From a9bd6af2756b293df71ef3213c5d512841e03e49 Mon Sep 17 00:00:00 2001 From: John McDole Date: Wed, 7 May 2025 13:52:54 -0700 Subject: [PATCH] Format code --- bin/generate.dart | 56 +++--- bin/test/generate_test.dart | 4 +- .../lib/animation_metadata.dart | 20 +- .../diagram_capture/lib/diagram_capture.dart | 5 +- .../test/diagram_capture_test.dart | 13 +- packages/diagram_generator/lib/main.dart | 43 +++-- .../lib/pages/diagram_catalog.dart | 31 ++-- .../lib/pages/diagram_viewer.dart | 7 +- .../test/diagram_viewer_test.dart | 4 +- packages/diagrams/lib/src/alert_dialog.dart | 41 +++-- .../diagrams/lib/src/animation_diagram.dart | 70 ++++--- packages/diagrams/lib/src/app_lifecycle.dart | 7 +- packages/diagrams/lib/src/arc_diagram.dart | 84 ++++----- packages/diagrams/lib/src/basic_shapes.dart | 171 ++++++++---------- .../diagrams/lib/src/checkbox_list_tile.dart | 9 +- packages/diagrams/lib/src/clip_diagram.dart | 96 +++++----- packages/diagrams/lib/src/colors.dart | 4 +- .../diagrams/lib/src/cupertino_colors.dart | 7 +- packages/diagrams/lib/src/curve.dart | 116 +++++------- packages/diagrams/lib/src/drawer.dart | 102 ++++++----- .../diagrams/lib/src/dropdown_button.dart | 12 +- packages/diagrams/lib/src/filter_quality.dart | 4 +- packages/diagrams/lib/src/font_feature.dart | 17 +- .../lib/src/go_router_push_animation.dart | 132 +++++++------- packages/diagrams/lib/src/image.dart | 80 ++++---- .../diagrams/lib/src/implicit_animations.dart | 30 +-- packages/diagrams/lib/src/list_view.dart | 4 +- .../diagrams/lib/src/radio_list_tile.dart | 9 +- packages/diagrams/lib/src/simple_dialog.dart | 92 +++++----- packages/diagrams/lib/src/stroke_cap.dart | 33 ++-- packages/diagrams/lib/src/stroke_join.dart | 47 +++-- .../diagrams/lib/src/switch_list_tile.dart | 9 +- packages/diagrams/lib/src/tabs.dart | 19 +- packages/diagrams/lib/src/text.dart | 43 ++--- packages/diagrams/lib/src/utils.dart | 7 +- 35 files changed, 688 insertions(+), 740 deletions(-) diff --git a/bin/generate.dart b/bin/generate.dart index ed0942fc..d0258a49 100644 --- a/bin/generate.dart +++ b/bin/generate.dart @@ -167,13 +167,12 @@ class DiagramGenerator { filters.add(temporaryDirectory.absolute.path); late final List filterArgs; if (deviceTargetPlatform.startsWith('android')) { - filterArgs = - filters.isNotEmpty - ? [ - '--route', - 'args:${Uri.encodeComponent(filters.join(' '))}', - ] - : []; + filterArgs = filters.isNotEmpty + ? [ + '--route', + 'args:${Uri.encodeComponent(filters.join(' '))}', + ] + : []; } else { filterArgs = []; for (final String arg in filters) { @@ -205,8 +204,8 @@ class DiagramGenerator { ) || (entry['id'] as String) == device) { deviceId = entry['id'] as String; - deviceTargetPlatform = - (entry['targetPlatform'] as String).toLowerCase(); + deviceTargetPlatform = (entry['targetPlatform'] as String) + .toLowerCase(); return true; } } @@ -420,10 +419,9 @@ class DiagramGenerator { } Future> _combineAnimations(List inputFiles) async { - final List errorFiles = - inputFiles - .where((File input) => path.basename(input.path) == 'error.log') - .toList(); + final List errorFiles = inputFiles + .where((File input) => path.basename(input.path) == 'error.log') + .toList(); if (errorFiles.length != 1) { throw GeneratorException('Subprocess did not complete cleanly!'); @@ -442,10 +440,9 @@ class DiagramGenerator { throw GeneratorException('Failed with errors (see $errorsFileName).'); } - final List metadataFiles = - inputFiles - .where((File input) => path.extension(input.path) == '.json') - .toList(); + final List metadataFiles = inputFiles + .where((File input) => path.extension(input.path) == '.json') + .toList(); // Collect all the animation frames that are in the metadata files so that // we can eliminate them from the other files that were transferred. @@ -468,19 +465,18 @@ class DiagramGenerator { metadata.frameFiles.map((File file) => file.absolute.path), ); } - final List staticFiles = - inputFiles.where((File input) { - if (!input.isAbsolute) { - input = File( - path.normalize( - path.join(temporaryDirectory.absolute.path, input.path), - ), - ); - } else { - input = File(path.normalize(input.path)); - } - return !animationFiles.contains(input.absolute.path); - }).toList(); + final List staticFiles = inputFiles.where((File input) { + if (!input.isAbsolute) { + input = File( + path.normalize( + path.join(temporaryDirectory.absolute.path, input.path), + ), + ); + } else { + input = File(path.normalize(input.path)); + } + return !animationFiles.contains(input.absolute.path); + }).toList(); final List convertedFiles = await _buildMoviesFromMetadata( metadataList, ); diff --git a/bin/test/generate_test.dart b/bin/test/generate_test.dart index 42212b36..7797fbab 100644 --- a/bin/test/generate_test.dart +++ b/bin/test/generate_test.dart @@ -73,7 +73,9 @@ void main() { 'packages', 'diagram_generator', ), - ): [ProcessResult(0, 0, '', '')], + ): [ + ProcessResult(0, 0, '', ''), + ], FakeInvocationRecord([ 'optipng', '-zc1-9', diff --git a/packages/animation_metadata/lib/animation_metadata.dart b/packages/animation_metadata/lib/animation_metadata.dart index 28f64a51..b0261c99 100644 --- a/packages/animation_metadata/lib/animation_metadata.dart +++ b/packages/animation_metadata/lib/animation_metadata.dart @@ -29,10 +29,11 @@ class AnimationMetadata { final Map metadata = json.decode(metadataFile.readAsStringSync()) as Map; final String baseDir = path.dirname(metadataFile.absolute.path); - final List frameFiles = - (metadata[_frameFilesKey]! as List).map((dynamic name) { + final List frameFiles = (metadata[_frameFilesKey]! as List) + .map((dynamic name) { return File(path.normalize(path.join(baseDir, name.toString()))); - }).toList(); + }) + .toList(); final Duration duration = Duration( milliseconds: metadata[_durationMsKey]! as int, ); @@ -66,13 +67,12 @@ class AnimationMetadata { _videoFormatKey: videoFormat.name, _frameRateKey: frameRate, _widthKey: width, - _frameFilesKey: - frameFiles.map((File file) { - return path.relative( - file.path, - from: path.dirname(metadataFile.absolute.path), - ); - }).toList(), + _frameFilesKey: frameFiles.map((File file) { + return path.relative( + file.path, + from: path.dirname(metadataFile.absolute.path), + ); + }).toList(), }; const JsonEncoder encoder = JsonEncoder.withIndent(' '); final String jsonMetadata = encoder.convert(metadata); diff --git a/packages/diagram_capture/lib/diagram_capture.dart b/packages/diagram_capture/lib/diagram_capture.dart index e6ed3f5b..c91ff344 100644 --- a/packages/diagram_capture/lib/diagram_capture.dart +++ b/packages/diagram_capture/lib/diagram_capture.dart @@ -444,8 +444,9 @@ class DiagramController { milliseconds: 1000 ~/ framerate, ); while (timestamp != Duration.zero) { - final Duration advanceBy = - timestamp > framerateDuration ? framerateDuration : timestamp; + final Duration advanceBy = timestamp > framerateDuration + ? framerateDuration + : timestamp; timestamp -= advanceBy; await advanceTime(advanceBy); } diff --git a/packages/diagram_capture/test/diagram_capture_test.dart b/packages/diagram_capture/test/diagram_capture_test.dart index 7988a7f3..c6edf92b 100644 --- a/packages/diagram_capture/test/diagram_capture_test.dart +++ b/packages/diagram_capture/test/diagram_capture_test.dart @@ -90,8 +90,8 @@ void main() { screenDimensions: const Size(100.0, 100.0), ); - controller.builder = - (BuildContext context) => TestAnimatedDiagram(key: key, size: 50.0); + controller.builder = (BuildContext context) => + TestAnimatedDiagram(key: key, size: 50.0); final List outputImages = await controller .drawAnimatedDiagramToImages( end: const Duration(milliseconds: 1200), @@ -115,8 +115,8 @@ void main() { screenDimensions: const Size(100.0, 100.0), ); - controller.builder = - (BuildContext context) => TestAnimatedDiagram(key: key, size: 50.0); + controller.builder = (BuildContext context) => + TestAnimatedDiagram(key: key, size: 50.0); final File outputFile = await controller.drawAnimatedDiagramToFiles( end: const Duration(milliseconds: 1200), frameRate: 5.0, @@ -177,8 +177,9 @@ void main() { expect(decodedImage.width, equals(300)); expect(decodedImage.height, equals(150)); expect(decodedImage.length, equals(45000)); - final image.Pixel testPixel = - decodedImage.getRange(150, 20, 1, 1).current; + final image.Pixel testPixel = decodedImage + .getRange(150, 20, 1, 1) + .current; expect(testPixel.a, equals(0xfe)); expect(testPixel.r, equals(0xed)); expect(testPixel.g, equals(0xbe)); diff --git a/packages/diagram_generator/lib/main.dart b/packages/diagram_generator/lib/main.dart index 2f8be25d..3e44d345 100644 --- a/packages/diagram_generator/lib/main.dart +++ b/packages/diagram_generator/lib/main.dart @@ -41,12 +41,11 @@ Future main(List args) async { DiagramFlutterBinding.ensureInitialized(); late final List arguments; if (platform.isAndroid) { - arguments = - PlatformDispatcher.instance.defaultRouteName.length > 5 - ? Uri.decodeComponent( - PlatformDispatcher.instance.defaultRouteName.substring(5), - ).split(' ') - : []; + arguments = PlatformDispatcher.instance.defaultRouteName.length > 5 + ? Uri.decodeComponent( + PlatformDispatcher.instance.defaultRouteName.substring(5), + ).split(' ') + : []; } else { arguments = args; } @@ -72,16 +71,15 @@ Future main(List args) async { final List categories = flags['category'] as List; final List names = flags['name'] as List; final List steps = flags['step'] as List; - final Set platforms = - (flags['platform'] as List).map(( - String platformStr, - ) { + final Set platforms = (flags['platform'] as List) + .map((String platformStr) { assert( diagramStepPlatformNames.containsKey(platformStr), 'Invalid platform $platformStr', ); return diagramStepPlatformNames[platformStr]!; - }).toSet(); + }) + .toSet(); print( 'Filters:\n categories: $categories\n names: $names\n steps: $steps', @@ -102,17 +100,18 @@ Future main(List args) async { Zone.current .fork( specification: ZoneSpecification( - handleUncaughtError: ( - Zone self, - ZoneDelegate parent, - Zone zone, - Object error, - StackTrace stackTrace, - ) { - print('Exception! $error\n$stackTrace'); - errorLog.writeln(error); - errorLog.writeln(stackTrace); - }, + handleUncaughtError: + ( + Zone self, + ZoneDelegate parent, + Zone zone, + Object error, + StackTrace stackTrace, + ) { + print('Exception! $error\n$stackTrace'); + errorLog.writeln(error); + errorLog.writeln(stackTrace); + }, ), ) .runGuarded(() async { diff --git a/packages/diagram_viewer/lib/pages/diagram_catalog.dart b/packages/diagram_viewer/lib/pages/diagram_catalog.dart index ce940d5c..0c22c009 100644 --- a/packages/diagram_viewer/lib/pages/diagram_catalog.dart +++ b/packages/diagram_viewer/lib/pages/diagram_catalog.dart @@ -104,10 +104,9 @@ class CatalogTile extends StatelessWidget { child: Text( name, style: TextStyle( - color: - Theme.of(context).brightness == Brightness.light - ? Colors.white - : Colors.black, + color: Theme.of(context).brightness == Brightness.light + ? Colors.white + : Colors.black, fontWeight: FontWeight.bold, fontSize: 16.0, ), @@ -136,9 +135,8 @@ class StepTile extends StatelessWidget { final List diagrams = await step.diagrams; Navigator.of(context).push( MaterialPageRoute( - builder: - (BuildContext context) => - DiagramViewerPage(step: step, diagrams: diagrams), + builder: (BuildContext context) => + DiagramViewerPage(step: step, diagrams: diagrams), ), ); } @@ -148,16 +146,15 @@ class StepTile extends StatelessWidget { return ListTile( shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20.0)), title: Text(step.runtimeType.toString()), - trailing: - step.platforms.containsAll(DiagramPlatform.values) - ? null - : Row( - mainAxisSize: MainAxisSize.min, - children: [ - for (final DiagramPlatform platform in step.platforms) - Chip(label: Text(platform.name)), - ], - ), + trailing: step.platforms.containsAll(DiagramPlatform.values) + ? null + : Row( + mainAxisSize: MainAxisSize.min, + children: [ + for (final DiagramPlatform platform in step.platforms) + Chip(label: Text(platform.name)), + ], + ), visualDensity: const VisualDensity(vertical: -4), onTap: () => openDiagramStepViewer(context, step), ); diff --git a/packages/diagram_viewer/lib/pages/diagram_viewer.dart b/packages/diagram_viewer/lib/pages/diagram_viewer.dart index bb0adcc0..3d4cb633 100644 --- a/packages/diagram_viewer/lib/pages/diagram_viewer.dart +++ b/packages/diagram_viewer/lib/pages/diagram_viewer.dart @@ -112,10 +112,9 @@ class _DiagramViewerPageState extends State padding: const EdgeInsets.all(8.0), child: Material( shape: const StadiumBorder(), - color: - theme.brightness == Brightness.light - ? theme.primaryColor - : theme.colorScheme.surface, + color: theme.brightness == Brightness.light + ? theme.primaryColor + : theme.colorScheme.surface, elevation: 4, ), ), diff --git a/packages/diagram_viewer/test/diagram_viewer_test.dart b/packages/diagram_viewer/test/diagram_viewer_test.dart index a23c413b..2c0bc063 100644 --- a/packages/diagram_viewer/test/diagram_viewer_test.dart +++ b/packages/diagram_viewer/test/diagram_viewer_test.dart @@ -98,7 +98,9 @@ void main() { final DiagramStep step = TestDiagramStep(); final List diagrams = await step.diagrams; await tester.pumpWidget( - DiagramViewerApp(home: DiagramViewerPage(step: step, diagrams: diagrams)), + DiagramViewerApp( + home: DiagramViewerPage(step: step, diagrams: diagrams), + ), ); await tester.pump(const Duration(minutes: 1)); for (final DiagramMetadata diagram in diagrams) { diff --git a/packages/diagrams/lib/src/alert_dialog.dart b/packages/diagrams/lib/src/alert_dialog.dart index 44eeff29..daa01557 100644 --- a/packages/diagrams/lib/src/alert_dialog.dart +++ b/packages/diagrams/lib/src/alert_dialog.dart @@ -61,26 +61,27 @@ class _AlertDialogDiagramState extends State initialRoute: '/', onGenerateRoute: (RouteSettings settings) { return PageRouteBuilder( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) { - return Scaffold( - appBar: AppBar(title: const Text('AlertDialog Demo')), - body: Center( - child: Builder( - builder: (BuildContext context) { - return OutlinedButton( - key: _openDialogKey, - child: const Text('Show Dialog'), - onPressed: () => _neverSatisfied(context), - ); - }, - ), - ), - ); - }, + pageBuilder: + ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return Scaffold( + appBar: AppBar(title: const Text('AlertDialog Demo')), + body: Center( + child: Builder( + builder: (BuildContext context) { + return OutlinedButton( + key: _openDialogKey, + child: const Text('Show Dialog'), + onPressed: () => _neverSatisfied(context), + ); + }, + ), + ), + ); + }, ); }, ), diff --git a/packages/diagrams/lib/src/animation_diagram.dart b/packages/diagrams/lib/src/animation_diagram.dart index fb0af806..93fd0c8e 100644 --- a/packages/diagrams/lib/src/animation_diagram.dart +++ b/packages/diagrams/lib/src/animation_diagram.dart @@ -63,15 +63,14 @@ class TransitionDiagramState extends State> @override void initState() { super.initState(); - _controller = AnimationController( - duration: _kAnimationDuration, - vsync: this, - )..addListener(() { - setState(() { - // The animation controller is changing the animation value, so we - // need to redraw. - }); - }); + _controller = + AnimationController(duration: _kAnimationDuration, vsync: this) + ..addListener(() { + setState(() { + // The animation controller is changing the animation value, so we + // need to redraw. + }); + }); animation = widget.buildAnimation(_controller); } @@ -233,30 +232,26 @@ class SparklinePainter extends CustomPainter { final Curve curve; final double position; - static final Paint _axisPaint = - Paint() - ..color = Colors.black45 - ..style = PaintingStyle.stroke - ..strokeWidth = 2.0; - - static final Paint _sparklinePaint = - Paint() - ..color = Colors.blue.shade900 - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeWidth = 4.0; - - static final Paint _graphProgressPaint = - Paint() - ..color = Colors.black26 - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeWidth = 4.0; - - static final Paint _positionCirclePaint = - Paint() - ..color = Colors.blue.shade900 - ..style = PaintingStyle.fill; + static final Paint _axisPaint = Paint() + ..color = Colors.black45 + ..style = PaintingStyle.stroke + ..strokeWidth = 2.0; + + static final Paint _sparklinePaint = Paint() + ..color = Colors.blue.shade900 + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeWidth = 4.0; + + static final Paint _graphProgressPaint = Paint() + ..color = Colors.black26 + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeWidth = 4.0; + + static final Paint _positionCirclePaint = Paint() + ..color = Colors.blue.shade900 + ..style = PaintingStyle.fill; @override void paint(Canvas canvas, Size size) { @@ -272,11 +267,10 @@ class SparklinePainter extends CustomPainter { size.width - rightMargin, size.height - topMargin, ); - final Path axes = - Path() - ..moveTo(area.left, area.top) // vertical axis - ..lineTo(area.left, area.bottom) // origin - ..lineTo(area.right, area.bottom); // horizontal axis + final Path axes = Path() + ..moveTo(area.left, area.top) // vertical axis + ..lineTo(area.left, area.bottom) // origin + ..lineTo(area.right, area.bottom); // horizontal axis canvas.drawPath(axes, _axisPaint); final Offset activePoint = FractionalOffset( position, diff --git a/packages/diagrams/lib/src/app_lifecycle.dart b/packages/diagrams/lib/src/app_lifecycle.dart index f308a649..e389aa7a 100644 --- a/packages/diagrams/lib/src/app_lifecycle.dart +++ b/packages/diagrams/lib/src/app_lifecycle.dart @@ -190,10 +190,9 @@ class AppLifecycleStateBox extends StatelessWidget { width: AppLifecycleDiagram.stateBoxWidth, height: AppLifecycleDiagram.stateBoxHeight, decoration: ShapeDecoration( - color: - Theme.of(context).brightness == Brightness.light - ? Colors.blue.shade100 - : Colors.blue.shade800, + color: Theme.of(context).brightness == Brightness.light + ? Colors.blue.shade100 + : Colors.blue.shade800, shape: RoundedRectangleBorder( side: const BorderSide(width: 3), borderRadius: BorderRadius.circular(10), diff --git a/packages/diagrams/lib/src/arc_diagram.dart b/packages/diagrams/lib/src/arc_diagram.dart index d3dd2e1a..3a3e1e50 100644 --- a/packages/diagrams/lib/src/arc_diagram.dart +++ b/packages/diagrams/lib/src/arc_diagram.dart @@ -223,10 +223,9 @@ void paintArrowHead( final Vector2 topVec = matrix.transform(Vector2(-length, length)); final Vector2 bottomVec = matrix.transform(Vector2(-length, -length)); - final Path path = - Path() - ..moveTo(center.dx + bottomVec.x, center.dy + bottomVec.y) - ..lineTo(center.dx, center.dy); + final Path path = Path() + ..moveTo(center.dx + bottomVec.x, center.dy + bottomVec.y) + ..lineTo(center.dx, center.dy); if (!bottomOnly) { path.lineTo(center.dx + topVec.x, center.dy + topVec.y); @@ -289,13 +288,12 @@ class ArcDiagramPainter extends CustomPainter { sin(startAngle + sweepAngle) * arcRect.height / 2, ); - final Paint paint = - Paint() - ..color = theme.hintColor - ..strokeWidth = 2.0 - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeJoin = StrokeJoin.round; + final Paint paint = Paint() + ..color = theme.hintColor + ..strokeWidth = 2.0 + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeJoin = StrokeJoin.round; // Unit circle, 8 angles at 45 degree increments for (int i = 0; i < 8; i++) { @@ -331,31 +329,29 @@ class ArcDiagramPainter extends CustomPainter { TextSpan( children: [ TextSpan( - text: - const [ - '0°, 360°', - '45°', - '90°', - '135°', - '180°', - '225°', - '270°', - '315°', - ][i], + text: const [ + '0°, 360°', + '45°', + '90°', + '135°', + '180°', + '225°', + '270°', + '315°', + ][i], ), const TextSpan(text: '\n'), TextSpan( - text: - const [ - '0, 2π', - 'π/4', - 'π/2', - '3π/4', - 'π', - '5π/4', - '3π/2', - '7π/4', - ][i], + text: const [ + '0, 2π', + 'π/4', + 'π/2', + '3π/4', + 'π', + '5π/4', + '3π/2', + '7π/4', + ][i], style: const TextStyle(fontWeight: FontWeight.bold), ), ], @@ -425,8 +421,11 @@ class ArcDiagramPainter extends CustomPainter { fontWeight: FontWeight.bold, ), alignment: 0.0, - theta: - lerpDouble(startAngle, startAngle + sweepAngle, sweepLabelAlignment)!, + theta: lerpDouble( + startAngle, + startAngle + sweepAngle, + sweepLabelAlignment, + )!, ); // Draw arrow at startAngle @@ -460,8 +459,9 @@ class CanvasDrawArcDiagram extends ArcDiagram { @override Widget build(BuildContext context) { - final ArcDiagramTheme theme = - dark ? ArcDiagramTheme.dark : ArcDiagramTheme.light; + final ArcDiagramTheme theme = dark + ? ArcDiagramTheme.dark + : ArcDiagramTheme.light; return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -516,8 +516,9 @@ class PathAddArcDiagram extends ArcDiagram { @override Widget build(BuildContext context) { - final ArcDiagramTheme theme = - dark ? ArcDiagramTheme.dark : ArcDiagramTheme.light; + final ArcDiagramTheme theme = dark + ? ArcDiagramTheme.dark + : ArcDiagramTheme.light; return Row( mainAxisSize: MainAxisSize.min, children: [ @@ -570,8 +571,9 @@ class PathAddArcCCWDiagram extends ArcDiagram { @override Widget build(BuildContext context) { - final ArcDiagramTheme theme = - dark ? ArcDiagramTheme.dark : ArcDiagramTheme.light; + final ArcDiagramTheme theme = dark + ? ArcDiagramTheme.dark + : ArcDiagramTheme.light; return Row( mainAxisSize: MainAxisSize.min, children: [ diff --git a/packages/diagrams/lib/src/basic_shapes.dart b/packages/diagrams/lib/src/basic_shapes.dart index a569a57f..277ccb0c 100644 --- a/packages/diagrams/lib/src/basic_shapes.dart +++ b/packages/diagrams/lib/src/basic_shapes.dart @@ -57,11 +57,10 @@ class ShapeDiagramTheme { final double rightArrow = rightEdge - arrowNudge; final double bottomArrow = bottomEdge - arrowNudge; - final Paint paint = - Paint() - ..color = xyPlaneColor - ..style = PaintingStyle.stroke - ..strokeWidth = 3.5; + final Paint paint = Paint() + ..color = xyPlaneColor + ..style = PaintingStyle.stroke + ..strokeWidth = 3.5; // Draw main lines going to the right and down @@ -195,11 +194,10 @@ class LineDiagramPainter extends CustomPainter { theme.paintXYPlane(canvas); - final Paint paint = - Paint() - ..strokeWidth = 5.0 - ..style = PaintingStyle.stroke - ..color = theme.foregroundColor; + final Paint paint = Paint() + ..strokeWidth = 5.0 + ..style = PaintingStyle.stroke + ..color = theme.foregroundColor; final Offset start = const Offset(2, 4) * _kGridSize; final Offset end = const Offset(8, 2) * _kGridSize; @@ -262,11 +260,10 @@ class RectConstructorDiagramPainter extends CustomPainter { canvas.save(); canvas.translate(showBottom ? 90 : 60, showBottom ? 60 : 50); - final Paint paint = - Paint() - ..strokeWidth = 4.0 - ..style = PaintingStyle.stroke - ..color = theme.shapeColor; + final Paint paint = Paint() + ..strokeWidth = 4.0 + ..style = PaintingStyle.stroke + ..color = theme.shapeColor; final Rect rect = Rect.fromPoints( const Offset(2, 2) * _kGridSize, @@ -425,11 +422,10 @@ class OvalDiagramPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { void drawRect(Rect rect, PaintingStyle style) { - final Paint paint = - Paint() - ..strokeWidth = 4.0 - ..style = PaintingStyle.stroke - ..color = theme.hintColor; + final Paint paint = Paint() + ..strokeWidth = 4.0 + ..style = PaintingStyle.stroke + ..color = theme.hintColor; canvas.drawRect(rect, paint); @@ -498,11 +494,10 @@ class RectDiagramPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { void drawRect(RRect rrect, PaintingStyle style) { - final Paint paint = - Paint() - ..strokeWidth = 4.0 - ..style = PaintingStyle.stroke - ..color = theme.foregroundColor; + final Paint paint = Paint() + ..strokeWidth = 4.0 + ..style = PaintingStyle.stroke + ..color = theme.foregroundColor; canvas.drawRRect(rrect, paint); @@ -650,11 +645,10 @@ class ConicToDiagramPainter extends CustomPainter { final double x1 = (x + x2) / 2; final double y1 = size.height * 0.1; - final Paint paint = - Paint() - ..color = theme.hintColor - ..strokeWidth = 5.0 - ..style = PaintingStyle.stroke; + final Paint paint = Paint() + ..color = theme.hintColor + ..strokeWidth = 5.0 + ..style = PaintingStyle.stroke; canvas.drawPath( Path() @@ -725,11 +719,10 @@ class QuadraticToDiagramPainter extends CustomPainter { final double x1 = (x + x2) / 2; final double y1 = size.height * 0.1; - final Paint paint = - Paint() - ..color = theme.shapeColor - ..strokeWidth = 5.0 - ..style = PaintingStyle.stroke; + final Paint paint = Paint() + ..color = theme.shapeColor + ..strokeWidth = 5.0 + ..style = PaintingStyle.stroke; canvas.drawPath( Path() @@ -762,11 +755,10 @@ class CubicToDiagramPainter extends CustomPainter { final double x3 = size.width * 0.9; final double y3 = size.height * 0.5; - final Paint paint = - Paint() - ..color = theme.hintColor - ..strokeWidth = 3.0 - ..style = PaintingStyle.stroke; + final Paint paint = Paint() + ..color = theme.hintColor + ..strokeWidth = 3.0 + ..style = PaintingStyle.stroke; canvas.drawLine(Offset(x, y), Offset(x1, y1), paint); @@ -914,66 +906,60 @@ class BasicShapesStep extends DiagramStep { ), BasicShapesDiagram( name: 'canvas_rrect', - painter: - (ShapeDiagramTheme theme) => - RectDiagramPainter(theme: theme, label: 'rrect', radius: 24), + painter: (ShapeDiagramTheme theme) => + RectDiagramPainter(theme: theme, label: 'rrect', radius: 24), width: 640, height: 384, ), BasicShapesDiagram( name: 'rect_from_ltrb', - painter: - (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( - theme: theme, - showLeft: true, - showTop: true, - showRight: true, - showBottom: true, - ), + painter: (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( + theme: theme, + showLeft: true, + showTop: true, + showRight: true, + showBottom: true, + ), width: 580, height: 380, ), BasicShapesDiagram( name: 'rect_from_ltwh', - painter: - (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( - theme: theme, - showLeft: true, - showTop: true, - showWidth: true, - showHeight: true, - ), + painter: (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( + theme: theme, + showLeft: true, + showTop: true, + showWidth: true, + showHeight: true, + ), width: 550, height: 370, ), BasicShapesDiagram( name: 'rect_from_points', - painter: - (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( - theme: theme, - showTopLeft: true, - showBottomRight: true, - ), + painter: (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( + theme: theme, + showTopLeft: true, + showBottomRight: true, + ), width: 550, height: 370, ), BasicShapesDiagram( name: 'rect_from_center', - painter: - (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( - theme: theme, - showWidth: true, - showHeight: true, - showCenter: true, - ), + painter: (ShapeDiagramTheme theme) => RectConstructorDiagramPainter( + theme: theme, + showWidth: true, + showHeight: true, + showCenter: true, + ), width: 550, height: 370, ), BasicShapesDiagram( name: 'rect_from_circle', - painter: - (ShapeDiagramTheme theme) => - CircleDiagramPainter(theme: theme, square: true), + painter: (ShapeDiagramTheme theme) => + CircleDiagramPainter(theme: theme, square: true), width: 625, height: 410, ), @@ -985,50 +971,47 @@ class BasicShapesStep extends DiagramStep { ), BasicShapesDiagram( name: 'canvas_circle', - painter: - (ShapeDiagramTheme theme) => CircleDiagramPainter(theme: theme), + painter: (ShapeDiagramTheme theme) => + CircleDiagramPainter(theme: theme), width: 625, height: 410, ), BasicShapesDiagram( name: 'path_conic_to', - painter: - (ShapeDiagramTheme theme) => ConicToDiagramPainter(theme: theme), + painter: (ShapeDiagramTheme theme) => + ConicToDiagramPainter(theme: theme), width: 600, height: 350, ), BasicShapesDiagram( name: 'path_quadratic_to', - painter: - (ShapeDiagramTheme theme) => - QuadraticToDiagramPainter(theme: theme), + painter: (ShapeDiagramTheme theme) => + QuadraticToDiagramPainter(theme: theme), width: 600, height: 350, ), BasicShapesDiagram( name: 'path_cubic_to', - painter: - (ShapeDiagramTheme theme) => CubicToDiagramPainter(theme: theme), + painter: (ShapeDiagramTheme theme) => + CubicToDiagramPainter(theme: theme), width: 500, height: 350, ), BasicShapesDiagram( name: 'radius_circular', - painter: - (ShapeDiagramTheme theme) => RadiusDiagramPainter( - theme: theme, - radius: const Radius.circular(96), - ), + painter: (ShapeDiagramTheme theme) => RadiusDiagramPainter( + theme: theme, + radius: const Radius.circular(96), + ), width: 500, height: 350, ), BasicShapesDiagram( name: 'radius_elliptical', - painter: - (ShapeDiagramTheme theme) => RadiusDiagramPainter( - theme: theme, - radius: const Radius.elliptical(144, 96), - ), + painter: (ShapeDiagramTheme theme) => RadiusDiagramPainter( + theme: theme, + radius: const Radius.elliptical(144, 96), + ), width: 500, height: 350, ), diff --git a/packages/diagrams/lib/src/checkbox_list_tile.dart b/packages/diagrams/lib/src/checkbox_list_tile.dart index 3e0f3b0b..0f97eaff 100644 --- a/packages/diagrams/lib/src/checkbox_list_tile.dart +++ b/packages/diagrams/lib/src/checkbox_list_tile.dart @@ -38,11 +38,10 @@ class LinkedLabelCheckbox extends StatelessWidget { color: Colors.blueAccent, decoration: TextDecoration.underline, ), - recognizer: - TapGestureRecognizer() - ..onTap = () { - print('Link has been tapped.'); - }, + recognizer: TapGestureRecognizer() + ..onTap = () { + print('Link has been tapped.'); + }, ), ), ), diff --git a/packages/diagrams/lib/src/clip_diagram.dart b/packages/diagrams/lib/src/clip_diagram.dart index 04394c4e..cb9b038d 100644 --- a/packages/diagrams/lib/src/clip_diagram.dart +++ b/packages/diagrams/lib/src/clip_diagram.dart @@ -67,11 +67,10 @@ class ClipRectPainter extends CustomPainter { _drawBackground(canvas, size); canvas.restore(); - final Paint paint = - Paint() - ..style = PaintingStyle.stroke - ..color = Colors.white - ..strokeWidth = 3.0; + final Paint paint = Paint() + ..style = PaintingStyle.stroke + ..color = Colors.white + ..strokeWidth = 3.0; canvas.drawRect(rect, paint); } @@ -97,11 +96,10 @@ class ClipRRectPainter extends CustomPainter { _drawBackground(canvas, size); canvas.restore(); - final Paint paint = - Paint() - ..style = PaintingStyle.stroke - ..color = Colors.white - ..strokeWidth = 3.0; + final Paint paint = Paint() + ..style = PaintingStyle.stroke + ..color = Colors.white + ..strokeWidth = 3.0; canvas.drawRRect(rrect, paint); } @@ -127,52 +125,50 @@ class ClipPathPainter extends CustomPainter { const double topControl = 60.0; const double middleControl = 75.0; - final Path path = - Path() - ..moveTo(cx, bottomAnchorY) - ..cubicTo( - cx - bottomControl, - bottomAnchorY, - leftAnchorX, - middleAnchorY + middleControl, - leftAnchorX, - middleAnchorY, - ) - ..cubicTo( - leftAnchorX, - middleAnchorY - middleControl, - cx - topControl, - topAnchorY - topControl, - cx, - topAnchorY, - ) - ..cubicTo( - cx + topControl, - topAnchorY - topControl, - rightAnchorX, - middleAnchorY - middleControl, - rightAnchorX, - middleAnchorY, - ) - ..cubicTo( - rightAnchorX, - middleAnchorY + middleControl, - cx + bottomControl, - bottomAnchorY, - cx, - bottomAnchorY, - ); + final Path path = Path() + ..moveTo(cx, bottomAnchorY) + ..cubicTo( + cx - bottomControl, + bottomAnchorY, + leftAnchorX, + middleAnchorY + middleControl, + leftAnchorX, + middleAnchorY, + ) + ..cubicTo( + leftAnchorX, + middleAnchorY - middleControl, + cx - topControl, + topAnchorY - topControl, + cx, + topAnchorY, + ) + ..cubicTo( + cx + topControl, + topAnchorY - topControl, + rightAnchorX, + middleAnchorY - middleControl, + rightAnchorX, + middleAnchorY, + ) + ..cubicTo( + rightAnchorX, + middleAnchorY + middleControl, + cx + bottomControl, + bottomAnchorY, + cx, + bottomAnchorY, + ); canvas.save(); canvas.clipPath(path); _drawBackground(canvas, size); canvas.restore(); - final Paint paint = - Paint() - ..style = PaintingStyle.stroke - ..color = Colors.white - ..strokeWidth = 3.0; + final Paint paint = Paint() + ..style = PaintingStyle.stroke + ..color = Colors.white + ..strokeWidth = 3.0; canvas.drawPath(path, paint); } diff --git a/packages/diagrams/lib/src/colors.dart b/packages/diagrams/lib/src/colors.dart index 51d1f28b..225af8ae 100644 --- a/packages/diagrams/lib/src/colors.dart +++ b/packages/diagrams/lib/src/colors.dart @@ -33,8 +33,8 @@ class ColorSwatchDiagram extends ColorDiagram { for (final int key in keys) { final Color textColor = ThemeData.estimateBrightnessForColor(swatch[key]!) == Brightness.light - ? Colors.black - : Colors.white; + ? Colors.black + : Colors.white; TextStyle style = TextStyle(color: textColor, fontSize: _kFontSize); String label, shadeLabel; if (swatch[key]!.toARGB32() == swatch.toARGB32()) { diff --git a/packages/diagrams/lib/src/cupertino_colors.dart b/packages/diagrams/lib/src/cupertino_colors.dart index 780b74a0..e6da4296 100644 --- a/packages/diagrams/lib/src/cupertino_colors.dart +++ b/packages/diagrams/lib/src/cupertino_colors.dart @@ -490,10 +490,9 @@ class ColorWidget extends StatelessWidget { Widget build(BuildContext context) { return DefaultTextStyle( style: TextStyle( - color: - color.r > 200 && color.g > 200 && color.b > 200 - ? CupertinoColors.black - : CupertinoColors.white, + color: color.r > 200 && color.g > 200 && color.b > 200 + ? CupertinoColors.black + : CupertinoColors.white, fontSize: 16.0, ), child: Center( diff --git a/packages/diagrams/lib/src/curve.dart b/packages/diagrams/lib/src/curve.dart index 42c07753..891b241c 100644 --- a/packages/diagrams/lib/src/curve.dart +++ b/packages/diagrams/lib/src/curve.dart @@ -50,47 +50,40 @@ class CurveDescription extends CustomPainter { return result; } - static final Paint _axisPaint = - Paint() - ..color = Colors.black45 - ..style = PaintingStyle.stroke - ..strokeWidth = 2.0; - - static final Paint _positionPaint = - Paint() - ..color = Colors.black45 - ..style = PaintingStyle.stroke - ..strokeWidth = 0.0; - - static final Paint _dashPaint = - Paint() - ..color = Colors.black45 - ..style = PaintingStyle.stroke - ..strokeWidth = 0.0; - - static final Paint _graphPaint = - Paint() - ..color = Colors.blue.shade900 - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeWidth = 4.0; - - static final Paint _graphProgressPaint = - Paint() - ..color = Colors.black26 - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.round - ..strokeWidth = 4.0; - - static final Paint _valueMarkerPaint = - Paint() - ..color = const Color(0xffA02020) - ..style = PaintingStyle.fill; - - static final Paint _positionCirclePaint = - Paint() - ..color = Colors.blue.shade900 - ..style = PaintingStyle.fill; + static final Paint _axisPaint = Paint() + ..color = Colors.black45 + ..style = PaintingStyle.stroke + ..strokeWidth = 2.0; + + static final Paint _positionPaint = Paint() + ..color = Colors.black45 + ..style = PaintingStyle.stroke + ..strokeWidth = 0.0; + + static final Paint _dashPaint = Paint() + ..color = Colors.black45 + ..style = PaintingStyle.stroke + ..strokeWidth = 0.0; + + static final Paint _graphPaint = Paint() + ..color = Colors.blue.shade900 + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeWidth = 4.0; + + static final Paint _graphProgressPaint = Paint() + ..color = Colors.black26 + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.round + ..strokeWidth = 4.0; + + static final Paint _valueMarkerPaint = Paint() + ..color = const Color(0xffA02020) + ..style = PaintingStyle.fill; + + static final Paint _positionCirclePaint = Paint() + ..color = Colors.blue.shade900 + ..style = PaintingStyle.fill; @override void paint(Canvas canvas, Size size) { @@ -108,13 +101,12 @@ class CurveDescription extends CustomPainter { size.width - rightMargin, size.height - verticalHeadroom, ); - final Path axes = - Path() - ..moveTo(area.left - unit, area.top) // vertical axis 1.0 tick - ..lineTo(area.left, area.top) // vertical axis - ..lineTo(area.left, area.bottom) // origin - ..lineTo(area.right, area.bottom) // horizontal axis - ..lineTo(area.right, area.bottom + unit); // horizontal axis 1.0 tick + final Path axes = Path() + ..moveTo(area.left - unit, area.top) // vertical axis 1.0 tick + ..lineTo(area.left, area.top) // vertical axis + ..lineTo(area.left, area.bottom) // origin + ..lineTo(area.right, area.bottom) // horizontal axis + ..lineTo(area.right, area.bottom + unit); // horizontal axis 1.0 tick canvas.drawPath(axes, _axisPaint); final Path dashLine = Path(); final double delta = 8.0 / area.width; @@ -162,25 +154,17 @@ class CurveDescription extends CustomPainter { // initial paused state to not include the position indicators. They just // add clutter before the animation is started. if (position != 0.0) { - final Path positionLine = - Path() - ..moveTo(activePoint.dx, area.bottom) - ..lineTo(activePoint.dx, area.top); // vertical pointer from base + final Path positionLine = Path() + ..moveTo(activePoint.dx, area.bottom) + ..lineTo(activePoint.dx, area.top); // vertical pointer from base canvas.drawPath(positionLine, _positionPaint); - final Path valueMarker = - Path() - ..moveTo(area.right + unit, activePoint.dy) - ..lineTo(area.right + unit * 2.0, activePoint.dy - unit) - ..lineTo( - area.right + unit * 2.0 + markerWidth, - activePoint.dy - unit, - ) - ..lineTo( - area.right + unit * 2.0 + markerWidth, - activePoint.dy + unit, - ) - ..lineTo(area.right + unit * 2.0, activePoint.dy + unit) - ..lineTo(area.right + unit, activePoint.dy); + final Path valueMarker = Path() + ..moveTo(area.right + unit, activePoint.dy) + ..lineTo(area.right + unit * 2.0, activePoint.dy - unit) + ..lineTo(area.right + unit * 2.0 + markerWidth, activePoint.dy - unit) + ..lineTo(area.right + unit * 2.0 + markerWidth, activePoint.dy + unit) + ..lineTo(area.right + unit * 2.0, activePoint.dy + unit) + ..lineTo(area.right + unit, activePoint.dy); canvas.drawPath(valueMarker, _valueMarkerPaint); } final Path graph = Path()..moveTo(area.left, area.bottom); diff --git a/packages/diagrams/lib/src/drawer.dart b/packages/diagrams/lib/src/drawer.dart index fbb83e21..db293267 100644 --- a/packages/diagrams/lib/src/drawer.dart +++ b/packages/diagrams/lib/src/drawer.dart @@ -56,59 +56,63 @@ class _DrawerDiagramState extends State initialRoute: '/', onGenerateRoute: (RouteSettings settings) { return PageRouteBuilder( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) { - return Container( - alignment: FractionalOffset.center, - color: Colors.white, - child: Scaffold( - appBar: AppBar( - title: const Text('Drawer Demo'), - automaticallyImplyLeading: false, - leading: Builder( - builder: (BuildContext context) { - return IconButton( - key: _menuKey, - icon: const Icon(Icons.menu), - onPressed: () { - Scaffold.of(context).openDrawer(); + pageBuilder: + ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return Container( + alignment: FractionalOffset.center, + color: Colors.white, + child: Scaffold( + appBar: AppBar( + title: const Text('Drawer Demo'), + automaticallyImplyLeading: false, + leading: Builder( + builder: (BuildContext context) { + return IconButton( + key: _menuKey, + icon: const Icon(Icons.menu), + onPressed: () { + Scaffold.of(context).openDrawer(); + }, + ); }, - ); - }, - ), - ), - drawer: Drawer( - child: ListView( - padding: EdgeInsets.zero, - children: const [ - DrawerHeader( - decoration: BoxDecoration(color: Colors.blue), - child: Text( - 'Drawer Header', - style: TextStyle(color: Colors.white, fontSize: 24), - ), - ), - ListTile( - leading: Icon(Icons.message), - title: Text('Messages'), - ), - ListTile( - leading: Icon(Icons.account_circle), - title: Text('Profile'), ), - ListTile( - leading: Icon(Icons.settings), - title: Text('Settings'), + ), + drawer: Drawer( + child: ListView( + padding: EdgeInsets.zero, + children: const [ + DrawerHeader( + decoration: BoxDecoration(color: Colors.blue), + child: Text( + 'Drawer Header', + style: TextStyle( + color: Colors.white, + fontSize: 24, + ), + ), + ), + ListTile( + leading: Icon(Icons.message), + title: Text('Messages'), + ), + ListTile( + leading: Icon(Icons.account_circle), + title: Text('Profile'), + ), + ListTile( + leading: Icon(Icons.settings), + title: Text('Settings'), + ), + ], ), - ], + ), ), - ), - ), - ); - }, + ); + }, ); }, ), diff --git a/packages/diagrams/lib/src/dropdown_button.dart b/packages/diagrams/lib/src/dropdown_button.dart index 09d1b48e..a74e3274 100644 --- a/packages/diagrams/lib/src/dropdown_button.dart +++ b/packages/diagrams/lib/src/dropdown_button.dart @@ -35,18 +35,14 @@ class DropdownButtonDiagram extends StatelessWidget with DiagramMetadata { underline: Container(height: 2, color: Colors.deepPurpleAccent), value: 'One', onChanged: (String? newValue) {}, - items: - [ - 'One', - 'Two', - 'Free', - 'Four', - ].map>((String value) { + items: ['One', 'Two', 'Free', 'Four'] + .map>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); - }).toList(), + }) + .toList(), ), ), ), diff --git a/packages/diagrams/lib/src/filter_quality.dart b/packages/diagrams/lib/src/filter_quality.dart index 9a58ce89..c6bd4d92 100644 --- a/packages/diagrams/lib/src/filter_quality.dart +++ b/packages/diagrams/lib/src/filter_quality.dart @@ -23,8 +23,8 @@ typedef _Painter = void Function(ui.Canvas canvas); Future _generateSamples() async { _originalImage = await _paint((ui.Canvas canvas) { const FlutterLogoDecoration flutterLogoDecoration = FlutterLogoDecoration(); - final BoxPainter flutterLogoPainter = - flutterLogoDecoration.createBoxPainter(); + final BoxPainter flutterLogoPainter = flutterLogoDecoration + .createBoxPainter(); flutterLogoPainter.paint( canvas, Offset.zero, diff --git a/packages/diagrams/lib/src/font_feature.dart b/packages/diagrams/lib/src/font_feature.dart index 5c394d9e..dbd23599 100644 --- a/packages/diagrams/lib/src/font_feature.dart +++ b/packages/diagrams/lib/src/font_feature.dart @@ -67,15 +67,14 @@ abstract class FontFeatureDiagram extends StatelessWidget minHeight: 0.0, maxHeight: double.infinity, child: Column( - children: - entries - .map( - (T entry) => SizedBox( - height: _margin + textStyle.fontSize! * 1.2 + _gap, - child: buildRow(context, entry), - ), - ) - .toList(), + children: entries + .map( + (T entry) => SizedBox( + height: _margin + textStyle.fontSize! * 1.2 + _gap, + child: buildRow(context, entry), + ), + ) + .toList(), ), ), ), diff --git a/packages/diagrams/lib/src/go_router_push_animation.dart b/packages/diagrams/lib/src/go_router_push_animation.dart index a57a32a8..80fc89c8 100644 --- a/packages/diagrams/lib/src/go_router_push_animation.dart +++ b/packages/diagrams/lib/src/go_router_push_animation.dart @@ -209,16 +209,17 @@ class _MainApp extends StatelessWidget { initialRoute: '/', onGenerateRoute: (RouteSettings settings) { return PageRouteBuilder( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) { - return Scaffold( - appBar: AppBar(title: const Text('Shell1')), - body: _Shell1(), - ); - }, + pageBuilder: + ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return Scaffold( + appBar: AppBar(title: const Text('Shell1')), + body: _Shell1(), + ); + }, ); }, ), @@ -234,61 +235,66 @@ class _Shell1 extends StatelessWidget { initialRoute: '/', onGenerateRoute: (RouteSettings settings) { return PageRouteBuilder( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - TextButton( - key: _pushShell1, - onPressed: () { - _innerNavigator.currentState!.push( - MaterialPageRoute( - builder: (_) { - return const Center(child: Text('shell1 body')); - }, + pageBuilder: + ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return Column( + mainAxisSize: MainAxisSize.min, + children: [ + TextButton( + key: _pushShell1, + onPressed: () { + _innerNavigator.currentState!.push( + MaterialPageRoute( + builder: (_) { + return const Center(child: Text('shell1 body')); + }, + ), + ); + }, + child: const Text('push the same shell route /shell1'), + ), + TextButton( + key: _pushShell2, + onPressed: () { + _outerNavigator.currentState!.push( + MaterialPageRoute( + builder: (_) { + return Scaffold( + appBar: AppBar(title: const Text('shell2')), + body: const Center(child: Text('shell2 body')), + ); + }, + ), + ); + }, + child: const Text( + 'push the different shell route /shell2', ), - ); - }, - child: const Text('push the same shell route /shell1'), - ), - TextButton( - key: _pushShell2, - onPressed: () { - _outerNavigator.currentState!.push( - MaterialPageRoute( - builder: (_) { - return Scaffold( - appBar: AppBar(title: const Text('shell2')), - body: const Center(child: Text('shell2 body')), - ); - }, + ), + TextButton( + key: _pushRegularRoute, + onPressed: () { + _outerNavigator.currentState!.push( + MaterialPageRoute( + builder: (_) { + return const Scaffold( + body: Center(child: Text('Regular Route')), + ); + }, + ), + ); + }, + child: const Text( + 'push the regular route /regular-route', ), - ); - }, - child: const Text('push the different shell route /shell2'), - ), - TextButton( - key: _pushRegularRoute, - onPressed: () { - _outerNavigator.currentState!.push( - MaterialPageRoute( - builder: (_) { - return const Scaffold( - body: Center(child: Text('Regular Route')), - ); - }, - ), - ); - }, - child: const Text('push the regular route /regular-route'), - ), - ], - ); - }, + ), + ], + ); + }, ); }, ); diff --git a/packages/diagrams/lib/src/image.dart b/packages/diagrams/lib/src/image.dart index d6aa8764..73113580 100644 --- a/packages/diagrams/lib/src/image.dart +++ b/packages/diagrams/lib/src/image.dart @@ -119,22 +119,23 @@ class FrameBuilderImageDiagram extends StatelessWidget { Widget build(BuildContext context) { return Image( image: image, - frameBuilder: ( - BuildContext context, - Widget child, - int? frame, - bool wasSynchronouslyLoaded, - ) { - if (wasSynchronouslyLoaded) { - return child; - } - return AnimatedOpacity( - opacity: frame == null ? 0 : 1, - duration: const Duration(seconds: 1), - curve: Curves.easeOut, - child: child, - ); - }, + frameBuilder: + ( + BuildContext context, + Widget child, + int? frame, + bool wasSynchronouslyLoaded, + ) { + if (wasSynchronouslyLoaded) { + return child; + } + return AnimatedOpacity( + opacity: frame == null ? 0 : 1, + duration: const Duration(seconds: 1), + curve: Curves.easeOut, + child: child, + ); + }, ); } } @@ -148,22 +149,23 @@ class LoadingProgressImageDiagram extends StatelessWidget { Widget build(BuildContext context) { return Image( image: image, - loadingBuilder: ( - BuildContext context, - Widget child, - ImageChunkEvent? loadingProgress, - ) { - if (loadingProgress == null) { - return child; - } - return Center( - child: CircularProgressIndicator( - value: - loadingProgress.cumulativeBytesLoaded / - loadingProgress.expectedTotalBytes!, - ), - ); - }, + loadingBuilder: + ( + BuildContext context, + Widget child, + ImageChunkEvent? loadingProgress, + ) { + if (loadingProgress == null) { + return child; + } + return Center( + child: CircularProgressIndicator( + value: + loadingProgress.cumulativeBytesLoaded / + loadingProgress.expectedTotalBytes!, + ), + ); + }, ); } } @@ -227,8 +229,8 @@ class ImageDiagramsStep extends DiagramStep { final String category = 'widgets'; static Future renderFlutterLogo(int width, int height) { - final BoxPainter boxPainter = - const FlutterLogoDecoration().createBoxPainter(); + final BoxPainter boxPainter = const FlutterLogoDecoration() + .createBoxPainter(); final ui.PictureRecorder recorder = ui.PictureRecorder(); boxPainter.paint( ui.Canvas(recorder), @@ -247,18 +249,16 @@ class ImageDiagramsStep extends DiagramStep { image: await renderFlutterLogo(300, 300), shownDuration: const Duration(seconds: 4), loadingDuration: const Duration(milliseconds: 500), - builder: - (BuildContext context, ImageProvider image) => - FrameBuilderImageDiagram(image: image), + builder: (BuildContext context, ImageProvider image) => + FrameBuilderImageDiagram(image: image), ), ImageDiagram( name: 'loading_progress_image', image: await renderFlutterLogo(300, 300), shownDuration: const Duration(seconds: 1), loadingDuration: const Duration(seconds: 2), - builder: - (BuildContext context, ImageProvider image) => - LoadingProgressImageDiagram(image: image), + builder: (BuildContext context, ImageProvider image) => + LoadingProgressImageDiagram(image: image), ), ]; } diff --git a/packages/diagrams/lib/src/implicit_animations.dart b/packages/diagrams/lib/src/implicit_animations.dart index d3517ed0..f3ecdfe5 100644 --- a/packages/diagrams/lib/src/implicit_animations.dart +++ b/packages/diagrams/lib/src/implicit_animations.dart @@ -23,8 +23,9 @@ class AnimatedAlignDiagram extends ImplicitAnimationDiagram { return Center( child: ImplicitAnimationDiagramTapper( child: AnimatedAlign( - alignment: - selected ? Alignment.center : AlignmentDirectional.bottomStart, + alignment: selected + ? Alignment.center + : AlignmentDirectional.bottomStart, duration: _kAnimationDuration, curve: curve, child: const SampleWidget(small: true), @@ -50,8 +51,9 @@ class AnimatedContainerDiagram width: selected ? 200.0 : 100.0, height: selected ? 100.0 : 200.0, color: selected ? Colors.red : Colors.blue, - alignment: - selected ? Alignment.center : AlignmentDirectional.topCenter, + alignment: selected + ? Alignment.center + : AlignmentDirectional.topCenter, duration: _kAnimationDuration, curve: curve, child: const SampleWidget(small: true), @@ -71,13 +73,12 @@ class AnimatedDefaultTextStyleDiagram @override Widget buildImplicitAnimation(BuildContext context, bool selected) { - final TextStyle selectedStyle = Theme.of( - context, - ).textTheme.headlineMedium!.copyWith( - color: Colors.red, - fontSize: 50.0, - fontWeight: FontWeight.w100, - ); + final TextStyle selectedStyle = Theme.of(context).textTheme.headlineMedium! + .copyWith( + color: Colors.red, + fontSize: 50.0, + fontWeight: FontWeight.w100, + ); final TextStyle unselectedStyle = selectedStyle.copyWith( color: Colors.blue, fontSize: 50.0, @@ -134,10 +135,9 @@ class AnimatedPaddingDiagram return Center( child: ImplicitAnimationDiagramTapper( child: AnimatedPadding( - padding: - selected - ? const EdgeInsets.symmetric(vertical: 80.0) - : const EdgeInsets.symmetric(horizontal: 80.0), + padding: selected + ? const EdgeInsets.symmetric(vertical: 80.0) + : const EdgeInsets.symmetric(horizontal: 80.0), duration: _kAnimationDuration, curve: curve, child: Container(color: Colors.blue), diff --git a/packages/diagrams/lib/src/list_view.dart b/packages/diagrams/lib/src/list_view.dart index 6c66b077..0281ee5b 100644 --- a/packages/diagrams/lib/src/list_view.dart +++ b/packages/diagrams/lib/src/list_view.dart @@ -66,8 +66,8 @@ class ListViewDiagram extends StatelessWidget with DiagramMetadata { child: Center(child: Text('Entry ${entries[index]}')), ); }, - separatorBuilder: - (BuildContext context, int index) => const Divider(), + separatorBuilder: (BuildContext context, int index) => + const Divider(), ); break; default: diff --git a/packages/diagrams/lib/src/radio_list_tile.dart b/packages/diagrams/lib/src/radio_list_tile.dart index f8df5601..e1ea2426 100644 --- a/packages/diagrams/lib/src/radio_list_tile.dart +++ b/packages/diagrams/lib/src/radio_list_tile.dart @@ -47,11 +47,10 @@ class LinkedLabelRadio extends StatelessWidget { color: Colors.blueAccent, decoration: TextDecoration.underline, ), - recognizer: - TapGestureRecognizer() - ..onTap = () { - print('Label has been tapped.'); - }, + recognizer: TapGestureRecognizer() + ..onTap = () { + print('Label has been tapped.'); + }, ), ), ], diff --git a/packages/diagrams/lib/src/simple_dialog.dart b/packages/diagrams/lib/src/simple_dialog.dart index e754b5e7..34d11763 100644 --- a/packages/diagrams/lib/src/simple_dialog.dart +++ b/packages/diagrams/lib/src/simple_dialog.dart @@ -78,26 +78,27 @@ class _SimpleDialogDiagramState extends State initialRoute: '/', onGenerateRoute: (RouteSettings settings) { return PageRouteBuilder( - pageBuilder: ( - BuildContext context, - Animation animation, - Animation secondaryAnimation, - ) { - return Scaffold( - appBar: AppBar(title: const Text('SimpleDialog Demo')), - body: Center( - child: Builder( - builder: (BuildContext context) { - return OutlinedButton( - key: _openDialogKey, - child: const Text('Show Options'), - onPressed: () => _askedToLead(context), - ); - }, - ), - ), - ); - }, + pageBuilder: + ( + BuildContext context, + Animation animation, + Animation secondaryAnimation, + ) { + return Scaffold( + appBar: AppBar(title: const Text('SimpleDialog Demo')), + body: Center( + child: Builder( + builder: (BuildContext context) { + return OutlinedButton( + key: _openDialogKey, + child: const Text('Show Options'), + onPressed: () => _askedToLead(context), + ); + }, + ), + ), + ); + }, ); }, ), @@ -105,32 +106,31 @@ class _SimpleDialogDiagramState extends State } Future _askedToLead(BuildContext context) async { - final Department result = - (await showDialog( - context: context, - useRootNavigator: false, - builder: (BuildContext context) { - return SimpleDialog( - title: const Text('Select assignment'), - children: [ - SimpleDialogOption( - key: _treasuryKey, - onPressed: () { - Navigator.pop(context, Department.treasury); - }, - child: const Text('Treasury department'), - ), - SimpleDialogOption( - key: _stateKey, - onPressed: () { - Navigator.pop(context, Department.state); - }, - child: const Text('State department'), - ), - ], - ); - }, - ))!; + final Department result = (await showDialog( + context: context, + useRootNavigator: false, + builder: (BuildContext context) { + return SimpleDialog( + title: const Text('Select assignment'), + children: [ + SimpleDialogOption( + key: _treasuryKey, + onPressed: () { + Navigator.pop(context, Department.treasury); + }, + child: const Text('Treasury department'), + ), + SimpleDialogOption( + key: _stateKey, + onPressed: () { + Navigator.pop(context, Department.state); + }, + child: const Text('State department'), + ), + ], + ); + }, + ))!; switch (result) { case Department.treasury: diff --git a/packages/diagrams/lib/src/stroke_cap.dart b/packages/diagrams/lib/src/stroke_cap.dart index 8b98bbf5..b4e89529 100644 --- a/packages/diagrams/lib/src/stroke_cap.dart +++ b/packages/diagrams/lib/src/stroke_cap.dart @@ -62,24 +62,21 @@ class StrokeCapDescription extends CustomPainter { final Offset start = Offset(0.0, center.dy); final Offset middle = Offset(size.width / 2.0, center.dy); - final Paint startPaint = - Paint() - ..color = Colors.grey - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.square - ..strokeWidth = 20.0; - final Paint linePaint = - Paint() - ..color = Colors.grey - ..style = PaintingStyle.stroke - ..strokeCap = cap - ..strokeWidth = 20.0; - final Paint endPaint = - Paint() - ..color = Colors.deepPurpleAccent - ..style = PaintingStyle.stroke - ..strokeCap = cap - ..strokeWidth = 20.0; + final Paint startPaint = Paint() + ..color = Colors.grey + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.square + ..strokeWidth = 20.0; + final Paint linePaint = Paint() + ..color = Colors.grey + ..style = PaintingStyle.stroke + ..strokeCap = cap + ..strokeWidth = 20.0; + final Paint endPaint = Paint() + ..color = Colors.deepPurpleAccent + ..style = PaintingStyle.stroke + ..strokeCap = cap + ..strokeWidth = 20.0; Path line = Path() // Line diff --git a/packages/diagrams/lib/src/stroke_join.dart b/packages/diagrams/lib/src/stroke_join.dart index 8747d452..ac5b55df 100644 --- a/packages/diagrams/lib/src/stroke_join.dart +++ b/packages/diagrams/lib/src/stroke_join.dart @@ -86,22 +86,20 @@ class StrokeJoinDescription extends CustomPainter { final Offset shortEnd = Offset(20.0 * math.cos(radians), 20.0 * math.sin(radians)) + center; - final Paint linePaint = - Paint() - ..color = Colors.grey - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.butt - ..strokeJoin = join - ..strokeMiterLimit = strokeMiterLimit - ..strokeWidth = 20.0; - final Paint centerPaint = - Paint() - ..color = Colors.deepPurpleAccent - ..style = PaintingStyle.stroke - ..strokeCap = StrokeCap.butt - ..strokeJoin = join - ..strokeMiterLimit = strokeMiterLimit - ..strokeWidth = 20.0; + final Paint linePaint = Paint() + ..color = Colors.grey + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.butt + ..strokeJoin = join + ..strokeMiterLimit = strokeMiterLimit + ..strokeWidth = 20.0; + final Paint centerPaint = Paint() + ..color = Colors.deepPurpleAccent + ..style = PaintingStyle.stroke + ..strokeCap = StrokeCap.butt + ..strokeJoin = join + ..strokeMiterLimit = strokeMiterLimit + ..strokeWidth = 20.0; Path line = Path() // Line @@ -172,14 +170,15 @@ class StrokeJoinPainterState @override void initState() { super.initState(); - controller = AnimationController( - duration: widget.duration, - vsync: this, - lowerBound: widget.startAngle, - upperBound: widget.endAngle, - )..addListener(() { - setState(() {}); - }); + controller = + AnimationController( + duration: widget.duration, + vsync: this, + lowerBound: widget.startAngle, + upperBound: widget.endAngle, + )..addListener(() { + setState(() {}); + }); controller.forward(); } diff --git a/packages/diagrams/lib/src/switch_list_tile.dart b/packages/diagrams/lib/src/switch_list_tile.dart index a98cc3c7..89703aab 100644 --- a/packages/diagrams/lib/src/switch_list_tile.dart +++ b/packages/diagrams/lib/src/switch_list_tile.dart @@ -37,11 +37,10 @@ class LinkedLabelSwitch extends StatelessWidget { color: Colors.blueAccent, decoration: TextDecoration.underline, ), - recognizer: - TapGestureRecognizer() - ..onTap = () { - print('Label has been tapped.'); - }, + recognizer: TapGestureRecognizer() + ..onTap = () { + print('Label has been tapped.'); + }, ), ), ), diff --git a/packages/diagrams/lib/src/tabs.dart b/packages/diagrams/lib/src/tabs.dart index 0f689b63..16bfcbfa 100644 --- a/packages/diagrams/lib/src/tabs.dart +++ b/packages/diagrams/lib/src/tabs.dart @@ -86,16 +86,15 @@ class TabsDiagramState extends State ), body: TabBarView( controller: _tabController, - children: - myTabs.map((Tab tab) { - final String label = tab.text!.toLowerCase(); - return Center( - child: Text( - 'This is the $label tab', - style: const TextStyle(fontSize: 36), - ), - ); - }).toList(), + children: myTabs.map((Tab tab) { + final String label = tab.text!.toLowerCase(); + return Center( + child: Text( + 'This is the $label tab', + style: const TextStyle(fontSize: 36), + ), + ); + }).toList(), ), ), ), diff --git a/packages/diagrams/lib/src/text.dart b/packages/diagrams/lib/src/text.dart index 5685d2d9..11761eac 100644 --- a/packages/diagrams/lib/src/text.dart +++ b/packages/diagrams/lib/src/text.dart @@ -88,11 +88,10 @@ class TextDiagram extends StatelessWidget with DiagramMetadata { 'Greetings, planet!', style: TextStyle( fontSize: 40, - foreground: - Paint() - ..style = PaintingStyle.stroke - ..strokeWidth = 6 - ..color = Colors.blue[700]!, + foreground: Paint() + ..style = PaintingStyle.stroke + ..strokeWidth = 6 + ..color = Colors.blue[700]!, ), ), // Solid text as fill. @@ -114,13 +113,12 @@ class TextDiagram extends StatelessWidget with DiagramMetadata { 'Greetings, planet!', style: TextStyle( fontSize: 40, - foreground: - Paint() - ..shader = ui.Gradient.linear( - const Offset(0, 20), - const Offset(150, 20), - [Colors.red, Colors.yellow], - ), + foreground: Paint() + ..shader = ui.Gradient.linear( + const Offset(0, 20), + const Offset(150, 20), + [Colors.red, Colors.yellow], + ), ), ), ], @@ -820,17 +818,16 @@ class RenderTextHeightBreakdown extends RenderBox // Paint the background color. canvas.drawRect(offset & size, paint); - final Offset lineBoxOrigin = - paintHeightIndicator - // Left-align the height caption. Ideally this should also be centered. - ? Offset( - heightCaptionTextPainter.width + - fontMetricsLabelPadding.dx - - heightCaptionBracketMinX, - 0, - ) + - offset - : (size - _textPainter.size as Offset) / 2 + offset; + final Offset lineBoxOrigin = paintHeightIndicator + // Left-align the height caption. Ideally this should also be centered. + ? Offset( + heightCaptionTextPainter.width + + fontMetricsLabelPadding.dx - + heightCaptionBracketMinX, + 0, + ) + + offset + : (size - _textPainter.size as Offset) / 2 + offset; assert(lineBoxOrigin.dy == offset.dy); // Paint the text. Layout is done in performLayout. diff --git a/packages/diagrams/lib/src/utils.dart b/packages/diagrams/lib/src/utils.dart index 74589beb..902cce1a 100644 --- a/packages/diagrams/lib/src/utils.dart +++ b/packages/diagrams/lib/src/utils.dart @@ -280,10 +280,9 @@ mixin LockstepStateMixin on State // Avoid concurrent modification of _completers by getting the durations // all at once before removing them. - final List ready = - _completers.keys - .where((Duration duration) => elapsed >= duration) - .toList(); + final List ready = _completers.keys + .where((Duration duration) => elapsed >= duration) + .toList(); for (final Duration duration in ready) { _completers[duration]!.complete();