Skip to content

Commit

Permalink
fix demo
Browse files Browse the repository at this point in the history
  • Loading branch information
alextekartik committed Oct 12, 2024
1 parent 47e676b commit 8f1643b
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 25 deletions.
16 changes: 8 additions & 8 deletions example/app_pick_crop_image_demo/.metadata
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled.
# This file should be version controlled and should not be manually edited.

version:
revision: 796c8ef79279f9c774545b3771238c3098dbefab
channel: stable
revision: "2663184aa79047d0a33a14a3b607954f8fdd8730"
channel: "stable"

project_type: app

# Tracks metadata for the flutter migrate command
migration:
platforms:
- platform: root
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
- platform: linux
create_revision: 796c8ef79279f9c774545b3771238c3098dbefab
base_revision: 796c8ef79279f9c774545b3771238c3098dbefab
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
- platform: web
create_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730
base_revision: 2663184aa79047d0a33a14a3b607954f8fdd8730

# User provided section

Expand Down
4 changes: 2 additions & 2 deletions example/app_pick_crop_image_demo/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# tekartik flutter recommended lints (extension over google lints and pedantic)
include: package:tekartik_lints_flutter/strict.yaml
include: package:tekartik_lints_flutter/package.yaml

linter:
rules:
avoid_print: false
public_member_api_docs: false
8 changes: 4 additions & 4 deletions example/app_pick_crop_image_demo/lib/page/main_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,11 @@ class _MainPageState extends State<MainPage> {
imageSource = const PickCropImageSourceGallery();
}

print('imageSource: $imageSource');
// print('imageSource: $imageSource');
var width = _saveWidth();
var height = _saveHeight();
var ovalCropMask = _ovalCropMask.value;
print('width $width, height $height, cropOvalMask $ovalCropMask');
// print('width $width, height $height, cropOvalMask $ovalCropMask');

// ignore: use_build_context_synchronously
var result = await pickCropImage(context,
Expand All @@ -267,7 +267,7 @@ class _MainPageState extends State<MainPage> {
height: height,
source: imageSource,
ovalCropMask: ovalCropMask));
print('result: $result');
// print('result: $result');
if (result != null) {
_result.value = result;
}
Expand All @@ -282,7 +282,7 @@ class _MainPageState extends State<MainPage> {
child: ExpansionPanelList(
expansionCallback: (int index, bool isExpanded) {
var list = List<bool>.from(_isOpenPanels.value);
list[index] = !isExpanded;
list[index] = isExpanded;
_isOpenPanels.value = list;
},
children: [
Expand Down
4 changes: 2 additions & 2 deletions example/app_pick_crop_image_demo/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies:
shared_preferences:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
cupertino_icons: ">=1.0.2"

tekartik_app_pick_crop_image_flutter:
git:
Expand All @@ -52,7 +52,7 @@ dev_dependencies:
ref: dart3a
path: packages/lints_flutter
version: '>=0.1.0'

dev_build: ">=1.0.1"
dependency_overrides:
tekartik_app_pick_crop_image_flutter:
path: ../../packages/app_pick_crop_image_flutter
Expand Down
5 changes: 5 additions & 0 deletions example/app_pick_crop_image_demo/tool/run_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'package:dev_build/shell.dart';

Future<void> main() async {
await run('flutter run -d web-server --web-port 8060 --web-hostname 0.0.0.0');
}
6 changes: 5 additions & 1 deletion packages/app_image/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# tekartik lints over google lints
include: package:tekartik_lints/strict.yaml
include: package:tekartik_lints/package.yaml

linter:
rules:
public_member_api_docs: false
10 changes: 8 additions & 2 deletions packages/app_image/lib/image_composer/src/image_composer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ import 'package:tekartik_common_utils/common_utils_import.dart';
import 'package:tekartik_common_utils/size/size.dart';

var debugComposeImage = false; // devWarning(true);
void log(Object? message) {
if (debugComposeImage) {
// ignore: avoid_print
print(message);
}
}

class ImageComposerData {
final List<ImageLayerData> layers;
Expand Down Expand Up @@ -54,7 +60,7 @@ Future<ImageData> composeImage(ImageComposerData data) async {
fullImageDestination =
Rect<double>.fromLTWH(0, 0, width.toDouble(), height.toDouble());
if (debugComposeImage) {
print('/compose $fullImageDestination');
log('/compose $fullImageDestination');
}
}

Expand All @@ -79,7 +85,7 @@ Future<ImageData> composeImage(ImageComposerData data) async {

var dst = layer.destination ?? fullImageDestination;
if (debugComposeImage) {
print('/compose (${layerImage.width}x${layerImage.width}) $src -> $dst');
log('/compose (${layerImage.width}x${layerImage.width}) $src -> $dst');
}

impl.compositeImage(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ImageEncoding getImageEncodingFromBytes(Uint8List bytes) {
if (isJpg(bytes)) {
encoding = ImageEncodingJpg(quality: imageEncodingJpgQualityUnknown);
} else if (isPng(bytes)) {
encoding = ImageEncodingPng();
encoding = const ImageEncodingPng();
} else {
throw UnsupportedError('Unsupported image type');
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app_image/test/encoding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import 'package:test/test.dart';
void main() {
group('encoding', () {
test('png', () {
expect(ImageEncodingPng().mimeType, 'image/png');
expect(ImageEncodingPng().extension, '.png');
expect(const ImageEncodingPng().mimeType, 'image/png');
expect(const ImageEncodingPng().extension, '.png');
});
test('jpg', () {
expect(ImageEncodingJpg(quality: 75).mimeType, 'image/jpeg');
Expand Down
6 changes: 5 additions & 1 deletion packages/app_image_web/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# tekartik lints over google lints
include: package:tekartik_lints/strict.yaml
include: package:tekartik_lints/package.yaml

linter:
rules:
public_member_api_docs: false
1 change: 1 addition & 0 deletions packages/app_image_web/lib/src/image_composer/src/web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Future<ImageData> composeImage(ImageComposerData data) async {
}
var dst = layer.destination ?? fullImageDestination;
if (debugComposeImageWeb) {
// ignore: avoid_print
print(
'/web_compose (${layerCanvas.width}x${layerCanvas.width}) $src -> $dst');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ void main() {

test('blobToBytes png', () async {
var canvas = OffscreenCanvas(1, 1);
var blob = await canvas.toBlob(ImageEncodingPng());
var blob = await canvas.toBlob(const ImageEncodingPng());
var bytes = await blobToBytes(blob);
expect(isJpg(bytes), isFalse);
expect(isPng(bytes), isTrue);
Expand Down
6 changes: 5 additions & 1 deletion packages/app_pick_crop_image_flutter/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# tekartik flutter recommended lints (extension over google lints and pedantic)
include: package:tekartik_lints_flutter/strict.yaml
include: package:tekartik_lints_flutter/package.yaml

linter:
rules:
public_member_api_docs: false

0 comments on commit 8f1643b

Please sign in to comment.