diff --git a/animations/analysis_options.yaml b/animations/analysis_options.yaml index be4f27226..b1d37f49e 100644 --- a/animations/analysis_options.yaml +++ b/animations/analysis_options.yaml @@ -12,10 +12,10 @@ linter: cancel_subscriptions: true close_sinks: true directives_ordering: true + # Required because of the numbered sources in lib/src/basics file_names: false package_api_docs: true package_prefixed_library_names: true test_types_in_equals: true throw_in_finally: true unnecessary_statements: true - use_key_in_widget_constructors: false diff --git a/animations/lib/main.dart b/animations/lib/main.dart index 6dccb7485..65a61e9e4 100644 --- a/animations/lib/main.dart +++ b/animations/lib/main.dart @@ -24,7 +24,7 @@ import 'src/misc/hero_animation.dart'; import 'src/misc/physics_card_drag.dart'; import 'src/misc/repeating_animation.dart'; -void main() => runApp(AnimationSamples()); +void main() => runApp(const AnimationSamples()); class Demo { final String name; @@ -42,42 +42,42 @@ final basicDemos = [ Demo( name: 'AnimatedContainer', route: AnimatedContainerDemo.routeName, - builder: (context) => AnimatedContainerDemo()), + builder: (context) => const AnimatedContainerDemo()), Demo( name: 'PageRouteBuilder', route: PageRouteBuilderDemo.routeName, - builder: (context) => PageRouteBuilderDemo()), + builder: (context) => const PageRouteBuilderDemo()), Demo( name: 'Animation Controller', route: AnimationControllerDemo.routeName, - builder: (context) => AnimationControllerDemo()), + builder: (context) => const AnimationControllerDemo()), Demo( name: 'Tweens', route: TweenDemo.routeName, - builder: (context) => TweenDemo()), + builder: (context) => const TweenDemo()), Demo( name: 'AnimatedBuilder', route: AnimatedBuilderDemo.routeName, - builder: (context) => AnimatedBuilderDemo()), + builder: (context) => const AnimatedBuilderDemo()), Demo( name: 'Custom Tween', route: CustomTweenDemo.routeName, - builder: (context) => CustomTweenDemo()), + builder: (context) => const CustomTweenDemo()), Demo( name: 'Tween Sequences', route: TweenSequenceDemo.routeName, - builder: (context) => TweenSequenceDemo()), + builder: (context) => const TweenSequenceDemo()), Demo( name: 'Fade Transition', route: FadeTransitionDemo.routeName, - builder: (context) => FadeTransitionDemo()), + builder: (context) => const FadeTransitionDemo()), ]; final miscDemos = [ Demo( name: 'Expandable Card', route: ExpandCardDemo.routeName, - builder: (context) => ExpandCardDemo()), + builder: (context) => const ExpandCardDemo()), Demo( name: 'Carousel', route: CarouselDemo.routeName, @@ -85,39 +85,39 @@ final miscDemos = [ Demo( name: 'Focus Image', route: FocusImageDemo.routeName, - builder: (context) => FocusImageDemo()), + builder: (context) => const FocusImageDemo()), Demo( name: 'Card Swipe', route: CardSwipeDemo.routeName, - builder: (context) => CardSwipeDemo()), + builder: (context) => const CardSwipeDemo()), Demo( name: 'Repeating Animation', route: RepeatingAnimationDemo.routeName, - builder: (context) => RepeatingAnimationDemo()), + builder: (context) => const RepeatingAnimationDemo()), Demo( name: 'Spring Physics', route: PhysicsCardDragDemo.routeName, - builder: (context) => PhysicsCardDragDemo()), + builder: (context) => const PhysicsCardDragDemo()), Demo( name: 'AnimatedList', route: AnimatedListDemo.routeName, - builder: (context) => AnimatedListDemo()), + builder: (context) => const AnimatedListDemo()), Demo( name: 'AnimatedPositioned', route: AnimatedPositionedDemo.routeName, - builder: (context) => AnimatedPositionedDemo()), + builder: (context) => const AnimatedPositionedDemo()), Demo( name: 'AnimatedSwitcher', route: AnimatedSwitcherDemo.routeName, - builder: (context) => AnimatedSwitcherDemo()), + builder: (context) => const AnimatedSwitcherDemo()), Demo( name: 'Hero Animation', route: HeroAnimationDemo.routeName, - builder: (context) => HeroAnimationDemo()), + builder: (context) => const HeroAnimationDemo()), Demo( name: 'Curved Animation', route: CurvedAnimationDemo.routeName, - builder: (context) => CurvedAnimationDemo()), + builder: (context) => const CurvedAnimationDemo()), ]; final basicDemoRoutes = @@ -132,6 +132,8 @@ final allRoutes = { }; class AnimationSamples extends StatelessWidget { + const AnimationSamples({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return MaterialApp( @@ -140,12 +142,14 @@ class AnimationSamples extends StatelessWidget { primarySwatch: Colors.deepPurple, ), routes: allRoutes, - home: HomePage(), + home: const HomePage(), ); } } class HomePage extends StatelessWidget { + const HomePage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { final headerStyle = Theme.of(context).textTheme.headline6; @@ -156,9 +160,9 @@ class HomePage extends StatelessWidget { body: ListView( children: [ ListTile(title: Text('Basics', style: headerStyle)), - ...basicDemos.map((d) => DemoTile(d)), + ...basicDemos.map((d) => DemoTile(demo: d)), ListTile(title: Text('Misc', style: headerStyle)), - ...miscDemos.map((d) => DemoTile(d)), + ...miscDemos.map((d) => DemoTile(demo: d)), ], ), ); @@ -168,7 +172,7 @@ class HomePage extends StatelessWidget { class DemoTile extends StatelessWidget { final Demo demo; - const DemoTile(this.demo); + const DemoTile({required this.demo, Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/animations/lib/src/basics/01_animated_container.dart b/animations/lib/src/basics/01_animated_container.dart index 64ef59798..2b6d47fd6 100644 --- a/animations/lib/src/basics/01_animated_container.dart +++ b/animations/lib/src/basics/01_animated_container.dart @@ -11,6 +11,7 @@ double generateMargin() => Random().nextDouble() * 64; Color generateColor() => Color(0xFFFFFFFF & Random().nextInt(0xFFFFFFFF)); class AnimatedContainerDemo extends StatefulWidget { + const AnimatedContainerDemo({Key? key}) : super(key: key); static String routeName = '/basics/01_animated_container'; @override diff --git a/animations/lib/src/basics/02_page_route_builder.dart b/animations/lib/src/basics/02_page_route_builder.dart index 9205fc232..b44171405 100644 --- a/animations/lib/src/basics/02_page_route_builder.dart +++ b/animations/lib/src/basics/02_page_route_builder.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class PageRouteBuilderDemo extends StatelessWidget { + const PageRouteBuilderDemo({Key? key}) : super(key: key); static const String routeName = '/basics/page_route_builder'; @override diff --git a/animations/lib/src/basics/03_animation_controller.dart b/animations/lib/src/basics/03_animation_controller.dart index bcc50aa03..9d05d4477 100644 --- a/animations/lib/src/basics/03_animation_controller.dart +++ b/animations/lib/src/basics/03_animation_controller.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class AnimationControllerDemo extends StatefulWidget { + const AnimationControllerDemo({Key? key}) : super(key: key); static const String routeName = '/basics/animation_controller'; @override diff --git a/animations/lib/src/basics/04_tweens.dart b/animations/lib/src/basics/04_tweens.dart index 4d73e94f0..acf9a07ea 100644 --- a/animations/lib/src/basics/04_tweens.dart +++ b/animations/lib/src/basics/04_tweens.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class TweenDemo extends StatefulWidget { + const TweenDemo({Key? key}) : super(key: key); static const String routeName = '/basics/tweens'; @override diff --git a/animations/lib/src/basics/05_animated_builder.dart b/animations/lib/src/basics/05_animated_builder.dart index 6a3c858bc..78dca83c6 100644 --- a/animations/lib/src/basics/05_animated_builder.dart +++ b/animations/lib/src/basics/05_animated_builder.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class AnimatedBuilderDemo extends StatefulWidget { + const AnimatedBuilderDemo({Key? key}) : super(key: key); static const String routeName = '/basics/animated_builder'; @override diff --git a/animations/lib/src/basics/06_custom_tween.dart b/animations/lib/src/basics/06_custom_tween.dart index 311696912..bc1ac567b 100644 --- a/animations/lib/src/basics/06_custom_tween.dart +++ b/animations/lib/src/basics/06_custom_tween.dart @@ -16,6 +16,7 @@ class TypewriterTween extends Tween { } class CustomTweenDemo extends StatefulWidget { + const CustomTweenDemo({Key? key}) : super(key: key); static const String routeName = '/basics/custom_tweens'; @override diff --git a/animations/lib/src/basics/07_tween_sequence.dart b/animations/lib/src/basics/07_tween_sequence.dart index 9f59b8534..97bdc49ea 100644 --- a/animations/lib/src/basics/07_tween_sequence.dart +++ b/animations/lib/src/basics/07_tween_sequence.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class TweenSequenceDemo extends StatefulWidget { + const TweenSequenceDemo({Key? key}) : super(key: key); static const String routeName = '/basics/chaining_tweens'; @override diff --git a/animations/lib/src/basics/08_fade_transition.dart b/animations/lib/src/basics/08_fade_transition.dart index e7da42d59..fdf6b9691 100644 --- a/animations/lib/src/basics/08_fade_transition.dart +++ b/animations/lib/src/basics/08_fade_transition.dart @@ -7,6 +7,7 @@ import 'package:flutter/material.dart'; // Refer to the AnimatedWidget docs here - https://api.flutter.dev/flutter/widgets/AnimatedWidget-class.html // for examples of other common animated widgets. class FadeTransitionDemo extends StatefulWidget { + const FadeTransitionDemo({Key? key}) : super(key: key); static const String routeName = '/basics/fade_transition'; @override diff --git a/animations/lib/src/misc/animated_list.dart b/animations/lib/src/misc/animated_list.dart index a8c8d46ee..095f48d5c 100644 --- a/animations/lib/src/misc/animated_list.dart +++ b/animations/lib/src/misc/animated_list.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; class AnimatedListDemo extends StatefulWidget { + const AnimatedListDemo({Key? key}) : super(key: key); static String routeName = '/misc/animated_list'; @override diff --git a/animations/lib/src/misc/animated_positioned.dart b/animations/lib/src/misc/animated_positioned.dart index c746f696e..8dbf7c0c9 100644 --- a/animations/lib/src/misc/animated_positioned.dart +++ b/animations/lib/src/misc/animated_positioned.dart @@ -7,6 +7,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; class AnimatedPositionedDemo extends StatefulWidget { + const AnimatedPositionedDemo({Key? key}) : super(key: key); static String routeName = '/basics/09_animated_positioned'; @override diff --git a/animations/lib/src/misc/animated_switcher.dart b/animations/lib/src/misc/animated_switcher.dart index 15d5de0c1..aaa4269f3 100644 --- a/animations/lib/src/misc/animated_switcher.dart +++ b/animations/lib/src/misc/animated_switcher.dart @@ -23,6 +23,7 @@ Widget generateContainer(int keyCount) => Container( ); class AnimatedSwitcherDemo extends StatefulWidget { + const AnimatedSwitcherDemo({Key? key}) : super(key: key); static String routeName = '/basics/10_animated_switcher'; @override diff --git a/animations/lib/src/misc/card_swipe.dart b/animations/lib/src/misc/card_swipe.dart index 872583c6c..c60474dd1 100644 --- a/animations/lib/src/misc/card_swipe.dart +++ b/animations/lib/src/misc/card_swipe.dart @@ -8,6 +8,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/physics.dart'; class CardSwipeDemo extends StatefulWidget { + const CardSwipeDemo({Key? key}) : super(key: key); static String routeName = '/misc/card_swipe'; @override @@ -78,7 +79,7 @@ class _CardSwipeDemoState extends State { class Card extends StatelessWidget { final String imageAssetName; - const Card(this.imageAssetName); + const Card({required this.imageAssetName, Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -101,10 +102,9 @@ class SwipeableCard extends StatefulWidget { final String imageAssetName; final VoidCallback onSwiped; - const SwipeableCard({ - required this.onSwiped, - required this.imageAssetName, - }); + const SwipeableCard( + {required this.onSwiped, required this.imageAssetName, Key? key}) + : super(key: key); @override _SwipeableCardState createState() => _SwipeableCardState(); @@ -135,7 +135,7 @@ class _SwipeableCardState extends State onHorizontalDragStart: _dragStart, onHorizontalDragUpdate: _dragUpdate, onHorizontalDragEnd: _dragEnd, - child: Card(widget.imageAssetName), + child: Card(imageAssetName: widget.imageAssetName), ), ); } diff --git a/animations/lib/src/misc/carousel.dart b/animations/lib/src/misc/carousel.dart index 88e94170a..d894bce35 100644 --- a/animations/lib/src/misc/carousel.dart +++ b/animations/lib/src/misc/carousel.dart @@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; class CarouselDemo extends StatelessWidget { + CarouselDemo({Key? key}) : super(key: key); static String routeName = '/misc/carousel'; static const List fileNames = [ diff --git a/animations/lib/src/misc/curved_animation.dart b/animations/lib/src/misc/curved_animation.dart index cb405e93d..4f0c7621d 100644 --- a/animations/lib/src/misc/curved_animation.dart +++ b/animations/lib/src/misc/curved_animation.dart @@ -6,6 +6,7 @@ import 'dart:math' as math; import 'package:flutter/material.dart'; class CurvedAnimationDemo extends StatefulWidget { + const CurvedAnimationDemo({Key? key}) : super(key: key); static const String routeName = '/misc/curved_animation'; @override diff --git a/animations/lib/src/misc/expand_card.dart b/animations/lib/src/misc/expand_card.dart index 1190cc23a..6867c5eee 100644 --- a/animations/lib/src/misc/expand_card.dart +++ b/animations/lib/src/misc/expand_card.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class ExpandCardDemo extends StatelessWidget { + const ExpandCardDemo({Key? key}) : super(key: key); static const String routeName = '/misc/expand_card'; @override @@ -13,7 +14,7 @@ class ExpandCardDemo extends StatelessWidget { appBar: AppBar( title: const Text('Expandable Card'), ), - body: Center( + body: const Center( child: ExpandCard(), ), ); @@ -21,6 +22,7 @@ class ExpandCardDemo extends StatelessWidget { } class ExpandCard extends StatefulWidget { + const ExpandCard({Key? key}) : super(key: key); @override _ExpandCardState createState() => _ExpandCardState(); } diff --git a/animations/lib/src/misc/focus_image.dart b/animations/lib/src/misc/focus_image.dart index a1e11227f..f89d12c65 100644 --- a/animations/lib/src/misc/focus_image.dart +++ b/animations/lib/src/misc/focus_image.dart @@ -5,18 +5,20 @@ import 'package:flutter/material.dart'; class FocusImageDemo extends StatelessWidget { + const FocusImageDemo({Key? key}) : super(key: key); static String routeName = '/misc/focus_image'; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Focus Image')), - body: Grid(), + body: const Grid(), ); } } class Grid extends StatelessWidget { + const Grid({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( @@ -26,8 +28,12 @@ class Grid extends StatelessWidget { const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), itemBuilder: (context, index) { return (index >= 20) - ? const SmallCard('assets/eat_cape_town_sm.jpg') - : const SmallCard('assets/eat_new_orleans_sm.jpg'); + ? const SmallCard( + imageAssetName: 'assets/eat_cape_town_sm.jpg', + ) + : const SmallCard( + imageAssetName: 'assets/eat_new_orleans_sm.jpg', + ); }, ), ); @@ -66,10 +72,9 @@ Tween _createTween(BuildContext context) { } class SmallCard extends StatelessWidget { + const SmallCard({required this.imageAssetName, Key? key}) : super(key: key); final String imageAssetName; - const SmallCard(this.imageAssetName); - @override Widget build(BuildContext context) { return Card( diff --git a/animations/lib/src/misc/hero_animation.dart b/animations/lib/src/misc/hero_animation.dart index 174beeac8..0544385ca 100644 --- a/animations/lib/src/misc/hero_animation.dart +++ b/animations/lib/src/misc/hero_animation.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class HeroAnimationDemo extends StatelessWidget { + const HeroAnimationDemo({Key? key}) : super(key: key); static const String routeName = '/misc/hero_animation'; @override @@ -21,14 +22,16 @@ class HeroAnimationDemo extends StatelessWidget { color: Colors.grey.shade300, ), ), - onTap: () => Navigator.of(context) - .push(MaterialPageRoute(builder: (context) => HeroPage())), + onTap: () => Navigator.of(context).push( + MaterialPageRoute(builder: (context) => const HeroPage())), ), ); } } class HeroPage extends StatelessWidget { + const HeroPage({Key? key}) : super(key: key); + @override Widget build(BuildContext context) { return Scaffold( diff --git a/animations/lib/src/misc/physics_card_drag.dart b/animations/lib/src/misc/physics_card_drag.dart index 51da6e76b..3399274a7 100644 --- a/animations/lib/src/misc/physics_card_drag.dart +++ b/animations/lib/src/misc/physics_card_drag.dart @@ -6,6 +6,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/physics.dart'; class PhysicsCardDragDemo extends StatelessWidget { + const PhysicsCardDragDemo({Key? key}) : super(key: key); static const String routeName = '/misc/physics_card'; @override @@ -26,8 +27,8 @@ class PhysicsCardDragDemo extends StatelessWidget { /// A draggable card that moves back to [Alignment.center] when it's /// released. class DraggableCard extends StatefulWidget { + const DraggableCard({required this.child, Key? key}) : super(key: key); final Widget child; - const DraggableCard({required this.child}); @override _DraggableCardState createState() => _DraggableCardState(); diff --git a/animations/lib/src/misc/repeating_animation.dart b/animations/lib/src/misc/repeating_animation.dart index 6767d1239..a98bfe479 100644 --- a/animations/lib/src/misc/repeating_animation.dart +++ b/animations/lib/src/misc/repeating_animation.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; class RepeatingAnimationDemo extends StatefulWidget { + const RepeatingAnimationDemo({Key? key}) : super(key: key); static String routeName = '/misc/repeating_animation'; @override diff --git a/animations/test/misc/animated_list_test.dart b/animations/test/misc/animated_list_test.dart index e810ddab4..6f817812f 100644 --- a/animations/test/misc/animated_list_test.dart +++ b/animations/test/misc/animated_list_test.dart @@ -6,7 +6,7 @@ import 'package:animations/src/misc/animated_list.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createAnimatedListDemoScreen() => MaterialApp( +Widget createAnimatedListDemoScreen() => const MaterialApp( home: AnimatedListDemo(), ); diff --git a/animations/test/misc/animated_positioned_test.dart b/animations/test/misc/animated_positioned_test.dart index 39d3e6d5a..3de643779 100644 --- a/animations/test/misc/animated_positioned_test.dart +++ b/animations/test/misc/animated_positioned_test.dart @@ -6,7 +6,7 @@ import 'package:animations/src/misc/animated_positioned.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createAnimatedPositionedDemoScreen() => MaterialApp( +Widget createAnimatedPositionedDemoScreen() => const MaterialApp( home: AnimatedPositionedDemo(), ); diff --git a/animations/test/misc/card_swipe_test.dart b/animations/test/misc/card_swipe_test.dart index f381f4cff..3637b94fd 100644 --- a/animations/test/misc/card_swipe_test.dart +++ b/animations/test/misc/card_swipe_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createCardSwipeScreen() => MaterialApp( +Widget createCardSwipeScreen() => const MaterialApp( home: CardSwipeDemo(), ); diff --git a/animations/test/misc/expand_card_test.dart b/animations/test/misc/expand_card_test.dart index ee033b908..1fb147bf2 100644 --- a/animations/test/misc/expand_card_test.dart +++ b/animations/test/misc/expand_card_test.dart @@ -6,7 +6,7 @@ import 'package:animations/src/misc/expand_card.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createExpandCardScreen() => MaterialApp( +Widget createExpandCardScreen() => const MaterialApp( home: ExpandCardDemo(), ); diff --git a/animations/test/misc/focus_image_test.dart b/animations/test/misc/focus_image_test.dart index bae4cbfc2..e57787a08 100644 --- a/animations/test/misc/focus_image_test.dart +++ b/animations/test/misc/focus_image_test.dart @@ -6,7 +6,7 @@ import 'package:animations/src/misc/focus_image.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createFocusImageScreen() => MaterialApp( +Widget createFocusImageScreen() => const MaterialApp( home: FocusImageDemo(), ); diff --git a/animations/test/misc/hero_animation_test.dart b/animations/test/misc/hero_animation_test.dart index 866c2e9e3..ce9480bb1 100644 --- a/animations/test/misc/hero_animation_test.dart +++ b/animations/test/misc/hero_animation_test.dart @@ -6,7 +6,7 @@ import 'package:animations/src/misc/hero_animation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -Widget createHeroAnimationDemoScreen() => MaterialApp( +Widget createHeroAnimationDemoScreen() => const MaterialApp( home: HeroAnimationDemo(), ); diff --git a/animations/test/widget_test.dart b/animations/test/widget_test.dart index 60fbd38d4..be5639df2 100644 --- a/animations/test/widget_test.dart +++ b/animations/test/widget_test.dart @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('smoke test', (tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(AnimationSamples()); + await tester.pumpWidget(const AnimationSamples()); // Verify that a least one of our demos is showing up in the list expect(find.text('AnimatedContainer'), findsOneWidget);