From 767264eca52c676ea1bdf10c6d8493850e78130b Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Tue, 4 Apr 2023 10:54:50 -0700 Subject: [PATCH 1/7] resizable honored in handles --- packages/flutter_box_transform/lib/src/transformable_box.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/flutter_box_transform/lib/src/transformable_box.dart b/packages/flutter_box_transform/lib/src/transformable_box.dart index f2ef4bf..25b9ca9 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box.dart @@ -482,7 +482,7 @@ class _TransformableBoxState extends State { ), ), ), - for (final handle in HandlePosition.corners) + if(controller.resizable) for (final handle in HandlePosition.corners) _CornerHandleWidget( key: ValueKey(handle), handlePosition: handle, @@ -492,7 +492,7 @@ class _TransformableBoxState extends State { onPointerUpdate: onHandlePanUpdate, onPointerUp: onHandlePanEnd, ), - for (final handle in HandlePosition.sides) + if(controller.resizable) for (final handle in HandlePosition.sides) _SideHandleWidget( key: ValueKey(handle), handlePosition: handle, From 5af7874e3c97831f58634c5634bb24154ca99cac Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Tue, 4 Apr 2023 14:34:07 -0700 Subject: [PATCH 2/7] add hideHandlesWhenNotResizable flag --- .../lib/src/transformable_box.dart | 14 ++++++++++++-- .../lib/src/transformable_box_controller.dart | 12 ++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/packages/flutter_box_transform/lib/src/transformable_box.dart b/packages/flutter_box_transform/lib/src/transformable_box.dart index 25b9ca9..3086c51 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box.dart @@ -220,6 +220,10 @@ class TransformableBox extends StatefulWidget { /// Whether the box is resizable or not. Setting this to false will disable /// all resizing operations. final bool resizable; + + /// Whether the box should hide the corner/side resize controls when [resizable] is + /// false. + final bool hideHandlesWhenNotResizable; /// Whether the box is movable or not. Setting this to false will disable /// all moving operations. @@ -263,6 +267,7 @@ class TransformableBox extends StatefulWidget { this.onTerminalHeightReached, this.onTerminalSizeReached, this.resizable = true, + this.hideHandlesWhenNotResizable = true, this.movable = true, this.flipWhileResizing = true, this.flipChild = true, @@ -336,6 +341,7 @@ class _TransformableBoxState extends State { ..constraints = widget.constraints ..resolveResizeModeCallback = widget.resolveResizeModeCallback ..resizable = widget.resizable + ..hideHandlesWhenNotResizable = widget.hideHandlesWhenNotResizable ..movable = widget.movable ..flipWhileResizing = widget.flipWhileResizing ..flipChild = widget.flipChild; @@ -370,6 +376,10 @@ class _TransformableBoxState extends State { controller.resizable = widget.resizable; } + if(oldWidget.hideHandlesWhenNotResizable != widget.hideHandlesWhenNotResizable) { + controller.hideHandlesWhenNotResizable = widget.hideHandlesWhenNotResizable; + } + if (oldWidget.movable != widget.movable) { controller.movable = widget.movable; } @@ -482,7 +492,7 @@ class _TransformableBoxState extends State { ), ), ), - if(controller.resizable) for (final handle in HandlePosition.corners) + if(controller.resizable || !controller.hideHandlesWhenNotResizable) for (final handle in HandlePosition.corners) _CornerHandleWidget( key: ValueKey(handle), handlePosition: handle, @@ -492,7 +502,7 @@ class _TransformableBoxState extends State { onPointerUpdate: onHandlePanUpdate, onPointerUp: onHandlePanEnd, ), - if(controller.resizable) for (final handle in HandlePosition.sides) + if(controller.resizable || !controller.hideHandlesWhenNotResizable) for (final handle in HandlePosition.sides) _SideHandleWidget( key: ValueKey(handle), handlePosition: handle, diff --git a/packages/flutter_box_transform/lib/src/transformable_box_controller.dart b/packages/flutter_box_transform/lib/src/transformable_box_controller.dart index 5eafdd4..7272ac8 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box_controller.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box_controller.dart @@ -74,6 +74,10 @@ class TransformableBoxController extends ChangeNotifier { /// all resizing operations. bool resizable = true; + /// Whether the box should hide the corner/side resize controls when [resizable] is + /// false. + bool hideHandlesWhenNotResizable = true; + /// Whether to allow flipping of the box while resizing. If this is set to /// true, the box will flip when the user drags the handles to opposite /// corners of the rect. @@ -143,6 +147,14 @@ class TransformableBoxController extends ChangeNotifier { notifyListeners(); } + /// Whether the box should hide the corner/side resize controls when [resizable] is + /// false. + void setHideHandlesWhenNotResizable(bool hideHandlesWhenNotResizable) { + this.hideHandlesWhenNotResizable = hideHandlesWhenNotResizable; + notifyListeners(); + } + + /// Whether to allow flipping of the box while resizing. If this is set to /// true, the box will flip when the user drags the handles to opposite /// corners of the rect. From c73d9f24f18d65841771346116bddfe802516936 Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Tue, 4 Apr 2023 14:34:33 -0700 Subject: [PATCH 3/7] expand example to include hideHandlesWhenNotResizable and ability to add second image --- .../example/lib/main.dart | 158 ++++++++++++++---- 1 file changed, 128 insertions(+), 30 deletions(-) diff --git a/packages/flutter_box_transform/example/lib/main.dart b/packages/flutter_box_transform/example/lib/main.dart index 054d225..bb60986 100644 --- a/packages/flutter_box_transform/example/lib/main.dart +++ b/packages/flutter_box_transform/example/lib/main.dart @@ -15,6 +15,7 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { + return AdaptiveTheme( light: ThemeData( useMaterial3: true, @@ -60,6 +61,11 @@ class MyApp extends StatelessWidget { class PlaygroundModel with ChangeNotifier { Rect rect = Rect.zero; Flip flip = Flip.none; + + bool showSecondImageBox = false; + Rect rect2 = Rect.zero; + Flip flip2 = Flip.none; + Rect clampingRect = Rect.largest; Rect? playgroundArea; late BoxConstraints constraints = const BoxConstraints( @@ -73,6 +79,7 @@ class PlaygroundModel with ChangeNotifier { bool constraintsEnabled = false; bool resizable = true; bool movable = true; + bool hideHandlesWhenNotResizable = true; void reset(BuildContext context) { final Size size = MediaQuery.of(context).size; @@ -85,6 +92,15 @@ class PlaygroundModel with ChangeNotifier { kInitialHeight, ); flip = Flip.none; + + rect2 = Rect.fromLTWH( + (width - kInitialWidth) / 3, + (height - kInitialHeight) / 3, + kInitialWidth, + kInitialHeight, + ); + flip2 = Flip.none; + clampingRect = Rect.fromLTWH( 0, 0, @@ -101,6 +117,7 @@ class PlaygroundModel with ChangeNotifier { movable = true; clampingEnabled = false; constraintsEnabled = false; + hideHandlesWhenNotResizable = true; notifyListeners(); } @@ -111,6 +128,12 @@ class PlaygroundModel with ChangeNotifier { notifyListeners(); } + void onRect2Changed(UITransformResult result) { + rect2 = result.rect; + flip2 = result is UIResizeResult ? result.flip : flip; + notifyListeners(); + } + void onFlipChanged(Flip flip) { this.flip = flip; notifyListeners(); @@ -178,6 +201,16 @@ class PlaygroundModel with ChangeNotifier { notifyListeners(); } + void toggleHideHandlesWhenNotResizable(bool enabled) { + hideHandlesWhenNotResizable = enabled; + notifyListeners(); + } + + void toggleShowSecondImageBox(bool enabled) { + showSecondImageBox = enabled; + notifyListeners(); + } + void onClampingRectChanged({ double? left, double? top, @@ -230,7 +263,7 @@ const double kSidePanelWidth = 300; const double kInitialWidth = 400; const double kInitialHeight = 300; const double kStrokeWidth = 1.5; -const Color kGridColor = Color(0x7FC3E8F3); +const Color kGridColor = Color.fromARGB(126, 27, 181, 228); class _PlaygroundState extends State with WidgetsBindingObserver { @override @@ -311,7 +344,8 @@ class _PlaygroundState extends State with WidgetsBindingObserver { ), if (model.clampingEnabled && model.playgroundArea != null) const ClampingRect(), - const ImageBox(), + ImageBox(rect:model.rect, flip:model.flip, imageAsset:'assets/images/landscape2.jpg', onChanged:model.onRectChanged), + if(model.showSecondImageBox) ImageBox(rect:model.rect2, flip:model.flip2, imageAsset:'assets/images/landscape.jpg', onChanged:model.onRect2Changed), ], ), ), @@ -323,7 +357,13 @@ class _PlaygroundState extends State with WidgetsBindingObserver { } class ImageBox extends StatefulWidget { - const ImageBox({super.key}); + const ImageBox({super.key, required this.rect, required this.flip, required this.imageAsset, + required this.onChanged}); + + final Rect rect; + final Flip flip; + final String imageAsset; + final Function(TransformResult)? onChanged; @override State createState() => _ImageBoxState(); @@ -340,13 +380,14 @@ class _ImageBoxState extends State { final PlaygroundModel model = context.watch(); final Color handleColor = Theme.of(context).colorScheme.primary; return TransformableBox( - key: const ValueKey('image-box'), - rect: model.rect, - flip: model.flip, + key: ValueKey('image-box-${widget.imageAsset}'), + rect: widget.rect, + flip: widget.flip, clampingRect: model.clampingEnabled ? model.clampingRect : null, constraints: model.constraintsEnabled ? model.constraints : null, - onChanged: model.onRectChanged, + onChanged: widget.onChanged, resizable: model.resizable, + hideHandlesWhenNotResizable: model.hideHandlesWhenNotResizable, movable: model.movable, flipChild: model.flipChild, flipWhileResizing: model.flipRectWhileResizing, @@ -373,8 +414,8 @@ class _ImageBoxState extends State { height: rect.height, decoration: BoxDecoration( color: Colors.white, - image: const DecorationImage( - image: AssetImage('assets/images/landscape2.jpg'), + image: DecorationImage( + image: AssetImage(widget.imageAsset), fit: BoxFit.fill, ), border: Border.symmetric( @@ -646,12 +687,68 @@ class ControlPanel extends StatelessWidget { ), ), const Divider(height: 1), + Container( + height: 44, + padding: const EdgeInsets.fromLTRB(16, 0, 6, 0), + alignment: Alignment.centerLeft, + child: Row( + children: [ + Expanded( + child: Text( + 'Hide corner/side controls if not resizable', + style: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).colorScheme.secondary, + ), + ), + ), + SizedBox( + height: 20, + child: Transform.scale( + scale: 0.7, + child: Switch( + value: model.hideHandlesWhenNotResizable, + onChanged: (value) => model.toggleHideHandlesWhenNotResizable(value), + ), + ), + ), + ], + ), + ), + const Divider(height: 1), const FlipControls(), const Divider(height: 1), const ClampingControls(), const Divider(height: 1), const ConstraintsControls(), const Divider(height: 1), + Container( + height: 44, + padding: const EdgeInsets.fromLTRB(16, 0, 6, 0), + alignment: Alignment.centerLeft, + child: Row( + children: [ + Expanded( + child: Text( + 'Add second image', + style: Theme.of(context).textTheme.titleSmall!.copyWith( + color: Theme.of(context).colorScheme.secondary, + ), + ), + ), + SizedBox( + height: 20, + child: Transform.scale( + scale: 0.7, + child: Switch( + value: model.showSecondImageBox, + onChanged: (value) => model.toggleShowSecondImageBox(value), + ), + ), + ), + ], + ), + ), + const Divider(height: 1), ], ), ), @@ -676,8 +773,8 @@ class PositionControls extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('X')), SizedBox(width: 16), Expanded(child: Label('Y')), @@ -696,8 +793,8 @@ class PositionControls extends StatelessWidget { ], ), const SizedBox(height: 16), - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('WIDTH')), SizedBox(width: 16), Expanded(child: Label('HEIGHT')), @@ -716,8 +813,8 @@ class PositionControls extends StatelessWidget { ], ), const SizedBox(height: 16), - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('ASPECT RATIO')), ], ), @@ -869,14 +966,14 @@ class FlipControls extends StatelessWidget { ], selectedColor: Theme.of(context).colorScheme.primary, constraints: const BoxConstraints.tightFor(height: 32), - children: [ + children: const [ Tooltip( message: 'Flip Horizontally', - waitDuration: const Duration(milliseconds: 500), + waitDuration: Duration(milliseconds: 500), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 8), child: Row( - children: const [ + children: [ ImageIcon( AssetImage('assets/images/ic_flip.png'), size: 20, @@ -889,11 +986,11 @@ class FlipControls extends StatelessWidget { ), Tooltip( message: 'Flip Vertically', - waitDuration: const Duration(milliseconds: 500), + waitDuration: Duration(milliseconds: 500), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8), + padding: EdgeInsets.symmetric(horizontal: 8), child: Row( - children: const [ + children: [ RotatedBox( quarterTurns: 1, child: ImageIcon( @@ -1033,8 +1130,8 @@ class _ClampingControlsState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('LEFT')), SizedBox(width: 16), Expanded(child: Label('TOP')), @@ -1081,8 +1178,8 @@ class _ClampingControlsState extends State { ], ), const SizedBox(height: 16), - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('RIGHT')), SizedBox(width: 16), Expanded(child: Label('BOTTOM')), @@ -1281,8 +1378,8 @@ class _ConstraintsControlsState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('Min W')), SizedBox(width: 16), Expanded(child: Label('Min H')), @@ -1337,8 +1434,8 @@ class _ConstraintsControlsState extends State { ], ), const SizedBox(height: 16), - Row( - children: const [ + const Row( + children: [ Expanded(child: Label('Max W')), SizedBox(width: 16), Expanded(child: Label('Max H')), @@ -1530,3 +1627,4 @@ class SectionHeader extends StatelessWidget { ); } } + From 822e152e1724d6aa2644b58b3d79bd72caa1d427 Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Tue, 4 Apr 2023 15:46:07 -0700 Subject: [PATCH 4/7] dart format --- .../example/lib/main.dart | 29 ++++++++--- .../lib/src/transformable_box.dart | 50 ++++++++++--------- .../lib/src/transformable_box_controller.dart | 1 - 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/packages/flutter_box_transform/example/lib/main.dart b/packages/flutter_box_transform/example/lib/main.dart index bb60986..cee3aae 100644 --- a/packages/flutter_box_transform/example/lib/main.dart +++ b/packages/flutter_box_transform/example/lib/main.dart @@ -15,7 +15,6 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return AdaptiveTheme( light: ThemeData( useMaterial3: true, @@ -344,8 +343,17 @@ class _PlaygroundState extends State with WidgetsBindingObserver { ), if (model.clampingEnabled && model.playgroundArea != null) const ClampingRect(), - ImageBox(rect:model.rect, flip:model.flip, imageAsset:'assets/images/landscape2.jpg', onChanged:model.onRectChanged), - if(model.showSecondImageBox) ImageBox(rect:model.rect2, flip:model.flip2, imageAsset:'assets/images/landscape.jpg', onChanged:model.onRect2Changed), + ImageBox( + rect: model.rect, + flip: model.flip, + imageAsset: 'assets/images/landscape2.jpg', + onChanged: model.onRectChanged), + if (model.showSecondImageBox) + ImageBox( + rect: model.rect2, + flip: model.flip2, + imageAsset: 'assets/images/landscape.jpg', + onChanged: model.onRect2Changed), ], ), ), @@ -357,8 +365,12 @@ class _PlaygroundState extends State with WidgetsBindingObserver { } class ImageBox extends StatefulWidget { - const ImageBox({super.key, required this.rect, required this.flip, required this.imageAsset, - required this.onChanged}); + const ImageBox( + {super.key, + required this.rect, + required this.flip, + required this.imageAsset, + required this.onChanged}); final Rect rect; final Flip flip; @@ -707,7 +719,8 @@ class ControlPanel extends StatelessWidget { scale: 0.7, child: Switch( value: model.hideHandlesWhenNotResizable, - onChanged: (value) => model.toggleHideHandlesWhenNotResizable(value), + onChanged: (value) => + model.toggleHideHandlesWhenNotResizable(value), ), ), ), @@ -741,7 +754,8 @@ class ControlPanel extends StatelessWidget { scale: 0.7, child: Switch( value: model.showSecondImageBox, - onChanged: (value) => model.toggleShowSecondImageBox(value), + onChanged: (value) => + model.toggleShowSecondImageBox(value), ), ), ), @@ -1627,4 +1641,3 @@ class SectionHeader extends StatelessWidget { ); } } - diff --git a/packages/flutter_box_transform/lib/src/transformable_box.dart b/packages/flutter_box_transform/lib/src/transformable_box.dart index 3086c51..482ae70 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box.dart @@ -220,7 +220,7 @@ class TransformableBox extends StatefulWidget { /// Whether the box is resizable or not. Setting this to false will disable /// all resizing operations. final bool resizable; - + /// Whether the box should hide the corner/side resize controls when [resizable] is /// false. final bool hideHandlesWhenNotResizable; @@ -376,8 +376,10 @@ class _TransformableBoxState extends State { controller.resizable = widget.resizable; } - if(oldWidget.hideHandlesWhenNotResizable != widget.hideHandlesWhenNotResizable) { - controller.hideHandlesWhenNotResizable = widget.hideHandlesWhenNotResizable; + if (oldWidget.hideHandlesWhenNotResizable != + widget.hideHandlesWhenNotResizable) { + controller.hideHandlesWhenNotResizable = + widget.hideHandlesWhenNotResizable; } if (oldWidget.movable != widget.movable) { @@ -492,26 +494,28 @@ class _TransformableBoxState extends State { ), ), ), - if(controller.resizable || !controller.hideHandlesWhenNotResizable) for (final handle in HandlePosition.corners) - _CornerHandleWidget( - key: ValueKey(handle), - handlePosition: handle, - handleTapSize: widget.handleTapSize, - builder: widget.cornerHandleBuilder, - onPointerDown: onHandlePanStart, - onPointerUpdate: onHandlePanUpdate, - onPointerUp: onHandlePanEnd, - ), - if(controller.resizable || !controller.hideHandlesWhenNotResizable) for (final handle in HandlePosition.sides) - _SideHandleWidget( - key: ValueKey(handle), - handlePosition: handle, - handleTapSize: widget.handleTapSize, - builder: widget.sideHandleBuilder, - onPointerDown: onHandlePanStart, - onPointerUpdate: onHandlePanUpdate, - onPointerUp: onHandlePanEnd, - ), + if (controller.resizable || !controller.hideHandlesWhenNotResizable) + for (final handle in HandlePosition.corners) + _CornerHandleWidget( + key: ValueKey(handle), + handlePosition: handle, + handleTapSize: widget.handleTapSize, + builder: widget.cornerHandleBuilder, + onPointerDown: onHandlePanStart, + onPointerUpdate: onHandlePanUpdate, + onPointerUp: onHandlePanEnd, + ), + if (controller.resizable || !controller.hideHandlesWhenNotResizable) + for (final handle in HandlePosition.sides) + _SideHandleWidget( + key: ValueKey(handle), + handlePosition: handle, + handleTapSize: widget.handleTapSize, + builder: widget.sideHandleBuilder, + onPointerDown: onHandlePanStart, + onPointerUpdate: onHandlePanUpdate, + onPointerUp: onHandlePanEnd, + ), ], ), ); diff --git a/packages/flutter_box_transform/lib/src/transformable_box_controller.dart b/packages/flutter_box_transform/lib/src/transformable_box_controller.dart index 7272ac8..cd047f0 100644 --- a/packages/flutter_box_transform/lib/src/transformable_box_controller.dart +++ b/packages/flutter_box_transform/lib/src/transformable_box_controller.dart @@ -154,7 +154,6 @@ class TransformableBoxController extends ChangeNotifier { notifyListeners(); } - /// Whether to allow flipping of the box while resizing. If this is set to /// true, the box will flip when the user drags the handles to opposite /// corners of the rect. From 964ea76d941349ddfda5c540ac06b20b20841870 Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Tue, 4 Apr 2023 16:01:55 -0700 Subject: [PATCH 5/7] expanded second image to integrate better --- packages/flutter_box_transform/example/lib/main.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/flutter_box_transform/example/lib/main.dart b/packages/flutter_box_transform/example/lib/main.dart index cee3aae..752d5b3 100644 --- a/packages/flutter_box_transform/example/lib/main.dart +++ b/packages/flutter_box_transform/example/lib/main.dart @@ -65,6 +65,8 @@ class PlaygroundModel with ChangeNotifier { Rect rect2 = Rect.zero; Flip flip2 = Flip.none; + int lastRectAdjusted = 1; // 1 or 2 + Rect clampingRect = Rect.largest; Rect? playgroundArea; late BoxConstraints constraints = const BoxConstraints( @@ -100,6 +102,8 @@ class PlaygroundModel with ChangeNotifier { ); flip2 = Flip.none; + lastRectAdjusted = 1; + clampingRect = Rect.fromLTWH( 0, 0, @@ -124,12 +128,14 @@ class PlaygroundModel with ChangeNotifier { void onRectChanged(UITransformResult result) { rect = result.rect; flip = result is UIResizeResult ? result.flip : flip; + lastRectAdjusted = 1; notifyListeners(); } void onRect2Changed(UITransformResult result) { rect2 = result.rect; flip2 = result is UIResizeResult ? result.flip : flip; + lastRectAdjusted = 2; notifyListeners(); } @@ -172,11 +178,13 @@ class PlaygroundModel with ChangeNotifier { void flipHorizontally() { flip = Flip.fromValue(flip.horizontalValue * -1, flip.verticalValue); + flip2 = Flip.fromValue(flip2.horizontalValue * -1, flip2.verticalValue); notifyListeners(); } void flipVertically() { flip = Flip.fromValue(flip.horizontalValue, flip.verticalValue * -1); + flip2 = Flip.fromValue(flip2.horizontalValue, flip2.verticalValue * -1); notifyListeners(); } @@ -776,12 +784,12 @@ class PositionControls extends StatelessWidget { @override Widget build(BuildContext context) { final PlaygroundModel model = context.watch(); - final Rect rect = model.rect; + final Rect rect = model.lastRectAdjusted==1 ? model.rect : model.rect2; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - const SectionHeader('POSITION'), + SectionHeader('POSITION${model.lastRectAdjusted==2?" of SECOND IMAGE":""}'), Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), child: Column( From e49a0c262c028003e194c22def6523643fa30c4e Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Wed, 5 Apr 2023 10:16:51 -0700 Subject: [PATCH 6/7] dart format --- packages/flutter_box_transform/example/lib/main.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/flutter_box_transform/example/lib/main.dart b/packages/flutter_box_transform/example/lib/main.dart index 752d5b3..4b9ade6 100644 --- a/packages/flutter_box_transform/example/lib/main.dart +++ b/packages/flutter_box_transform/example/lib/main.dart @@ -784,12 +784,13 @@ class PositionControls extends StatelessWidget { @override Widget build(BuildContext context) { final PlaygroundModel model = context.watch(); - final Rect rect = model.lastRectAdjusted==1 ? model.rect : model.rect2; + final Rect rect = model.lastRectAdjusted == 1 ? model.rect : model.rect2; return Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - SectionHeader('POSITION${model.lastRectAdjusted==2?" of SECOND IMAGE":""}'), + SectionHeader( + 'POSITION${model.lastRectAdjusted == 2 ? " of SECOND IMAGE" : ""}'), Padding( padding: const EdgeInsets.fromLTRB(16, 0, 16, 16), child: Column( From 753ff0ef36ae9c89df3bbf023d8bb28072eeaf2b Mon Sep 17 00:00:00 2001 From: Tim Maffett Date: Wed, 5 Apr 2023 10:38:44 -0700 Subject: [PATCH 7/7] revert const changes which are not compatible with stable channel dart analyze --- .../example/lib/main.dart | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/packages/flutter_box_transform/example/lib/main.dart b/packages/flutter_box_transform/example/lib/main.dart index 4b9ade6..bc2ad02 100644 --- a/packages/flutter_box_transform/example/lib/main.dart +++ b/packages/flutter_box_transform/example/lib/main.dart @@ -796,8 +796,8 @@ class PositionControls extends StatelessWidget { child: Column( mainAxisSize: MainAxisSize.min, children: [ - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('X')), SizedBox(width: 16), Expanded(child: Label('Y')), @@ -816,8 +816,8 @@ class PositionControls extends StatelessWidget { ], ), const SizedBox(height: 16), - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('WIDTH')), SizedBox(width: 16), Expanded(child: Label('HEIGHT')), @@ -836,8 +836,8 @@ class PositionControls extends StatelessWidget { ], ), const SizedBox(height: 16), - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('ASPECT RATIO')), ], ), @@ -989,14 +989,14 @@ class FlipControls extends StatelessWidget { ], selectedColor: Theme.of(context).colorScheme.primary, constraints: const BoxConstraints.tightFor(height: 32), - children: const [ + children: [ Tooltip( message: 'Flip Horizontally', - waitDuration: Duration(milliseconds: 500), + waitDuration: const Duration(milliseconds: 500), child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: Row( - children: [ + children: const [ ImageIcon( AssetImage('assets/images/ic_flip.png'), size: 20, @@ -1009,11 +1009,11 @@ class FlipControls extends StatelessWidget { ), Tooltip( message: 'Flip Vertically', - waitDuration: Duration(milliseconds: 500), + waitDuration: const Duration(milliseconds: 500), child: Padding( - padding: EdgeInsets.symmetric(horizontal: 8), + padding: const EdgeInsets.symmetric(horizontal: 8), child: Row( - children: [ + children: const [ RotatedBox( quarterTurns: 1, child: ImageIcon( @@ -1153,8 +1153,8 @@ class _ClampingControlsState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('LEFT')), SizedBox(width: 16), Expanded(child: Label('TOP')), @@ -1201,8 +1201,8 @@ class _ClampingControlsState extends State { ], ), const SizedBox(height: 16), - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('RIGHT')), SizedBox(width: 16), Expanded(child: Label('BOTTOM')), @@ -1401,8 +1401,8 @@ class _ConstraintsControlsState extends State { crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, children: [ - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('Min W')), SizedBox(width: 16), Expanded(child: Label('Min H')), @@ -1457,8 +1457,8 @@ class _ConstraintsControlsState extends State { ], ), const SizedBox(height: 16), - const Row( - children: [ + Row( + children: const [ Expanded(child: Label('Max W')), SizedBox(width: 16), Expanded(child: Label('Max H')),