diff --git a/animations/ios/Runner.xcodeproj/project.pbxproj b/animations/ios/Runner.xcodeproj/project.pbxproj index b7ef4c45fe8..1b8fd3034da 100644 --- a/animations/ios/Runner.xcodeproj/project.pbxproj +++ b/animations/ios/Runner.xcodeproj/project.pbxproj @@ -9,11 +9,7 @@ /* Begin PBXBuildFile section */ 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; @@ -26,8 +22,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, - 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, ); name = "Embed Frameworks"; runOnlyForDeploymentPostprocessing = 0; @@ -38,13 +32,11 @@ 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; - 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; - 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; @@ -57,8 +49,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, - 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -68,9 +58,7 @@ 9740EEB11CF90186004384FC /* Flutter */ = { isa = PBXGroup; children = ( - 3B80C3931E831B6300D905FE /* App.framework */, 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, - 9740EEBA1CF902C7004384FC /* Flutter.framework */, 9740EEB21CF90195004384FC /* Debug.xcconfig */, 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 9740EEB31CF90195004384FC /* Generated.xcconfig */, @@ -201,7 +189,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; }; 9740EEB61CF901F6004384FC /* Run Script */ = { isa = PBXShellScriptBuildPhase; @@ -253,7 +241,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -330,7 +317,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -386,7 +372,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; diff --git a/animations/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/animations/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16ed0..919434a6254 100644 --- a/animations/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/animations/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/animations/lib/main.dart b/animations/lib/main.dart index eee14aa142c..b74b957bf3b 100644 --- a/animations/lib/main.dart +++ b/animations/lib/main.dart @@ -31,7 +31,11 @@ class Demo { final String route; final WidgetBuilder builder; - const Demo({this.name, this.route, this.builder}); + const Demo({ + required this.name, + required this.route, + required this.builder, + }); } final basicDemos = [ diff --git a/animations/lib/src/basics/01_animated_container.dart b/animations/lib/src/basics/01_animated_container.dart index 9b84fd4e6d4..e009f43ff84 100644 --- a/animations/lib/src/basics/01_animated_container.dart +++ b/animations/lib/src/basics/01_animated_container.dart @@ -18,9 +18,9 @@ class AnimatedContainerDemo extends StatefulWidget { } class _AnimatedContainerDemoState extends State { - Color color; - double borderRadius; - double margin; + late Color color; + late double borderRadius; + late double margin; @override void initState() { diff --git a/animations/lib/src/basics/03_animation_controller.dart b/animations/lib/src/basics/03_animation_controller.dart index a9d46f35bbb..3a88bfebe49 100644 --- a/animations/lib/src/basics/03_animation_controller.dart +++ b/animations/lib/src/basics/03_animation_controller.dart @@ -20,7 +20,7 @@ class _AnimationControllerDemoState extends State // Widget is not visible. static const Duration _duration = Duration(seconds: 1); - AnimationController controller; + late final AnimationController controller; @override void initState() { diff --git a/animations/lib/src/basics/04_tweens.dart b/animations/lib/src/basics/04_tweens.dart index 9ed9822aaa6..1984f8b0ca1 100644 --- a/animations/lib/src/basics/04_tweens.dart +++ b/animations/lib/src/basics/04_tweens.dart @@ -15,8 +15,8 @@ class _TweenDemoState extends State with SingleTickerProviderStateMixin { static const Duration _duration = Duration(seconds: 1); static const double accountBalance = 1000000; - AnimationController controller; - Animation animation; + late final AnimationController controller; + late final Animation animation; @override void initState() { diff --git a/animations/lib/src/basics/05_animated_builder.dart b/animations/lib/src/basics/05_animated_builder.dart index 70919886c92..10d7f0dbe05 100644 --- a/animations/lib/src/basics/05_animated_builder.dart +++ b/animations/lib/src/basics/05_animated_builder.dart @@ -16,8 +16,8 @@ class _AnimatedBuilderDemoState extends State static const Color beginColor = Colors.deepPurple; static const Color endColor = Colors.deepOrange; Duration duration = Duration(milliseconds: 800); - AnimationController controller; - Animation animation; + late AnimationController controller; + late Animation animation; @override void initState() { diff --git a/animations/lib/src/basics/06_custom_tween.dart b/animations/lib/src/basics/06_custom_tween.dart index 4c2ce48e1f9..87471a449b3 100644 --- a/animations/lib/src/basics/06_custom_tween.dart +++ b/animations/lib/src/basics/06_custom_tween.dart @@ -5,13 +5,13 @@ import 'package:flutter/material.dart'; class TypewriterTween extends Tween { - TypewriterTween({String begin = '', String end}) + TypewriterTween({String begin = '', String end = ''}) : super(begin: begin, end: end); @override String lerp(double t) { - var cutoff = (end.length * t).round(); - return end.substring(0, cutoff); + var cutoff = (end!.length * t).round(); + return end!.substring(0, cutoff); } } @@ -26,8 +26,8 @@ class _CustomTweenDemoState extends State with SingleTickerProviderStateMixin { static const Duration _duration = Duration(seconds: 3); static const String message = loremIpsum; - AnimationController controller; - Animation animation; + late final AnimationController controller; + late final Animation animation; @override void initState() { diff --git a/animations/lib/src/basics/07_tween_sequence.dart b/animations/lib/src/basics/07_tween_sequence.dart index 231458777b2..59f98d6a145 100644 --- a/animations/lib/src/basics/07_tween_sequence.dart +++ b/animations/lib/src/basics/07_tween_sequence.dart @@ -14,8 +14,8 @@ class TweenSequenceDemo extends StatefulWidget { class _TweenSequenceDemoState extends State with SingleTickerProviderStateMixin { static const Duration duration = Duration(seconds: 3); - AnimationController controller; - Animation animation; + late final AnimationController controller; + late final Animation animation; static final colors = [ Colors.red, @@ -31,7 +31,7 @@ class _TweenSequenceDemoState extends State void initState() { super.initState(); - final sequenceItems = >[]; + final sequenceItems = >[]; for (var i = 0; i < colors.length; i++) { final beginColor = colors[i]; @@ -39,7 +39,7 @@ class _TweenSequenceDemoState extends State final weight = 1 / colors.length; sequenceItems.add( - TweenSequenceItem( + TweenSequenceItem( tween: ColorTween(begin: beginColor, end: endColor), weight: weight, ), @@ -47,7 +47,7 @@ class _TweenSequenceDemoState extends State } controller = AnimationController(duration: duration, vsync: this); - animation = TweenSequence(sequenceItems).animate(controller); + animation = TweenSequence(sequenceItems).animate(controller); } @override diff --git a/animations/lib/src/basics/08_fade_transition.dart b/animations/lib/src/basics/08_fade_transition.dart index 4d04dad19a1..15e5817cf53 100644 --- a/animations/lib/src/basics/08_fade_transition.dart +++ b/animations/lib/src/basics/08_fade_transition.dart @@ -15,9 +15,9 @@ class FadeTransitionDemo extends StatefulWidget { class _FadeTransitionDemoState extends State with SingleTickerProviderStateMixin { - AnimationController _controller; - Animation _animation; - CurvedAnimation _curve; + late final AnimationController _controller; + late final Animation _animation; + late final CurvedAnimation _curve; @override void initState() { diff --git a/animations/lib/src/misc/animated_list.dart b/animations/lib/src/misc/animated_list.dart index 7c9aff2aee6..7c115c5202b 100644 --- a/animations/lib/src/misc/animated_list.dart +++ b/animations/lib/src/misc/animated_list.dart @@ -14,23 +14,31 @@ class AnimatedListDemo extends StatefulWidget { class _AnimatedListDemoState extends State { final GlobalKey _listKey = GlobalKey(); - final listData = initialListData; + final listData = [ + UserModel(0, 'Govind', 'Dixit'), + UserModel(1, 'Greta', 'Stoll'), + UserModel(2, 'Monty', 'Carlo'), + UserModel(3, 'Petey', 'Cruiser'), + UserModel(4, 'Barry', 'Cade'), + ]; + final initialListSize = 5; void addUser() { setState(() { var index = listData.length; listData.add( - UserModel(firstName: 'New', lastName: 'Person'), + UserModel(++_maxIdValue, 'New', 'Person'), ); - _listKey.currentState + _listKey.currentState! .insertItem(index, duration: Duration(milliseconds: 300)); }); } - void deleteUser(int index) { + void deleteUser(int id) { setState(() { + final index = listData.indexWhere((u) => u.id == id); var user = listData.removeAt(index); - _listKey.currentState.removeItem( + _listKey.currentState!.removeItem( index, (context, animation) { return FadeTransition( @@ -49,7 +57,7 @@ class _AnimatedListDemoState extends State { }); } - Widget _buildItem(UserModel user, [int index]) { + Widget _buildItem(UserModel user) { return ListTile( key: ValueKey(user), title: Text(user.firstName), @@ -59,7 +67,7 @@ class _AnimatedListDemoState extends State { ), trailing: IconButton( icon: Icon(Icons.delete), - onPressed: () => deleteUser(index), + onPressed: () => deleteUser(user.id), ), ); } @@ -79,11 +87,11 @@ class _AnimatedListDemoState extends State { body: SafeArea( child: AnimatedList( key: _listKey, - initialItemCount: initialListData.length, + initialItemCount: 5, itemBuilder: (context, index, animation) { return FadeTransition( opacity: animation, - child: _buildItem(listData[index], index), + child: _buildItem(listData[index]), ); }, ), @@ -93,31 +101,15 @@ class _AnimatedListDemoState extends State { } class UserModel { - const UserModel({this.firstName, this.lastName}); + UserModel( + this.id, + this.firstName, + this.lastName, + ); + final int id; final String firstName; final String lastName; } -List initialListData = [ - UserModel( - firstName: 'Govind', - lastName: 'Dixit', - ), - UserModel( - firstName: 'Greta', - lastName: 'Stoll', - ), - UserModel( - firstName: 'Monty', - lastName: 'Carlo', - ), - UserModel( - firstName: 'Petey', - lastName: 'Cruiser', - ), - UserModel( - firstName: 'Barry', - lastName: 'Cade', - ), -]; +int _maxIdValue = 4; diff --git a/animations/lib/src/misc/animated_positioned.dart b/animations/lib/src/misc/animated_positioned.dart index 641ff91eb81..a514e96a6f9 100644 --- a/animations/lib/src/misc/animated_positioned.dart +++ b/animations/lib/src/misc/animated_positioned.dart @@ -14,8 +14,8 @@ class AnimatedPositionedDemo extends StatefulWidget { } class _AnimatedPositionedDemoState extends State { - double topPosition; - double leftPosition; + late double topPosition; + late double leftPosition; double generateTopPosition(double top) => Random().nextDouble() * top; @@ -41,40 +41,38 @@ class _AnimatedPositionedDemoState extends State { final appBar = AppBar(title: Text('AnimatedPositioned')); final topPadding = MediaQuery.of(context).padding.top; // AnimatedPositioned animates changes to a widget's position within a Stack - return SafeArea( - child: Scaffold( - appBar: appBar, - body: Container( - height: size.height, - width: size.width, - child: Stack( - children: [ - AnimatedPositioned( - top: topPosition, - left: leftPosition, - duration: Duration(seconds: 1), - child: InkWell( - onTap: () => changePosition( - size.height - - (appBar.preferredSize.height + topPadding + 50), - size.width - 150), - child: Container( - alignment: Alignment.center, - width: 150, - height: 50, - child: Text( - 'Click Me', - style: TextStyle( - color: - Theme.of(context).buttonTheme.colorScheme.onPrimary, - ), + return Scaffold( + appBar: appBar, + body: Container( + height: size.height, + width: size.width, + child: Stack( + children: [ + AnimatedPositioned( + top: topPosition, + left: leftPosition, + duration: Duration(seconds: 1), + child: InkWell( + onTap: () => changePosition( + size.height - + (appBar.preferredSize.height + topPadding + 50), + size.width - 150), + child: Container( + alignment: Alignment.center, + width: 150, + height: 50, + child: Text( + 'Click Me', + style: TextStyle( + color: + Theme.of(context).buttonTheme.colorScheme!.onPrimary, ), - color: Theme.of(context).primaryColor, ), + color: Theme.of(context).primaryColor, ), ), - ], - ), + ), + ], ), ), ); diff --git a/animations/lib/src/misc/animated_switcher.dart b/animations/lib/src/misc/animated_switcher.dart index 4c316d23000..bbd6e445ca4 100644 --- a/animations/lib/src/misc/animated_switcher.dart +++ b/animations/lib/src/misc/animated_switcher.dart @@ -30,8 +30,8 @@ class AnimatedSwitcherDemo extends StatefulWidget { } class _AnimatedSwitcherDemoState extends State { - Widget container; - int keyCount; + late Widget container; + late int keyCount; @override void initState() { @@ -53,7 +53,7 @@ class _AnimatedSwitcherDemoState extends State { child: Text( 'Change Widget', style: TextStyle( - color: Theme.of(context).buttonTheme.colorScheme.onPrimary), + color: Theme.of(context).buttonTheme.colorScheme!.onPrimary), ), ), ], diff --git a/animations/lib/src/misc/card_swipe.dart b/animations/lib/src/misc/card_swipe.dart index d024816fb58..56f7d55c69d 100644 --- a/animations/lib/src/misc/card_swipe.dart +++ b/animations/lib/src/misc/card_swipe.dart @@ -15,7 +15,7 @@ class CardSwipeDemo extends StatefulWidget { } class _CardSwipeDemoState extends State { - List fileNames; + late List fileNames; @override void initState() { @@ -102,8 +102,8 @@ class SwipeableCard extends StatefulWidget { final VoidCallback onSwiped; SwipeableCard({ - this.onSwiped, - this.imageAssetName, + required this.onSwiped, + required this.imageAssetName, }); @override @@ -112,9 +112,9 @@ class SwipeableCard extends StatefulWidget { class _SwipeableCardState extends State with SingleTickerProviderStateMixin { - AnimationController _controller; - Animation _animation; - double _dragStartX; + late AnimationController _controller; + late Animation _animation; + late double _dragStartX; bool _isSwipingLeft = false; @override @@ -155,18 +155,29 @@ class _SwipeableCardState extends State } setState(() { + final size = context.size; + + if (size == null) { + return; + } + // Calculate the amount dragged in unit coordinates (between 0 and 1) // using this widgets width. _controller.value = - (details.localPosition.dx - _dragStartX).abs() / context.size.width; + (details.localPosition.dx - _dragStartX).abs() / size.width; }); } /// Runs the fling / spring animation using the final velocity of the drag /// gesture. void _dragEnd(DragEndDetails details) { - var velocity = - (details.velocity.pixelsPerSecond.dx / context.size.width).abs(); + final size = context.size; + + if (size == null) { + return; + } + + var velocity = (details.velocity.pixelsPerSecond.dx / size.width).abs(); _animate(velocity: velocity); } diff --git a/animations/lib/src/misc/carousel.dart b/animations/lib/src/misc/carousel.dart index f89217b7dbb..712aecc3070 100644 --- a/animations/lib/src/misc/carousel.dart +++ b/animations/lib/src/misc/carousel.dart @@ -46,15 +46,15 @@ typedef OnCurrentItemChangedCallback = void Function(int currentItem); class Carousel extends StatefulWidget { final IndexedWidgetBuilder itemBuilder; - const Carousel({Key key, @required this.itemBuilder}); + const Carousel({Key? key, required this.itemBuilder}) : super(key: key); @override _CarouselState createState() => _CarouselState(); } class _CarouselState extends State { - PageController _controller; - int _currentPage; + late final PageController _controller; + late int _currentPage; bool _pageHasChanged = false; @override @@ -81,11 +81,11 @@ class _CarouselState extends State { itemBuilder: (context, index) => AnimatedBuilder( animation: _controller, builder: (context, child) { - var result = _pageHasChanged ? _controller.page : _currentPage * 1.0; + var result = _pageHasChanged ? _controller.page! : _currentPage * 1.0; // The horizontal position of the page between a 1 and 0 var value = result - index; - value = (1 - (value.abs() * .5)).clamp(0.0, 1.0) as double; + value = (1 - (value.abs() * .5)).clamp(0.0, 1.0); return Center( child: SizedBox( diff --git a/animations/lib/src/misc/curved_animation.dart b/animations/lib/src/misc/curved_animation.dart index 06558ebde89..52edbdebb68 100644 --- a/animations/lib/src/misc/curved_animation.dart +++ b/animations/lib/src/misc/curved_animation.dart @@ -15,14 +15,15 @@ class CurvedAnimationDemo extends StatefulWidget { class CurveChoice { final Curve curve; final String name; - const CurveChoice({this.curve, this.name}); + + const CurveChoice({required this.curve, required this.name}); } class _CurvedAnimationDemoState extends State with SingleTickerProviderStateMixin { - AnimationController controller; - Animation animationRotation; - Animation animationTranslation; + late final AnimationController controller; + late final Animation animationRotation; + late final Animation animationTranslation; static const _duration = Duration(seconds: 4); List curves = [ CurveChoice(curve: Curves.bounceIn, name: 'Bounce In'), @@ -38,8 +39,8 @@ class _CurvedAnimationDemoState extends State CurveChoice(curve: Curves.easeInCirc, name: 'Ease In Circle'), CurveChoice(curve: Curves.easeOutCirc, name: 'Ease Out Circle'), ]; - CurveChoice selectedForwardCurve, selectedReverseCurve; - CurvedAnimation curvedAnimation; + late CurveChoice selectedForwardCurve, selectedReverseCurve; + late final CurvedAnimation curvedAnimation; @override void initState() { @@ -100,10 +101,12 @@ class _CurvedAnimationDemoState extends State value: curve, child: Text(curve.name)); }).toList(), onChanged: (newCurve) { - setState(() { - selectedForwardCurve = newCurve; - curvedAnimation.curve = selectedForwardCurve.curve; - }); + if (newCurve != null) { + setState(() { + selectedForwardCurve = newCurve; + curvedAnimation.curve = selectedForwardCurve.curve; + }); + } }, value: selectedForwardCurve, ), @@ -118,10 +121,12 @@ class _CurvedAnimationDemoState extends State value: curve, child: Text(curve.name)); }).toList(), onChanged: (newCurve) { - setState(() { - selectedReverseCurve = newCurve; - curvedAnimation.reverseCurve = selectedReverseCurve.curve; - }); + if (newCurve != null) { + setState(() { + selectedReverseCurve = newCurve; + curvedAnimation.reverseCurve = selectedReverseCurve.curve; + }); + } }, value: selectedReverseCurve, ), diff --git a/animations/lib/src/misc/hero_animation.dart b/animations/lib/src/misc/hero_animation.dart index 8579cb2ff4f..fabac4cc4cc 100644 --- a/animations/lib/src/misc/hero_animation.dart +++ b/animations/lib/src/misc/hero_animation.dart @@ -18,7 +18,7 @@ class HeroAnimationDemo extends StatelessWidget { tag: 'hero-page-child', child: _createHeroContainer( size: 50.0, - color: Colors.grey[300], + color: Colors.grey.shade300, ), ), onTap: () => Navigator.of(context) @@ -47,7 +47,10 @@ class HeroPage extends StatelessWidget { } } -StatelessWidget _createHeroContainer({double size, Color color}) { +StatelessWidget _createHeroContainer({ + required double size, + required Color color, +}) { return Container( height: size, width: size, diff --git a/animations/lib/src/misc/physics_card_drag.dart b/animations/lib/src/misc/physics_card_drag.dart index 99443a8a3b6..8edd1b29e16 100644 --- a/animations/lib/src/misc/physics_card_drag.dart +++ b/animations/lib/src/misc/physics_card_drag.dart @@ -27,7 +27,7 @@ class PhysicsCardDragDemo extends StatelessWidget { /// released. class DraggableCard extends StatefulWidget { final Widget child; - DraggableCard({this.child}); + DraggableCard({required this.child}); @override _DraggableCardState createState() => _DraggableCardState(); @@ -35,7 +35,7 @@ class DraggableCard extends StatefulWidget { class _DraggableCardState extends State with SingleTickerProviderStateMixin { - AnimationController _controller; + late final AnimationController _controller; /// The alignment of the card as it is dragged or being animated. /// @@ -44,7 +44,7 @@ class _DraggableCardState extends State /// this value is set to the value of the [_animation]. var _dragAlignment = Alignment.center; - Animation _animation; + late Animation _animation; final _spring = const SpringDescription( mass: 10, diff --git a/animations/lib/src/misc/repeating_animation.dart b/animations/lib/src/misc/repeating_animation.dart index f27fd73bb8e..31b3dda061f 100644 --- a/animations/lib/src/misc/repeating_animation.dart +++ b/animations/lib/src/misc/repeating_animation.dart @@ -13,8 +13,8 @@ class RepeatingAnimationDemo extends StatefulWidget { class RepeatingAnimationDemoState extends State with SingleTickerProviderStateMixin { - AnimationController _controller; - Animation _borderRadius; + late final AnimationController _controller; + late final Animation _borderRadius; @override void initState() { diff --git a/animations/pubspec.lock b/animations/pubspec.lock index 144924780fb..9ccea16347d 100644 --- a/animations/pubspec.lock +++ b/animations/pubspec.lock @@ -49,7 +49,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.2" fake_async: dependency: transitive description: @@ -94,7 +94,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.9.2" + version: "1.10.0" sky_engine: dependency: transitive description: flutter diff --git a/animations/pubspec.yaml b/animations/pubspec.yaml index c587d9a5a6f..b1449dc3f61 100644 --- a/animations/pubspec.yaml +++ b/animations/pubspec.yaml @@ -3,12 +3,12 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.10.0 <3.0.0" + sdk: ">=2.12.0-0 <3.0.0" dependencies: flutter: sdk: flutter - cupertino_icons: ^1.0.0 + cupertino_icons: ^1.0.2 dev_dependencies: flutter_test: