diff --git a/animations/analysis_options.yaml b/animations/analysis_options.yaml index c64725cc6..be4f27226 100644 --- a/animations/analysis_options.yaml +++ b/animations/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,15 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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 b74b957bf..6dccb7485 100644 --- a/animations/lib/main.dart +++ b/animations/lib/main.dart @@ -151,7 +151,7 @@ class HomePage extends StatelessWidget { final headerStyle = Theme.of(context).textTheme.headline6; return Scaffold( appBar: AppBar( - title: Text('Animation Samples'), + title: const Text('Animation Samples'), ), body: ListView( children: [ @@ -168,7 +168,7 @@ class HomePage extends StatelessWidget { class DemoTile extends StatelessWidget { final Demo demo; - DemoTile(this.demo); + const DemoTile(this.demo); @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 e009f43ff..64ef59798 100644 --- a/animations/lib/src/basics/01_animated_container.dart +++ b/animations/lib/src/basics/01_animated_container.dart @@ -49,13 +49,13 @@ class _AnimatedContainerDemoState extends State { // and shrinking cards. return Scaffold( appBar: AppBar( - title: Text('AnimatedContainer'), + title: const Text('AnimatedContainer'), ), body: Center( child: Column( children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: SizedBox( width: 128, height: 128, @@ -70,7 +70,7 @@ class _AnimatedContainerDemoState extends State { ), ), ElevatedButton( - child: Text( + child: const Text( 'change', ), onPressed: () => change(), diff --git a/animations/lib/src/basics/02_page_route_builder.dart b/animations/lib/src/basics/02_page_route_builder.dart index 3b06d2c18..9205fc232 100644 --- a/animations/lib/src/basics/02_page_route_builder.dart +++ b/animations/lib/src/basics/02_page_route_builder.dart @@ -11,11 +11,11 @@ class PageRouteBuilderDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Page 1'), + title: const Text('Page 1'), ), body: Center( child: ElevatedButton( - child: Text('Go!'), + child: const Text('Go!'), onPressed: () { Navigator.of(context).push(_createRoute()); }, @@ -29,7 +29,8 @@ Route _createRoute() { return PageRouteBuilder( pageBuilder: (context, animation, secondaryAnimation) => _Page2(), transitionsBuilder: (context, animation, secondaryAnimation, child) { - var tween = Tween(begin: Offset(0.0, 1.0), end: Offset.zero); + var tween = + Tween(begin: const Offset(0.0, 1.0), end: Offset.zero); var curveTween = CurveTween(curve: Curves.ease); return SlideTransition( @@ -45,7 +46,7 @@ class _Page2 extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Page 2'), + title: const Text('Page 2'), ), body: Center( child: Text('Page 2!', style: Theme.of(context).textTheme.headline4), diff --git a/animations/lib/src/basics/03_animation_controller.dart b/animations/lib/src/basics/03_animation_controller.dart index 3a88bfebe..bcc50aa03 100644 --- a/animations/lib/src/basics/03_animation_controller.dart +++ b/animations/lib/src/basics/03_animation_controller.dart @@ -54,22 +54,22 @@ class _AnimationControllerDemoState extends State // has completed. return Scaffold( appBar: AppBar( - title: Text('Animation Controller'), + title: const Text('Animation Controller'), ), body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ ConstrainedBox( - constraints: BoxConstraints(maxWidth: 200), + constraints: const BoxConstraints(maxWidth: 200), child: Text( - '${controller.value.toStringAsFixed(2)}', + controller.value.toStringAsFixed(2), style: Theme.of(context).textTheme.headline3, textScaleFactor: 1 + controller.value, ), ), ElevatedButton( - child: Text('animate'), + child: const Text('animate'), onPressed: () { if (controller.status == AnimationStatus.completed) { controller.reverse(); diff --git a/animations/lib/src/basics/04_tweens.dart b/animations/lib/src/basics/04_tweens.dart index 1984f8b0c..4d73e94f0 100644 --- a/animations/lib/src/basics/04_tweens.dart +++ b/animations/lib/src/basics/04_tweens.dart @@ -40,16 +40,16 @@ class _TweenDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Tweens'), + title: const Text('Tweens'), ), body: Center( child: Column( mainAxisSize: MainAxisSize.min, children: [ ConstrainedBox( - constraints: BoxConstraints(maxWidth: 200), + constraints: const BoxConstraints(maxWidth: 200), child: Text('\$${animation.value.toStringAsFixed(2)}', - style: TextStyle(fontSize: 24)), + style: const TextStyle(fontSize: 24)), ), ElevatedButton( child: Text( diff --git a/animations/lib/src/basics/05_animated_builder.dart b/animations/lib/src/basics/05_animated_builder.dart index 10d7f0dbe..6a3c858bc 100644 --- a/animations/lib/src/basics/05_animated_builder.dart +++ b/animations/lib/src/basics/05_animated_builder.dart @@ -15,7 +15,7 @@ class _AnimatedBuilderDemoState extends State with SingleTickerProviderStateMixin { static const Color beginColor = Colors.deepPurple; static const Color endColor = Colors.deepOrange; - Duration duration = Duration(milliseconds: 800); + Duration duration = const Duration(milliseconds: 800); late AnimationController controller; late Animation animation; @@ -38,7 +38,7 @@ class _AnimatedBuilderDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('AnimatedBuilder'), + title: const Text('AnimatedBuilder'), ), body: Center( // AnimatedBuilder handles listening to a given animation and calling the builder @@ -66,7 +66,7 @@ class _AnimatedBuilderDemoState extends State // if there is a non-animated Widget contained within the animated widget. // This can improve performance since this widget doesn't need to be rebuilt // when the animation changes. - child: Text( + child: const Text( 'Change Color', style: TextStyle(color: Colors.white), ), diff --git a/animations/lib/src/basics/06_custom_tween.dart b/animations/lib/src/basics/06_custom_tween.dart index 87471a449..311696912 100644 --- a/animations/lib/src/basics/06_custom_tween.dart +++ b/animations/lib/src/basics/06_custom_tween.dart @@ -47,7 +47,7 @@ class _CustomTweenDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Custom Tween'), + title: const Text('Custom Tween'), actions: [ MaterialButton( child: Text( @@ -79,16 +79,18 @@ class _CustomTweenDemoState extends State crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Padding( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: Card( child: Container( - padding: EdgeInsets.all(8.0), + padding: const EdgeInsets.all(8.0), child: AnimatedBuilder( animation: animation, builder: (context, child) { - return Text('${animation.value}', - style: TextStyle( - fontSize: 16, fontFamily: 'SpecialElite')); + return Text( + animation.value, + style: const TextStyle( + fontSize: 16, fontFamily: 'SpecialElite'), + ); }, ), ), diff --git a/animations/lib/src/basics/07_tween_sequence.dart b/animations/lib/src/basics/07_tween_sequence.dart index 59f98d6a1..9f59b8534 100644 --- a/animations/lib/src/basics/07_tween_sequence.dart +++ b/animations/lib/src/basics/07_tween_sequence.dart @@ -60,7 +60,7 @@ class _TweenSequenceDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Tween Sequences'), + title: const Text('Tween Sequences'), ), body: Center( child: AnimatedBuilder( @@ -75,7 +75,7 @@ class _TweenSequenceDemoState extends State child: child, ); }, - child: Text('Animate', style: TextStyle(color: Colors.white)), + child: const Text('Animate', style: TextStyle(color: Colors.white)), ), ), ); diff --git a/animations/lib/src/basics/08_fade_transition.dart b/animations/lib/src/basics/08_fade_transition.dart index 15e5817cf..e7da42d59 100644 --- a/animations/lib/src/basics/08_fade_transition.dart +++ b/animations/lib/src/basics/08_fade_transition.dart @@ -24,7 +24,7 @@ class _FadeTransitionDemoState extends State super.initState(); _controller = AnimationController( vsync: this, - duration: Duration(milliseconds: 500), + duration: const Duration(milliseconds: 500), ); _curve = CurvedAnimation(parent: _controller, curve: Curves.easeIn); @@ -45,7 +45,7 @@ class _FadeTransitionDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text( + title: const Text( 'Fade Transition', ), ), @@ -55,14 +55,14 @@ class _FadeTransitionDemoState extends State children: [ FadeTransition( opacity: _animation, - child: Icon( + child: const Icon( Icons.star, color: Colors.amber, size: 300, ), ), ElevatedButton( - child: Text('animate'), + child: const Text('animate'), onPressed: () => setState(() { _controller.animateTo(1.0).then( (value) => _controller.animateBack(0.0)); diff --git a/animations/lib/src/misc/animated_list.dart b/animations/lib/src/misc/animated_list.dart index 7c115c520..a8c8d46ee 100644 --- a/animations/lib/src/misc/animated_list.dart +++ b/animations/lib/src/misc/animated_list.dart @@ -30,7 +30,7 @@ class _AnimatedListDemoState extends State { UserModel(++_maxIdValue, 'New', 'Person'), ); _listKey.currentState! - .insertItem(index, duration: Duration(milliseconds: 300)); + .insertItem(index, duration: const Duration(milliseconds: 300)); }); } @@ -42,17 +42,17 @@ class _AnimatedListDemoState extends State { index, (context, animation) { return FadeTransition( - opacity: - CurvedAnimation(parent: animation, curve: Interval(0.5, 1.0)), + opacity: CurvedAnimation( + parent: animation, curve: const Interval(0.5, 1.0)), child: SizeTransition( - sizeFactor: - CurvedAnimation(parent: animation, curve: Interval(0.0, 1.0)), + sizeFactor: CurvedAnimation( + parent: animation, curve: const Interval(0.0, 1.0)), axisAlignment: 0.0, child: _buildItem(user), ), ); }, - duration: Duration(milliseconds: 600), + duration: const Duration(milliseconds: 600), ); }); } @@ -62,11 +62,11 @@ class _AnimatedListDemoState extends State { key: ValueKey(user), title: Text(user.firstName), subtitle: Text(user.lastName), - leading: CircleAvatar( + leading: const CircleAvatar( child: Icon(Icons.person), ), trailing: IconButton( - icon: Icon(Icons.delete), + icon: const Icon(Icons.delete), onPressed: () => deleteUser(user.id), ), ); @@ -76,10 +76,10 @@ class _AnimatedListDemoState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('AnimatedList'), + title: const Text('AnimatedList'), actions: [ IconButton( - icon: Icon(Icons.add), + icon: const Icon(Icons.add), onPressed: addUser, ), ], diff --git a/animations/lib/src/misc/animated_positioned.dart b/animations/lib/src/misc/animated_positioned.dart index a514e96a6..c746f696e 100644 --- a/animations/lib/src/misc/animated_positioned.dart +++ b/animations/lib/src/misc/animated_positioned.dart @@ -38,12 +38,12 @@ class _AnimatedPositionedDemoState extends State { @override Widget build(BuildContext context) { final size = MediaQuery.of(context).size; - final appBar = AppBar(title: Text('AnimatedPositioned')); + final appBar = AppBar(title: const Text('AnimatedPositioned')); final topPadding = MediaQuery.of(context).padding.top; // AnimatedPositioned animates changes to a widget's position within a Stack return Scaffold( appBar: appBar, - body: Container( + body: SizedBox( height: size.height, width: size.width, child: Stack( @@ -51,7 +51,7 @@ class _AnimatedPositionedDemoState extends State { AnimatedPositioned( top: topPosition, left: leftPosition, - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), child: InkWell( onTap: () => changePosition( size.height - diff --git a/animations/lib/src/misc/animated_switcher.dart b/animations/lib/src/misc/animated_switcher.dart index bbd6e445c..15d5de0c1 100644 --- a/animations/lib/src/misc/animated_switcher.dart +++ b/animations/lib/src/misc/animated_switcher.dart @@ -44,7 +44,7 @@ class _AnimatedSwitcherDemoState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('AnimatedSwitcher'), + title: const Text('AnimatedSwitcher'), actions: [ MaterialButton( onPressed: () => setState( @@ -63,7 +63,7 @@ class _AnimatedSwitcherDemoState extends State { // with a given transition. You can change the transitions by using // transitionBuilder property. child: AnimatedSwitcher( - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), child: container, transitionBuilder: (child, animation) => ScaleTransition( child: child, diff --git a/animations/lib/src/misc/card_swipe.dart b/animations/lib/src/misc/card_swipe.dart index 56f7d55c6..872583c6c 100644 --- a/animations/lib/src/misc/card_swipe.dart +++ b/animations/lib/src/misc/card_swipe.dart @@ -35,7 +35,7 @@ class _CardSwipeDemoState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Card Swipe'), + title: const Text('Card Swipe'), ), body: Padding( padding: const EdgeInsets.all(12.0), @@ -78,7 +78,7 @@ class _CardSwipeDemoState extends State { class Card extends StatelessWidget { final String imageAssetName; - Card(this.imageAssetName); + const Card(this.imageAssetName); @override Widget build(BuildContext context) { @@ -101,7 +101,7 @@ class SwipeableCard extends StatefulWidget { final String imageAssetName; final VoidCallback onSwiped; - SwipeableCard({ + const SwipeableCard({ required this.onSwiped, required this.imageAssetName, }); @@ -123,7 +123,7 @@ class _SwipeableCardState extends State _controller = AnimationController.unbounded(vsync: this); _animation = _controller.drive(Tween( begin: Offset.zero, - end: Offset(1, 0), + end: const Offset(1, 0), )); } @@ -184,12 +184,13 @@ class _SwipeableCardState extends State void _updateAnimation(double dragPosition) { _animation = _controller.drive(Tween( begin: Offset.zero, - end: _isSwipingLeft ? Offset(-1, 0) : Offset(1, 0), + end: _isSwipingLeft ? const Offset(-1, 0) : const Offset(1, 0), )); } void _animate({double velocity = 0}) { - var description = SpringDescription(mass: 50, stiffness: 1, damping: 1); + var description = + const SpringDescription(mass: 50, stiffness: 1, damping: 1); var simulation = SpringSimulation(description, _controller.value, 1, velocity); _controller.animateWith(simulation).then((_) { diff --git a/animations/lib/src/misc/carousel.dart b/animations/lib/src/misc/carousel.dart index 712aecc30..88e94170a 100644 --- a/animations/lib/src/misc/carousel.dart +++ b/animations/lib/src/misc/carousel.dart @@ -22,7 +22,7 @@ class CarouselDemo extends StatelessWidget { Widget build(context) { return Scaffold( appBar: AppBar( - title: Text('Carousel Demo'), + title: const Text('Carousel Demo'), ), body: Center( child: Padding( diff --git a/animations/lib/src/misc/curved_animation.dart b/animations/lib/src/misc/curved_animation.dart index 52edbdebb..cb405e93d 100644 --- a/animations/lib/src/misc/curved_animation.dart +++ b/animations/lib/src/misc/curved_animation.dart @@ -25,7 +25,7 @@ class _CurvedAnimationDemoState extends State late final Animation animationRotation; late final Animation animationTranslation; static const _duration = Duration(seconds: 4); - List curves = [ + List curves = const [ CurveChoice(curve: Curves.bounceIn, name: 'Bounce In'), CurveChoice(curve: Curves.bounceOut, name: 'Bounce Out'), CurveChoice(curve: Curves.easeInCubic, name: 'Ease In Cubic'), @@ -69,8 +69,8 @@ class _CurvedAnimationDemoState extends State } }); animationTranslation = Tween( - begin: Offset(-1, 0), - end: Offset(1, 0), + begin: const Offset(-1, 0), + end: const Offset(1, 0), ).animate(curvedAnimation) ..addListener(() { setState(() {}); @@ -86,11 +86,11 @@ class _CurvedAnimationDemoState extends State Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Curved Animation'), + title: const Text('Curved Animation'), ), body: Column( children: [ - SizedBox(height: 20.0), + const SizedBox(height: 20.0), Text( 'Select Curve for forward motion', style: Theme.of(context).textTheme.headline6, @@ -110,7 +110,7 @@ class _CurvedAnimationDemoState extends State }, value: selectedForwardCurve, ), - SizedBox(height: 15.0), + const SizedBox(height: 15.0), Text( 'Select Curve for reverse motion', style: Theme.of(context).textTheme.headline6, @@ -130,32 +130,28 @@ class _CurvedAnimationDemoState extends State }, value: selectedReverseCurve, ), - SizedBox(height: 35.0), + const SizedBox(height: 35.0), Transform.rotate( angle: animationRotation.value, - child: Center( - child: Container( - child: FlutterLogo( - size: 100, - ), + child: const Center( + child: FlutterLogo( + size: 100, ), ), ), - SizedBox(height: 35.0), + const SizedBox(height: 35.0), FractionalTranslation( translation: animationTranslation.value, - child: Container( - child: FlutterLogo( - size: 100, - ), + child: const FlutterLogo( + size: 100, ), ), - SizedBox(height: 25.0), + const SizedBox(height: 25.0), ElevatedButton( onPressed: () { controller.forward(); }, - child: Text('Animate'), + child: const Text('Animate'), ), ], ), diff --git a/animations/lib/src/misc/expand_card.dart b/animations/lib/src/misc/expand_card.dart index fe4f80394..1190cc23a 100644 --- a/animations/lib/src/misc/expand_card.dart +++ b/animations/lib/src/misc/expand_card.dart @@ -11,7 +11,7 @@ class ExpandCardDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Expandable Card'), + title: const Text('Expandable Card'), ), body: Center( child: ExpandCard(), diff --git a/animations/lib/src/misc/focus_image.dart b/animations/lib/src/misc/focus_image.dart index d35f6f092..a1e11227f 100644 --- a/animations/lib/src/misc/focus_image.dart +++ b/animations/lib/src/misc/focus_image.dart @@ -10,7 +10,7 @@ class FocusImageDemo extends StatelessWidget { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Focus Image')), + appBar: AppBar(title: const Text('Focus Image')), body: Grid(), ); } @@ -23,11 +23,11 @@ class Grid extends StatelessWidget { body: GridView.builder( itemCount: 40, gridDelegate: - SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), + const SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4), itemBuilder: (context, index) { return (index >= 20) - ? SmallCard('assets/eat_cape_town_sm.jpg') - : SmallCard('assets/eat_new_orleans_sm.jpg'); + ? const SmallCard('assets/eat_cape_town_sm.jpg') + : const SmallCard('assets/eat_new_orleans_sm.jpg'); }, ), ); @@ -68,7 +68,7 @@ Tween _createTween(BuildContext context) { class SmallCard extends StatelessWidget { final String imageAssetName; - SmallCard(this.imageAssetName); + const SmallCard(this.imageAssetName); @override Widget build(BuildContext context) { @@ -92,7 +92,7 @@ class SmallCard extends StatelessWidget { class _SecondPage extends StatelessWidget { final String imageAssetName; - _SecondPage(this.imageAssetName); + const _SecondPage(this.imageAssetName); @override Widget build(BuildContext context) { diff --git a/animations/lib/src/misc/hero_animation.dart b/animations/lib/src/misc/hero_animation.dart index fabac4cc4..174beeac8 100644 --- a/animations/lib/src/misc/hero_animation.dart +++ b/animations/lib/src/misc/hero_animation.dart @@ -11,7 +11,7 @@ class HeroAnimationDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Hero Animation'), + title: const Text('Hero Animation'), ), body: GestureDetector( child: Hero( @@ -54,12 +54,12 @@ StatelessWidget _createHeroContainer({ return Container( height: size, width: size, - padding: EdgeInsets.all(10.0), - margin: size < 100.0 ? EdgeInsets.all(10.0) : EdgeInsets.all(0), + padding: const EdgeInsets.all(10.0), + margin: size < 100.0 ? const EdgeInsets.all(10.0) : const EdgeInsets.all(0), decoration: BoxDecoration( shape: BoxShape.circle, color: color, ), - child: FlutterLogo(), + child: const FlutterLogo(), ); } diff --git a/animations/lib/src/misc/physics_card_drag.dart b/animations/lib/src/misc/physics_card_drag.dart index 8edd1b29e..51da6e76b 100644 --- a/animations/lib/src/misc/physics_card_drag.dart +++ b/animations/lib/src/misc/physics_card_drag.dart @@ -12,9 +12,9 @@ class PhysicsCardDragDemo extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Spring Physics'), + title: const Text('Spring Physics'), ), - body: DraggableCard( + body: const DraggableCard( child: FlutterLogo( size: 128, ), @@ -27,7 +27,7 @@ class PhysicsCardDragDemo extends StatelessWidget { /// released. class DraggableCard extends StatefulWidget { final Widget child; - DraggableCard({required this.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 31b3dda06..6767d1239 100644 --- a/animations/lib/src/misc/repeating_animation.dart +++ b/animations/lib/src/misc/repeating_animation.dart @@ -33,7 +33,7 @@ class RepeatingAnimationDemoState extends State @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar(title: Text('Repeating Animation')), + appBar: AppBar(title: const Text('Repeating Animation')), body: Center( child: AnimatedBuilder( animation: _borderRadius, diff --git a/animations/macos/Runner.xcodeproj/project.pbxproj b/animations/macos/Runner.xcodeproj/project.pbxproj index 5a64e58cd..0a6b4d409 100644 --- a/animations/macos/Runner.xcodeproj/project.pbxproj +++ b/animations/macos/Runner.xcodeproj/project.pbxproj @@ -26,10 +26,6 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -49,8 +45,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -69,13 +63,11 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -83,8 +75,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -138,8 +128,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -260,7 +248,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; diff --git a/animations/pubspec.lock b/animations/pubspec.lock index bc98564c9..29526b6b5 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.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -62,11 +62,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -88,13 +102,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" sky_engine: dependency: transitive description: flutter diff --git a/animations/pubspec.yaml b/animations/pubspec.yaml index b1449dc3f..bee1acf79 100644 --- a/animations/pubspec.yaml +++ b/animations/pubspec.yaml @@ -3,7 +3,7 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: @@ -13,7 +13,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/animations/test/misc/card_swipe_test.dart b/animations/test/misc/card_swipe_test.dart index 95c039903..f381f4cff 100644 --- a/animations/test/misc/card_swipe_test.dart +++ b/animations/test/misc/card_swipe_test.dart @@ -20,7 +20,8 @@ void main() { var totalCards = tester.widgetList(find.byType(SwipeableCard)).length; // Swipe out one card. - await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0)); + await tester.drag( + find.byType(SwipeableCard).first, const Offset(100.0, 0.0)); await tester.pumpAndSettle(); // Check if removed properly. @@ -37,7 +38,8 @@ void main() { // Swipe out all cards. for (var i = 0; i < totalCards; i++) { // Swipe out one by one. - await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0)); + await tester.drag( + find.byType(SwipeableCard).first, const Offset(100.0, 0.0)); await tester.pumpAndSettle(); } @@ -52,7 +54,8 @@ void main() { var totalCards = tester.widgetList(find.byType(SwipeableCard)).length; // Swipe out one card. - await tester.drag(find.byType(SwipeableCard).first, Offset(100.0, 0.0)); + await tester.drag( + find.byType(SwipeableCard).first, const Offset(100.0, 0.0)); await tester.pumpAndSettle(); // Tap the Refill button. diff --git a/animations/test/misc/carousel_test.dart b/animations/test/misc/carousel_test.dart index d466acd7c..7793a57c6 100644 --- a/animations/test/misc/carousel_test.dart +++ b/animations/test/misc/carousel_test.dart @@ -20,7 +20,7 @@ void main() { expect(imageList.length, 2); // Swipe the Carousel. - await tester.fling(find.byType(CarouselDemo), Offset(-400, 0), 800); + await tester.fling(find.byType(CarouselDemo), const Offset(-400, 0), 800); await tester.pumpAndSettle(); // Get the images available on the screen after swipe. diff --git a/experimental/desktop_photo_search/analysis_options.yaml b/experimental/desktop_photo_search/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/experimental/desktop_photo_search/analysis_options.yaml +++ b/experimental/desktop_photo_search/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/experimental/desktop_photo_search/lib/main.dart b/experimental/desktop_photo_search/lib/main.dart index 0837dd728..89017d5b2 100644 --- a/experimental/desktop_photo_search/lib/main.dart +++ b/experimental/desktop_photo_search/lib/main.dart @@ -5,12 +5,10 @@ import 'dart:io'; import 'package:file_selector/file_selector.dart'; -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_simple_treeview/flutter_simple_treeview.dart'; import 'package:logging/logging.dart'; import 'package:menubar/menubar.dart' as menubar; -import 'package:meta/meta.dart'; import 'package:provider/provider.dart'; import 'src/model/photo_search_model.dart'; @@ -58,7 +56,7 @@ class UnsplashSearchApp extends StatelessWidget { } class UnsplashHomePage extends StatelessWidget { - const UnsplashHomePage({@required this.title}); + const UnsplashHomePage({required this.title}); final String title; @override @@ -83,7 +81,7 @@ class UnsplashHomePage extends StatelessWidget { onClicked: () { showDialog( context: context, - builder: (context) => PolicyDialog(), + builder: (context) => const PolicyDialog(), ); }, ), @@ -111,7 +109,7 @@ class UnsplashHomePage extends StatelessWidget { secondChild: Center( child: photoSearchModel.selectedPhoto != null ? PhotoDetails( - photo: photoSearchModel.selectedPhoto, + photo: photoSearchModel.selectedPhoto!, onPhotoSave: (photo) async { final path = await getSavePath( suggestedName: '${photo.id}.jpg', @@ -144,7 +142,7 @@ class UnsplashHomePage extends StatelessWidget { builder: (context) => PhotoSearchDialog(photoSearchModel.addSearch), ), tooltip: 'Search for a photo', - child: Icon(Icons.search), + child: const Icon(Icons.search), ), ); } @@ -165,7 +163,7 @@ class UnsplashHomePage extends StatelessWidget { child: Padding( padding: const EdgeInsets.all(12.0), child: Text( - 'Photo by ${photo.user.name}', + 'Photo by ${photo.user!.name}', ), ), ), diff --git a/experimental/desktop_photo_search/lib/src/model/photo_search_model.dart b/experimental/desktop_photo_search/lib/src/model/photo_search_model.dart index e6509403d..dcb839894 100644 --- a/experimental/desktop_photo_search/lib/src/model/photo_search_model.dart +++ b/experimental/desktop_photo_search/lib/src/model/photo_search_model.dart @@ -5,7 +5,6 @@ import 'dart:typed_data'; import 'package:flutter/foundation.dart'; -import 'package:meta/meta.dart'; import '../unsplash/photo.dart'; import '../unsplash/unsplash.dart'; @@ -25,13 +24,13 @@ class PhotoSearchModel extends ChangeNotifier { List get entries => List.unmodifiable(_entries); final List _entries = []; - Photo get selectedPhoto => _selectedPhoto; - set selectedPhoto(Photo photo) { + Photo? get selectedPhoto => _selectedPhoto; + set selectedPhoto(Photo? photo) { _selectedPhoto = photo; notifyListeners(); } - Photo _selectedPhoto; + Photo? _selectedPhoto; Future addSearch(String query) async { final result = await _client.searchPhotos( @@ -41,13 +40,12 @@ class PhotoSearchModel extends ChangeNotifier { final search = Search((s) { s ..query = query - ..results.addAll(result.results); + ..results.addAll(result!.results); }); _entries.add(SearchEntry(query, search.results.toList(), this)); notifyListeners(); } - Future download({@required Photo photo}) => - _client.download(photo); + Future download({required Photo photo}) => _client.download(photo); } diff --git a/experimental/desktop_photo_search/lib/src/model/search.dart b/experimental/desktop_photo_search/lib/src/model/search.dart index fd482c178..be2487a9e 100644 --- a/experimental/desktop_photo_search/lib/src/model/search.dart +++ b/experimental/desktop_photo_search/lib/src/model/search.dart @@ -14,7 +14,7 @@ import '../unsplash/photo.dart'; part 'search.g.dart'; abstract class Search implements Built { - factory Search([void Function(SearchBuilder) updates]) = _$Search; + factory Search([void Function(SearchBuilder)? updates]) = _$Search; Search._(); @BuiltValueField(wireName: 'query') @@ -27,7 +27,7 @@ abstract class Search implements Built { return json.encode(serializers.serializeWith(Search.serializer, this)); } - static Search fromJson(String jsonString) { + static Search? fromJson(String jsonString) { return serializers.deserializeWith( Search.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/model/search.g.dart b/experimental/desktop_photo_search/lib/src/model/search.g.dart index 0bb59e677..ae59f2871 100644 --- a/experimental/desktop_photo_search/lib/src/model/search.g.dart +++ b/experimental/desktop_photo_search/lib/src/model/search.g.dart @@ -19,9 +19,9 @@ class _$SearchSerializer implements StructuredSerializer { final String wireName = 'Search'; @override - Iterable serialize(Serializers serializers, Search object, + Iterable serialize(Serializers serializers, Search object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'query', serializers.serialize(object.query, specifiedType: const FullType(String)), @@ -35,7 +35,7 @@ class _$SearchSerializer implements StructuredSerializer { } @override - Search deserialize(Serializers serializers, Iterable serialized, + Search deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new SearchBuilder(); @@ -43,7 +43,7 @@ class _$SearchSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'query': result.query = serializers.deserialize(value, @@ -52,7 +52,7 @@ class _$SearchSerializer implements StructuredSerializer { case 'results': result.results.replace(serializers.deserialize(value, specifiedType: - const FullType(BuiltList, const [const FullType(Photo)])) + const FullType(BuiltList, const [const FullType(Photo)]))! as BuiltList); break; } @@ -68,10 +68,10 @@ class _$Search extends Search { @override final BuiltList results; - factory _$Search([void Function(SearchBuilder) updates]) => + factory _$Search([void Function(SearchBuilder)? updates]) => (new SearchBuilder()..update(updates)).build(); - _$Search._({this.query, this.results}) : super._() { + _$Search._({required this.query, required this.results}) : super._() { BuiltValueNullFieldError.checkNotNull(query, 'Search', 'query'); BuiltValueNullFieldError.checkNotNull(results, 'Search', 'results'); } @@ -104,16 +104,16 @@ class _$Search extends Search { } class SearchBuilder implements Builder { - _$Search _$v; + _$Search? _$v; - String _query; - String get query => _$this._query; - set query(String query) => _$this._query = query; + String? _query; + String? get query => _$this._query; + set query(String? query) => _$this._query = query; - ListBuilder _results; + ListBuilder? _results; ListBuilder get results => _$this._results ??= new ListBuilder(); - set results(ListBuilder results) => _$this._results = results; + set results(ListBuilder? results) => _$this._results = results; SearchBuilder(); @@ -134,7 +134,7 @@ class SearchBuilder implements Builder { } @override - void update(void Function(SearchBuilder) updates) { + void update(void Function(SearchBuilder)? updates) { if (updates != null) updates(this); } @@ -148,7 +148,7 @@ class SearchBuilder implements Builder { query, 'Search', 'query'), results: results.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'results'; results.build(); diff --git a/experimental/desktop_photo_search/lib/src/unsplash/api_error.dart b/experimental/desktop_photo_search/lib/src/unsplash/api_error.dart index 5a80cb230..72e48a691 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/api_error.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/api_error.dart @@ -13,18 +13,18 @@ import '../serializers.dart'; part 'api_error.g.dart'; abstract class ApiError implements Built { - factory ApiError([void Function(ApiErrorBuilder) updates]) = _$ApiError; + factory ApiError([void Function(ApiErrorBuilder)? updates]) = _$ApiError; ApiError._(); @BuiltValueField(wireName: 'errors') - BuiltList get errors; + BuiltList? get errors; String toJson() { return json.encode(serializers.serializeWith(ApiError.serializer, this)); } - static ApiError fromJson(String jsonString) { + static ApiError? fromJson(String jsonString) { return serializers.deserializeWith( ApiError.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/api_error.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/api_error.g.dart index ac781f16a..4cfa82513 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/api_error.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/api_error.g.dart @@ -19,20 +19,23 @@ class _$ApiErrorSerializer implements StructuredSerializer { final String wireName = 'ApiError'; @override - Iterable serialize(Serializers serializers, ApiError object, + Iterable serialize(Serializers serializers, ApiError object, {FullType specifiedType = FullType.unspecified}) { - final result = [ - 'errors', - serializers.serialize(object.errors, - specifiedType: - const FullType(BuiltList, const [const FullType(String)])), - ]; - + final result = []; + Object? value; + value = object.errors; + if (value != null) { + result + ..add('errors') + ..add(serializers.serialize(value, + specifiedType: + const FullType(BuiltList, const [const FullType(String)]))); + } return result; } @override - ApiError deserialize(Serializers serializers, Iterable serialized, + ApiError deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new ApiErrorBuilder(); @@ -40,12 +43,12 @@ class _$ApiErrorSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'errors': result.errors.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, const [const FullType(String)])) + specifiedType: const FullType( + BuiltList, const [const FullType(String)]))! as BuiltList); break; } @@ -57,14 +60,12 @@ class _$ApiErrorSerializer implements StructuredSerializer { class _$ApiError extends ApiError { @override - final BuiltList errors; + final BuiltList? errors; - factory _$ApiError([void Function(ApiErrorBuilder) updates]) => + factory _$ApiError([void Function(ApiErrorBuilder)? updates]) => (new ApiErrorBuilder()..update(updates)).build(); - _$ApiError._({this.errors}) : super._() { - BuiltValueNullFieldError.checkNotNull(errors, 'ApiError', 'errors'); - } + _$ApiError._({this.errors}) : super._(); @override ApiError rebuild(void Function(ApiErrorBuilder) updates) => @@ -92,19 +93,19 @@ class _$ApiError extends ApiError { } class ApiErrorBuilder implements Builder { - _$ApiError _$v; + _$ApiError? _$v; - ListBuilder _errors; + ListBuilder? _errors; ListBuilder get errors => _$this._errors ??= new ListBuilder(); - set errors(ListBuilder errors) => _$this._errors = errors; + set errors(ListBuilder? errors) => _$this._errors = errors; ApiErrorBuilder(); ApiErrorBuilder get _$this { final $v = _$v; if ($v != null) { - _errors = $v.errors.toBuilder(); + _errors = $v.errors?.toBuilder(); _$v = null; } return this; @@ -117,7 +118,7 @@ class ApiErrorBuilder implements Builder { } @override - void update(void Function(ApiErrorBuilder) updates) { + void update(void Function(ApiErrorBuilder)? updates) { if (updates != null) updates(this); } @@ -125,12 +126,12 @@ class ApiErrorBuilder implements Builder { _$ApiError build() { _$ApiError _$result; try { - _$result = _$v ?? new _$ApiError._(errors: errors.build()); + _$result = _$v ?? new _$ApiError._(errors: _errors?.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'errors'; - errors.build(); + _errors?.build(); } catch (e) { throw new BuiltValueNestedFieldError( 'ApiError', _$failedField, e.toString()); diff --git a/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.dart b/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.dart index 165128be1..205b3e755 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.dart @@ -14,7 +14,7 @@ part 'current_user_collections.g.dart'; abstract class CurrentUserCollections implements Built { factory CurrentUserCollections( - [void Function(CurrentUserCollectionsBuilder) updates]) = + [void Function(CurrentUserCollectionsBuilder)? updates]) = _$CurrentUserCollections; CurrentUserCollections._(); @@ -22,24 +22,21 @@ abstract class CurrentUserCollections @BuiltValueField(wireName: 'id') int get id; - @nullable @BuiltValueField(wireName: 'title') - String get title; + String? get title; - @nullable @BuiltValueField(wireName: 'published_at') - String get publishedAt; + String? get publishedAt; - @nullable @BuiltValueField(wireName: 'updated_at') - String get updatedAt; + String? get updatedAt; String toJson() { return json.encode( serializers.serializeWith(CurrentUserCollections.serializer, this)); } - static CurrentUserCollections fromJson(String jsonString) { + static CurrentUserCollections? fromJson(String jsonString) { return serializers.deserializeWith( CurrentUserCollections.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.g.dart index ce8a8b60c..1c59cad46 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/current_user_collections.g.dart @@ -24,14 +24,14 @@ class _$CurrentUserCollectionsSerializer final String wireName = 'CurrentUserCollections'; @override - Iterable serialize( + Iterable serialize( Serializers serializers, CurrentUserCollections object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'id', serializers.serialize(object.id, specifiedType: const FullType(int)), ]; - Object value; + Object? value; value = object.title; if (value != null) { result @@ -58,7 +58,7 @@ class _$CurrentUserCollectionsSerializer @override CurrentUserCollections deserialize( - Serializers serializers, Iterable serialized, + Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new CurrentUserCollectionsBuilder(); @@ -66,7 +66,7 @@ class _$CurrentUserCollectionsSerializer while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'id': result.id = serializers.deserialize(value, @@ -95,18 +95,18 @@ class _$CurrentUserCollections extends CurrentUserCollections { @override final int id; @override - final String title; + final String? title; @override - final String publishedAt; + final String? publishedAt; @override - final String updatedAt; + final String? updatedAt; factory _$CurrentUserCollections( - [void Function(CurrentUserCollectionsBuilder) updates]) => + [void Function(CurrentUserCollectionsBuilder)? updates]) => (new CurrentUserCollectionsBuilder()..update(updates)).build(); _$CurrentUserCollections._( - {this.id, this.title, this.publishedAt, this.updatedAt}) + {required this.id, this.title, this.publishedAt, this.updatedAt}) : super._() { BuiltValueNullFieldError.checkNotNull(id, 'CurrentUserCollections', 'id'); } @@ -150,23 +150,23 @@ class _$CurrentUserCollections extends CurrentUserCollections { class CurrentUserCollectionsBuilder implements Builder { - _$CurrentUserCollections _$v; + _$CurrentUserCollections? _$v; - int _id; - int get id => _$this._id; - set id(int id) => _$this._id = id; + int? _id; + int? get id => _$this._id; + set id(int? id) => _$this._id = id; - String _title; - String get title => _$this._title; - set title(String title) => _$this._title = title; + String? _title; + String? get title => _$this._title; + set title(String? title) => _$this._title = title; - String _publishedAt; - String get publishedAt => _$this._publishedAt; - set publishedAt(String publishedAt) => _$this._publishedAt = publishedAt; + String? _publishedAt; + String? get publishedAt => _$this._publishedAt; + set publishedAt(String? publishedAt) => _$this._publishedAt = publishedAt; - String _updatedAt; - String get updatedAt => _$this._updatedAt; - set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt; + String? _updatedAt; + String? get updatedAt => _$this._updatedAt; + set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt; CurrentUserCollectionsBuilder(); @@ -189,7 +189,7 @@ class CurrentUserCollectionsBuilder } @override - void update(void Function(CurrentUserCollectionsBuilder) updates) { + void update(void Function(CurrentUserCollectionsBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/exif.dart b/experimental/desktop_photo_search/lib/src/unsplash/exif.dart index 32d242f93..709b5b209 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/exif.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/exif.dart @@ -12,39 +12,33 @@ import '../serializers.dart'; part 'exif.g.dart'; abstract class Exif implements Built { - factory Exif([void Function(ExifBuilder) updates]) = _$Exif; + factory Exif([void Function(ExifBuilder)? updates]) = _$Exif; Exif._(); - @nullable @BuiltValueField(wireName: 'make') - String get make; + String? get make; - @nullable @BuiltValueField(wireName: 'model') - String get model; + String? get model; - @nullable @BuiltValueField(wireName: 'exposure_time') - String get exposureTime; + String? get exposureTime; - @nullable @BuiltValueField(wireName: 'aperture') - String get aperture; + String? get aperture; - @nullable @BuiltValueField(wireName: 'focal_length') - String get focalLength; + String? get focalLength; - @nullable @BuiltValueField(wireName: 'iso') - int get iso; + int? get iso; String toJson() { return json.encode(serializers.serializeWith(Exif.serializer, this)); } - static Exif fromJson(String jsonString) { + static Exif? fromJson(String jsonString) { return serializers.deserializeWith( Exif.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/exif.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/exif.g.dart index 5456e90df..207e37d2e 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/exif.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/exif.g.dart @@ -19,10 +19,10 @@ class _$ExifSerializer implements StructuredSerializer { final String wireName = 'Exif'; @override - Iterable serialize(Serializers serializers, Exif object, + Iterable serialize(Serializers serializers, Exif object, {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object value; + final result = []; + Object? value; value = object.make; if (value != null) { result @@ -68,7 +68,7 @@ class _$ExifSerializer implements StructuredSerializer { } @override - Exif deserialize(Serializers serializers, Iterable serialized, + Exif deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new ExifBuilder(); @@ -76,7 +76,7 @@ class _$ExifSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'make': result.make = serializers.deserialize(value, @@ -111,19 +111,19 @@ class _$ExifSerializer implements StructuredSerializer { class _$Exif extends Exif { @override - final String make; + final String? make; @override - final String model; + final String? model; @override - final String exposureTime; + final String? exposureTime; @override - final String aperture; + final String? aperture; @override - final String focalLength; + final String? focalLength; @override - final int iso; + final int? iso; - factory _$Exif([void Function(ExifBuilder) updates]) => + factory _$Exif([void Function(ExifBuilder)? updates]) => (new ExifBuilder()..update(updates)).build(); _$Exif._( @@ -180,31 +180,31 @@ class _$Exif extends Exif { } class ExifBuilder implements Builder { - _$Exif _$v; + _$Exif? _$v; - String _make; - String get make => _$this._make; - set make(String make) => _$this._make = make; + String? _make; + String? get make => _$this._make; + set make(String? make) => _$this._make = make; - String _model; - String get model => _$this._model; - set model(String model) => _$this._model = model; + String? _model; + String? get model => _$this._model; + set model(String? model) => _$this._model = model; - String _exposureTime; - String get exposureTime => _$this._exposureTime; - set exposureTime(String exposureTime) => _$this._exposureTime = exposureTime; + String? _exposureTime; + String? get exposureTime => _$this._exposureTime; + set exposureTime(String? exposureTime) => _$this._exposureTime = exposureTime; - String _aperture; - String get aperture => _$this._aperture; - set aperture(String aperture) => _$this._aperture = aperture; + String? _aperture; + String? get aperture => _$this._aperture; + set aperture(String? aperture) => _$this._aperture = aperture; - String _focalLength; - String get focalLength => _$this._focalLength; - set focalLength(String focalLength) => _$this._focalLength = focalLength; + String? _focalLength; + String? get focalLength => _$this._focalLength; + set focalLength(String? focalLength) => _$this._focalLength = focalLength; - int _iso; - int get iso => _$this._iso; - set iso(int iso) => _$this._iso = iso; + int? _iso; + int? get iso => _$this._iso; + set iso(int? iso) => _$this._iso = iso; ExifBuilder(); @@ -229,7 +229,7 @@ class ExifBuilder implements Builder { } @override - void update(void Function(ExifBuilder) updates) { + void update(void Function(ExifBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/links.dart b/experimental/desktop_photo_search/lib/src/unsplash/links.dart index d51fd1406..612195b1b 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/links.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/links.dart @@ -12,31 +12,27 @@ import '../serializers.dart'; part 'links.g.dart'; abstract class Links implements Built { - factory Links([void Function(LinksBuilder) updates]) = _$Links; + factory Links([void Function(LinksBuilder)? updates]) = _$Links; Links._(); - @nullable @BuiltValueField(wireName: 'self') - String get self; + String? get self; - @nullable @BuiltValueField(wireName: 'html') - String get html; + String? get html; - @nullable @BuiltValueField(wireName: 'download') - String get download; + String? get download; - @nullable @BuiltValueField(wireName: 'download_location') - String get downloadLocation; + String? get downloadLocation; String toJson() { return json.encode(serializers.serializeWith(Links.serializer, this)); } - static Links fromJson(String jsonString) { + static Links? fromJson(String jsonString) { return serializers.deserializeWith( Links.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/links.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/links.g.dart index fa97b21e9..52c1fd4e8 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/links.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/links.g.dart @@ -19,10 +19,10 @@ class _$LinksSerializer implements StructuredSerializer { final String wireName = 'Links'; @override - Iterable serialize(Serializers serializers, Links object, + Iterable serialize(Serializers serializers, Links object, {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object value; + final result = []; + Object? value; value = object.self; if (value != null) { result @@ -55,7 +55,7 @@ class _$LinksSerializer implements StructuredSerializer { } @override - Links deserialize(Serializers serializers, Iterable serialized, + Links deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new LinksBuilder(); @@ -63,7 +63,7 @@ class _$LinksSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'self': result.self = serializers.deserialize(value, @@ -90,15 +90,15 @@ class _$LinksSerializer implements StructuredSerializer { class _$Links extends Links { @override - final String self; + final String? self; @override - final String html; + final String? html; @override - final String download; + final String? download; @override - final String downloadLocation; + final String? downloadLocation; - factory _$Links([void Function(LinksBuilder) updates]) => + factory _$Links([void Function(LinksBuilder)? updates]) => (new LinksBuilder()..update(updates)).build(); _$Links._({this.self, this.html, this.download, this.downloadLocation}) @@ -140,23 +140,23 @@ class _$Links extends Links { } class LinksBuilder implements Builder { - _$Links _$v; + _$Links? _$v; - String _self; - String get self => _$this._self; - set self(String self) => _$this._self = self; + String? _self; + String? get self => _$this._self; + set self(String? self) => _$this._self = self; - String _html; - String get html => _$this._html; - set html(String html) => _$this._html = html; + String? _html; + String? get html => _$this._html; + set html(String? html) => _$this._html = html; - String _download; - String get download => _$this._download; - set download(String download) => _$this._download = download; + String? _download; + String? get download => _$this._download; + set download(String? download) => _$this._download = download; - String _downloadLocation; - String get downloadLocation => _$this._downloadLocation; - set downloadLocation(String downloadLocation) => + String? _downloadLocation; + String? get downloadLocation => _$this._downloadLocation; + set downloadLocation(String? downloadLocation) => _$this._downloadLocation = downloadLocation; LinksBuilder(); @@ -180,7 +180,7 @@ class LinksBuilder implements Builder { } @override - void update(void Function(LinksBuilder) updates) { + void update(void Function(LinksBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/location.dart b/experimental/desktop_photo_search/lib/src/unsplash/location.dart index 85c06cd1e..e426bef97 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/location.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/location.dart @@ -13,27 +13,24 @@ import 'position.dart'; part 'location.g.dart'; abstract class Location implements Built { - factory Location([void Function(LocationBuilder) updates]) = _$Location; + factory Location([void Function(LocationBuilder)? updates]) = _$Location; Location._(); - @nullable @BuiltValueField(wireName: 'city') - String get city; + String? get city; - @nullable @BuiltValueField(wireName: 'country') - String get country; + String? get country; - @nullable @BuiltValueField(wireName: 'position') - Position get position; + Position? get position; String toJson() { return json.encode(serializers.serializeWith(Location.serializer, this)); } - static Location fromJson(String jsonString) { + static Location? fromJson(String jsonString) { return serializers.deserializeWith( Location.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/location.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/location.g.dart index 6115809ba..9e6ed7d06 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/location.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/location.g.dart @@ -19,10 +19,10 @@ class _$LocationSerializer implements StructuredSerializer { final String wireName = 'Location'; @override - Iterable serialize(Serializers serializers, Location object, + Iterable serialize(Serializers serializers, Location object, {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object value; + final result = []; + Object? value; value = object.city; if (value != null) { result @@ -48,7 +48,7 @@ class _$LocationSerializer implements StructuredSerializer { } @override - Location deserialize(Serializers serializers, Iterable serialized, + Location deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new LocationBuilder(); @@ -56,7 +56,7 @@ class _$LocationSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'city': result.city = serializers.deserialize(value, @@ -68,7 +68,7 @@ class _$LocationSerializer implements StructuredSerializer { break; case 'position': result.position.replace(serializers.deserialize(value, - specifiedType: const FullType(Position)) as Position); + specifiedType: const FullType(Position))! as Position); break; } } @@ -79,13 +79,13 @@ class _$LocationSerializer implements StructuredSerializer { class _$Location extends Location { @override - final String city; + final String? city; @override - final String country; + final String? country; @override - final Position position; + final Position? position; - factory _$Location([void Function(LocationBuilder) updates]) => + factory _$Location([void Function(LocationBuilder)? updates]) => (new LocationBuilder()..update(updates)).build(); _$Location._({this.city, this.country, this.position}) : super._(); @@ -123,19 +123,19 @@ class _$Location extends Location { } class LocationBuilder implements Builder { - _$Location _$v; + _$Location? _$v; - String _city; - String get city => _$this._city; - set city(String city) => _$this._city = city; + String? _city; + String? get city => _$this._city; + set city(String? city) => _$this._city = city; - String _country; - String get country => _$this._country; - set country(String country) => _$this._country = country; + String? _country; + String? get country => _$this._country; + set country(String? country) => _$this._country = country; - PositionBuilder _position; + PositionBuilder? _position; PositionBuilder get position => _$this._position ??= new PositionBuilder(); - set position(PositionBuilder position) => _$this._position = position; + set position(PositionBuilder? position) => _$this._position = position; LocationBuilder(); @@ -157,7 +157,7 @@ class LocationBuilder implements Builder { } @override - void update(void Function(LocationBuilder) updates) { + void update(void Function(LocationBuilder)? updates) { if (updates != null) updates(this); } @@ -169,7 +169,7 @@ class LocationBuilder implements Builder { new _$Location._( city: city, country: country, position: _position?.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'position'; _position?.build(); diff --git a/experimental/desktop_photo_search/lib/src/unsplash/photo.dart b/experimental/desktop_photo_search/lib/src/unsplash/photo.dart index 927bf4535..e303fad4c 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/photo.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/photo.dart @@ -20,82 +20,66 @@ import 'user.dart'; part 'photo.g.dart'; abstract class Photo implements Built { - factory Photo([void Function(PhotoBuilder) updates]) = _$Photo; + factory Photo([void Function(PhotoBuilder)? updates]) = _$Photo; Photo._(); @BuiltValueField(wireName: 'id') String get id; - @nullable @BuiltValueField(wireName: 'created_at') - String get createdAt; + String? get createdAt; - @nullable @BuiltValueField(wireName: 'updated_at') - String get updatedAt; + String? get updatedAt; - @nullable @BuiltValueField(wireName: 'width') - int get width; + int? get width; - @nullable @BuiltValueField(wireName: 'height') - int get height; + int? get height; - @nullable @BuiltValueField(wireName: 'color') - String get color; + String? get color; - @nullable @BuiltValueField(wireName: 'downloads') - int get downloads; + int? get downloads; - @nullable @BuiltValueField(wireName: 'likes') - int get likes; + int? get likes; - @nullable @BuiltValueField(wireName: 'liked_by_user') - bool get likedByUser; + bool? get likedByUser; - @nullable @BuiltValueField(wireName: 'description') - String get description; + String? get description; - @nullable @BuiltValueField(wireName: 'exif') - Exif get exif; + Exif? get exif; - @nullable @BuiltValueField(wireName: 'location') - Location get location; + Location? get location; - @nullable @BuiltValueField(wireName: 'tags') - BuiltList get tags; + BuiltList? get tags; - @nullable @BuiltValueField(wireName: 'current_user_collections') - BuiltList get currentUserCollections; + BuiltList? get currentUserCollections; - @nullable @BuiltValueField(wireName: 'urls') - Urls get urls; + Urls? get urls; - @nullable @BuiltValueField(wireName: 'links') - Links get links; + Links? get links; - @nullable @BuiltValueField(wireName: 'user') - User get user; + User? get user; String toJson() { return json.encode(serializers.serializeWith(Photo.serializer, this)); } - static Photo fromJson(String jsonString) { + static Photo? fromJson(String jsonString) { return serializers.deserializeWith( Photo.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/photo.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/photo.g.dart index dc399f22b..b879eb2a9 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/photo.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/photo.g.dart @@ -19,13 +19,13 @@ class _$PhotoSerializer implements StructuredSerializer { final String wireName = 'Photo'; @override - Iterable serialize(Serializers serializers, Photo object, + Iterable serialize(Serializers serializers, Photo object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'id', serializers.serialize(object.id, specifiedType: const FullType(String)), ]; - Object value; + Object? value; value = object.createdAt; if (value != null) { result @@ -140,7 +140,7 @@ class _$PhotoSerializer implements StructuredSerializer { } @override - Photo deserialize(Serializers serializers, Iterable serialized, + Photo deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new PhotoBuilder(); @@ -148,7 +148,7 @@ class _$PhotoSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'id': result.id = serializers.deserialize(value, @@ -192,35 +192,35 @@ class _$PhotoSerializer implements StructuredSerializer { break; case 'exif': result.exif.replace(serializers.deserialize(value, - specifiedType: const FullType(Exif)) as Exif); + specifiedType: const FullType(Exif))! as Exif); break; case 'location': result.location.replace(serializers.deserialize(value, - specifiedType: const FullType(Location)) as Location); + specifiedType: const FullType(Location))! as Location); break; case 'tags': result.tags.replace(serializers.deserialize(value, specifiedType: - const FullType(BuiltList, const [const FullType(Tags)])) + const FullType(BuiltList, const [const FullType(Tags)]))! as BuiltList); break; case 'current_user_collections': result.currentUserCollections.replace(serializers.deserialize(value, specifiedType: const FullType(BuiltList, const [ const FullType(CurrentUserCollections) - ])) as BuiltList); + ]))! as BuiltList); break; case 'urls': result.urls.replace(serializers.deserialize(value, - specifiedType: const FullType(Urls)) as Urls); + specifiedType: const FullType(Urls))! as Urls); break; case 'links': result.links.replace(serializers.deserialize(value, - specifiedType: const FullType(Links)) as Links); + specifiedType: const FullType(Links))! as Links); break; case 'user': result.user.replace(serializers.deserialize(value, - specifiedType: const FullType(User)) as User); + specifiedType: const FullType(User))! as User); break; } } @@ -233,43 +233,43 @@ class _$Photo extends Photo { @override final String id; @override - final String createdAt; + final String? createdAt; @override - final String updatedAt; + final String? updatedAt; @override - final int width; + final int? width; @override - final int height; + final int? height; @override - final String color; + final String? color; @override - final int downloads; + final int? downloads; @override - final int likes; + final int? likes; @override - final bool likedByUser; + final bool? likedByUser; @override - final String description; + final String? description; @override - final Exif exif; + final Exif? exif; @override - final Location location; + final Location? location; @override - final BuiltList tags; + final BuiltList? tags; @override - final BuiltList currentUserCollections; + final BuiltList? currentUserCollections; @override - final Urls urls; + final Urls? urls; @override - final Links links; + final Links? links; @override - final User user; + final User? user; - factory _$Photo([void Function(PhotoBuilder) updates]) => + factory _$Photo([void Function(PhotoBuilder)? updates]) => (new PhotoBuilder()..update(updates)).build(); _$Photo._( - {this.id, + {required this.id, this.createdAt, this.updatedAt, this.width, @@ -387,79 +387,79 @@ class _$Photo extends Photo { } class PhotoBuilder implements Builder { - _$Photo _$v; + _$Photo? _$v; - String _id; - String get id => _$this._id; - set id(String id) => _$this._id = id; + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; - String _createdAt; - String get createdAt => _$this._createdAt; - set createdAt(String createdAt) => _$this._createdAt = createdAt; + String? _createdAt; + String? get createdAt => _$this._createdAt; + set createdAt(String? createdAt) => _$this._createdAt = createdAt; - String _updatedAt; - String get updatedAt => _$this._updatedAt; - set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt; + String? _updatedAt; + String? get updatedAt => _$this._updatedAt; + set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt; - int _width; - int get width => _$this._width; - set width(int width) => _$this._width = width; + int? _width; + int? get width => _$this._width; + set width(int? width) => _$this._width = width; - int _height; - int get height => _$this._height; - set height(int height) => _$this._height = height; + int? _height; + int? get height => _$this._height; + set height(int? height) => _$this._height = height; - String _color; - String get color => _$this._color; - set color(String color) => _$this._color = color; + String? _color; + String? get color => _$this._color; + set color(String? color) => _$this._color = color; - int _downloads; - int get downloads => _$this._downloads; - set downloads(int downloads) => _$this._downloads = downloads; + int? _downloads; + int? get downloads => _$this._downloads; + set downloads(int? downloads) => _$this._downloads = downloads; - int _likes; - int get likes => _$this._likes; - set likes(int likes) => _$this._likes = likes; + int? _likes; + int? get likes => _$this._likes; + set likes(int? likes) => _$this._likes = likes; - bool _likedByUser; - bool get likedByUser => _$this._likedByUser; - set likedByUser(bool likedByUser) => _$this._likedByUser = likedByUser; + bool? _likedByUser; + bool? get likedByUser => _$this._likedByUser; + set likedByUser(bool? likedByUser) => _$this._likedByUser = likedByUser; - String _description; - String get description => _$this._description; - set description(String description) => _$this._description = description; + String? _description; + String? get description => _$this._description; + set description(String? description) => _$this._description = description; - ExifBuilder _exif; + ExifBuilder? _exif; ExifBuilder get exif => _$this._exif ??= new ExifBuilder(); - set exif(ExifBuilder exif) => _$this._exif = exif; + set exif(ExifBuilder? exif) => _$this._exif = exif; - LocationBuilder _location; + LocationBuilder? _location; LocationBuilder get location => _$this._location ??= new LocationBuilder(); - set location(LocationBuilder location) => _$this._location = location; + set location(LocationBuilder? location) => _$this._location = location; - ListBuilder _tags; + ListBuilder? _tags; ListBuilder get tags => _$this._tags ??= new ListBuilder(); - set tags(ListBuilder tags) => _$this._tags = tags; + set tags(ListBuilder? tags) => _$this._tags = tags; - ListBuilder _currentUserCollections; + ListBuilder? _currentUserCollections; ListBuilder get currentUserCollections => _$this._currentUserCollections ??= new ListBuilder(); set currentUserCollections( - ListBuilder currentUserCollections) => + ListBuilder? currentUserCollections) => _$this._currentUserCollections = currentUserCollections; - UrlsBuilder _urls; + UrlsBuilder? _urls; UrlsBuilder get urls => _$this._urls ??= new UrlsBuilder(); - set urls(UrlsBuilder urls) => _$this._urls = urls; + set urls(UrlsBuilder? urls) => _$this._urls = urls; - LinksBuilder _links; + LinksBuilder? _links; LinksBuilder get links => _$this._links ??= new LinksBuilder(); - set links(LinksBuilder links) => _$this._links = links; + set links(LinksBuilder? links) => _$this._links = links; - UserBuilder _user; + UserBuilder? _user; UserBuilder get user => _$this._user ??= new UserBuilder(); - set user(UserBuilder user) => _$this._user = user; + set user(UserBuilder? user) => _$this._user = user; PhotoBuilder(); @@ -495,7 +495,7 @@ class PhotoBuilder implements Builder { } @override - void update(void Function(PhotoBuilder) updates) { + void update(void Function(PhotoBuilder)? updates) { if (updates != null) updates(this); } @@ -523,7 +523,7 @@ class PhotoBuilder implements Builder { links: _links?.build(), user: _user?.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'exif'; _exif?.build(); diff --git a/experimental/desktop_photo_search/lib/src/unsplash/position.dart b/experimental/desktop_photo_search/lib/src/unsplash/position.dart index 9216a6ff3..4399eb23f 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/position.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/position.dart @@ -12,7 +12,7 @@ import '../serializers.dart'; part 'position.g.dart'; abstract class Position implements Built { - factory Position([void Function(PositionBuilder) updates]) = _$Position; + factory Position([void Function(PositionBuilder)? updates]) = _$Position; Position._(); @@ -26,7 +26,7 @@ abstract class Position implements Built { return json.encode(serializers.serializeWith(Position.serializer, this)); } - static Position fromJson(String jsonString) { + static Position? fromJson(String jsonString) { return serializers.deserializeWith( Position.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/position.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/position.g.dart index df9e51afc..be7d15523 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/position.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/position.g.dart @@ -19,9 +19,9 @@ class _$PositionSerializer implements StructuredSerializer { final String wireName = 'Position'; @override - Iterable serialize(Serializers serializers, Position object, + Iterable serialize(Serializers serializers, Position object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'latitude', serializers.serialize(object.latitude, specifiedType: const FullType(double)), @@ -34,7 +34,7 @@ class _$PositionSerializer implements StructuredSerializer { } @override - Position deserialize(Serializers serializers, Iterable serialized, + Position deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new PositionBuilder(); @@ -42,7 +42,7 @@ class _$PositionSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'latitude': result.latitude = serializers.deserialize(value, @@ -65,10 +65,10 @@ class _$Position extends Position { @override final double longitude; - factory _$Position([void Function(PositionBuilder) updates]) => + factory _$Position([void Function(PositionBuilder)? updates]) => (new PositionBuilder()..update(updates)).build(); - _$Position._({this.latitude, this.longitude}) : super._() { + _$Position._({required this.latitude, required this.longitude}) : super._() { BuiltValueNullFieldError.checkNotNull(latitude, 'Position', 'latitude'); BuiltValueNullFieldError.checkNotNull(longitude, 'Position', 'longitude'); } @@ -103,15 +103,15 @@ class _$Position extends Position { } class PositionBuilder implements Builder { - _$Position _$v; + _$Position? _$v; - double _latitude; - double get latitude => _$this._latitude; - set latitude(double latitude) => _$this._latitude = latitude; + double? _latitude; + double? get latitude => _$this._latitude; + set latitude(double? latitude) => _$this._latitude = latitude; - double _longitude; - double get longitude => _$this._longitude; - set longitude(double longitude) => _$this._longitude = longitude; + double? _longitude; + double? get longitude => _$this._longitude; + set longitude(double? longitude) => _$this._longitude = longitude; PositionBuilder(); @@ -132,7 +132,7 @@ class PositionBuilder implements Builder { } @override - void update(void Function(PositionBuilder) updates) { + void update(void Function(PositionBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.dart b/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.dart index 4b3d56989..2d4905024 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.dart @@ -16,18 +16,16 @@ part 'search_photos_response.g.dart'; abstract class SearchPhotosResponse implements Built { factory SearchPhotosResponse( - [void Function(SearchPhotosResponseBuilder) updates]) = + [void Function(SearchPhotosResponseBuilder)? updates]) = _$SearchPhotosResponse; SearchPhotosResponse._(); - @nullable @BuiltValueField(wireName: 'total') - int get total; + int? get total; - @nullable @BuiltValueField(wireName: 'total_pages') - int get totalPages; + int? get totalPages; @BuiltValueField(wireName: 'results') BuiltList get results; @@ -37,7 +35,7 @@ abstract class SearchPhotosResponse serializers.serializeWith(SearchPhotosResponse.serializer, this)); } - static SearchPhotosResponse fromJson(String jsonString) { + static SearchPhotosResponse? fromJson(String jsonString) { return serializers.deserializeWith( SearchPhotosResponse.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.g.dart index 29c4f2fd3..b1ab455bf 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/search_photos_response.g.dart @@ -24,16 +24,16 @@ class _$SearchPhotosResponseSerializer final String wireName = 'SearchPhotosResponse'; @override - Iterable serialize( + Iterable serialize( Serializers serializers, SearchPhotosResponse object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'results', serializers.serialize(object.results, specifiedType: const FullType(BuiltList, const [const FullType(Photo)])), ]; - Object value; + Object? value; value = object.total; if (value != null) { result @@ -51,7 +51,7 @@ class _$SearchPhotosResponseSerializer @override SearchPhotosResponse deserialize( - Serializers serializers, Iterable serialized, + Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new SearchPhotosResponseBuilder(); @@ -59,7 +59,7 @@ class _$SearchPhotosResponseSerializer while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'total': result.total = serializers.deserialize(value, @@ -72,7 +72,7 @@ class _$SearchPhotosResponseSerializer case 'results': result.results.replace(serializers.deserialize(value, specifiedType: - const FullType(BuiltList, const [const FullType(Photo)])) + const FullType(BuiltList, const [const FullType(Photo)]))! as BuiltList); break; } @@ -84,17 +84,17 @@ class _$SearchPhotosResponseSerializer class _$SearchPhotosResponse extends SearchPhotosResponse { @override - final int total; + final int? total; @override - final int totalPages; + final int? totalPages; @override final BuiltList results; factory _$SearchPhotosResponse( - [void Function(SearchPhotosResponseBuilder) updates]) => + [void Function(SearchPhotosResponseBuilder)? updates]) => (new SearchPhotosResponseBuilder()..update(updates)).build(); - _$SearchPhotosResponse._({this.total, this.totalPages, this.results}) + _$SearchPhotosResponse._({this.total, this.totalPages, required this.results}) : super._() { BuiltValueNullFieldError.checkNotNull( results, 'SearchPhotosResponse', 'results'); @@ -136,20 +136,20 @@ class _$SearchPhotosResponse extends SearchPhotosResponse { class SearchPhotosResponseBuilder implements Builder { - _$SearchPhotosResponse _$v; + _$SearchPhotosResponse? _$v; - int _total; - int get total => _$this._total; - set total(int total) => _$this._total = total; + int? _total; + int? get total => _$this._total; + set total(int? total) => _$this._total = total; - int _totalPages; - int get totalPages => _$this._totalPages; - set totalPages(int totalPages) => _$this._totalPages = totalPages; + int? _totalPages; + int? get totalPages => _$this._totalPages; + set totalPages(int? totalPages) => _$this._totalPages = totalPages; - ListBuilder _results; + ListBuilder? _results; ListBuilder get results => _$this._results ??= new ListBuilder(); - set results(ListBuilder results) => _$this._results = results; + set results(ListBuilder? results) => _$this._results = results; SearchPhotosResponseBuilder(); @@ -171,7 +171,7 @@ class SearchPhotosResponseBuilder } @override - void update(void Function(SearchPhotosResponseBuilder) updates) { + void update(void Function(SearchPhotosResponseBuilder)? updates) { if (updates != null) updates(this); } @@ -183,7 +183,7 @@ class SearchPhotosResponseBuilder new _$SearchPhotosResponse._( total: total, totalPages: totalPages, results: results.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'results'; results.build(); diff --git a/experimental/desktop_photo_search/lib/src/unsplash/tags.dart b/experimental/desktop_photo_search/lib/src/unsplash/tags.dart index 707ce5e37..0073a6f34 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/tags.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/tags.dart @@ -12,7 +12,7 @@ import '../serializers.dart'; part 'tags.g.dart'; abstract class Tags implements Built { - factory Tags([void Function(TagsBuilder) updates]) = _$Tags; + factory Tags([void Function(TagsBuilder)? updates]) = _$Tags; Tags._(); @@ -23,7 +23,7 @@ abstract class Tags implements Built { return json.encode(serializers.serializeWith(Tags.serializer, this)); } - static Tags fromJson(String jsonString) { + static Tags? fromJson(String jsonString) { return serializers.deserializeWith( Tags.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/tags.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/tags.g.dart index f8bcca47b..7d4d949d3 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/tags.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/tags.g.dart @@ -19,9 +19,9 @@ class _$TagsSerializer implements StructuredSerializer { final String wireName = 'Tags'; @override - Iterable serialize(Serializers serializers, Tags object, + Iterable serialize(Serializers serializers, Tags object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'title', serializers.serialize(object.title, specifiedType: const FullType(String)), @@ -31,7 +31,7 @@ class _$TagsSerializer implements StructuredSerializer { } @override - Tags deserialize(Serializers serializers, Iterable serialized, + Tags deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new TagsBuilder(); @@ -39,7 +39,7 @@ class _$TagsSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'title': result.title = serializers.deserialize(value, @@ -56,10 +56,10 @@ class _$Tags extends Tags { @override final String title; - factory _$Tags([void Function(TagsBuilder) updates]) => + factory _$Tags([void Function(TagsBuilder)? updates]) => (new TagsBuilder()..update(updates)).build(); - _$Tags._({this.title}) : super._() { + _$Tags._({required this.title}) : super._() { BuiltValueNullFieldError.checkNotNull(title, 'Tags', 'title'); } @@ -89,11 +89,11 @@ class _$Tags extends Tags { } class TagsBuilder implements Builder { - _$Tags _$v; + _$Tags? _$v; - String _title; - String get title => _$this._title; - set title(String title) => _$this._title = title; + String? _title; + String? get title => _$this._title; + set title(String? title) => _$this._title = title; TagsBuilder(); @@ -113,7 +113,7 @@ class TagsBuilder implements Builder { } @override - void update(void Function(TagsBuilder) updates) { + void update(void Function(TagsBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/unsplash.dart b/experimental/desktop_photo_search/lib/src/unsplash/unsplash.dart index e7cad6183..4201d5e06 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/unsplash.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/unsplash.dart @@ -7,7 +7,6 @@ import 'dart:typed_data'; import 'package:http/http.dart' as http; import 'package:logging/logging.dart'; -import 'package:meta/meta.dart'; import 'package:pedantic/pedantic.dart'; import 'api_error.dart'; @@ -21,30 +20,28 @@ final _unsplashBaseUrl = Uri.parse('https://api.unsplash.com/'); /// requests to the Unsplash API. class Unsplash { Unsplash({ - @required String accessKey, - http.BaseClient httpClient, - }) : assert(accessKey != null, 'accessKey must not be null'), - _accessKey = accessKey, + required String accessKey, + http.BaseClient? httpClient, + }) : _accessKey = accessKey, _client = httpClient ?? http.Client(); final String _accessKey; final http.Client _client; final _log = Logger('Unsplash'); - Future searchPhotos({ - @required String query, + Future searchPhotos({ + required String query, num page = 1, num perPage = 10, List collections = const [], - SearchPhotosOrientation orientation, + SearchPhotosOrientation? orientation, }) async { final searchPhotosUrl = _unsplashBaseUrl .replace(path: '/search/photos', queryParameters: { 'query': query, if (page != 1) 'page': '$page', if (perPage != 10) 'per_page': '$perPage', - if (collections != null && collections.isNotEmpty) - 'collections': '${collections.join(',')}', + if (collections.isNotEmpty) 'collections': collections.join(','), if (orientation == SearchPhotosOrientation.landscape) 'orientation': 'landscape', if (orientation == SearchPhotosOrientation.portrait) @@ -72,8 +69,8 @@ class Unsplash { if (body is Map && body['errors'] is List && body['errors'].isNotEmpty as bool) { - final apiError = ApiError.fromJson(response.body); - throw UnsplashException(apiError.errors.join(', ')); + final apiError = ApiError.fromJson(response.body)!; + throw UnsplashException(apiError.errors!.join(', ')); } return SearchPhotosResponse.fromJson( @@ -85,14 +82,14 @@ class Unsplash { // For detail on how downloading photos from Unsplash, please see // https://help.unsplash.com/en/articles/2511258-guideline-triggering-a-download - _log.info('GET ${photo.urls.full}'); - final futureBytes = http.readBytes(Uri.parse(photo.urls.full), headers: { + _log.info('GET ${photo.urls!.full}'); + final futureBytes = http.readBytes(Uri.parse(photo.urls!.full!), headers: { 'Accept-Version': 'v1', 'Authorization': 'Client-ID $_accessKey', }); - _log.info('GET ${photo.links.downloadLocation}'); - unawaited(http.get(Uri.parse(photo.links.downloadLocation), headers: { + _log.info('GET ${photo.links!.downloadLocation}'); + unawaited(http.get(Uri.parse(photo.links!.downloadLocation!), headers: { 'Accept-Version': 'v1', 'Authorization': 'Client-ID $_accessKey', })); @@ -110,7 +107,7 @@ enum SearchPhotosOrientation { class UnsplashException implements Exception { UnsplashException([this.message]); - final String message; + final String? message; @override String toString() { diff --git a/experimental/desktop_photo_search/lib/src/unsplash/urls.dart b/experimental/desktop_photo_search/lib/src/unsplash/urls.dart index b7d8037a3..1a834304b 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/urls.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/urls.dart @@ -12,35 +12,30 @@ import '../serializers.dart'; part 'urls.g.dart'; abstract class Urls implements Built { - factory Urls([void Function(UrlsBuilder b) updates]) = _$Urls; + factory Urls([void Function(UrlsBuilder b)? updates]) = _$Urls; Urls._(); - @nullable @BuiltValueField(wireName: 'raw') - String get raw; + String? get raw; - @nullable @BuiltValueField(wireName: 'full') - String get full; + String? get full; - @nullable @BuiltValueField(wireName: 'regular') - String get regular; + String? get regular; - @nullable @BuiltValueField(wireName: 'small') - String get small; + String? get small; - @nullable @BuiltValueField(wireName: 'thumb') - String get thumb; + String? get thumb; String toJson() { return json.encode(serializers.serializeWith(Urls.serializer, this)); } - static Urls fromJson(String jsonString) { + static Urls? fromJson(String jsonString) { return serializers.deserializeWith( Urls.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/urls.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/urls.g.dart index 38f76a459..14b4d5213 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/urls.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/urls.g.dart @@ -19,10 +19,10 @@ class _$UrlsSerializer implements StructuredSerializer { final String wireName = 'Urls'; @override - Iterable serialize(Serializers serializers, Urls object, + Iterable serialize(Serializers serializers, Urls object, {FullType specifiedType = FullType.unspecified}) { - final result = []; - Object value; + final result = []; + Object? value; value = object.raw; if (value != null) { result @@ -62,7 +62,7 @@ class _$UrlsSerializer implements StructuredSerializer { } @override - Urls deserialize(Serializers serializers, Iterable serialized, + Urls deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new UrlsBuilder(); @@ -70,7 +70,7 @@ class _$UrlsSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'raw': result.raw = serializers.deserialize(value, @@ -101,17 +101,17 @@ class _$UrlsSerializer implements StructuredSerializer { class _$Urls extends Urls { @override - final String raw; + final String? raw; @override - final String full; + final String? full; @override - final String regular; + final String? regular; @override - final String small; + final String? small; @override - final String thumb; + final String? thumb; - factory _$Urls([void Function(UrlsBuilder) updates]) => + factory _$Urls([void Function(UrlsBuilder)? updates]) => (new UrlsBuilder()..update(updates)).build(); _$Urls._({this.raw, this.full, this.regular, this.small, this.thumb}) @@ -156,27 +156,27 @@ class _$Urls extends Urls { } class UrlsBuilder implements Builder { - _$Urls _$v; + _$Urls? _$v; - String _raw; - String get raw => _$this._raw; - set raw(String raw) => _$this._raw = raw; + String? _raw; + String? get raw => _$this._raw; + set raw(String? raw) => _$this._raw = raw; - String _full; - String get full => _$this._full; - set full(String full) => _$this._full = full; + String? _full; + String? get full => _$this._full; + set full(String? full) => _$this._full = full; - String _regular; - String get regular => _$this._regular; - set regular(String regular) => _$this._regular = regular; + String? _regular; + String? get regular => _$this._regular; + set regular(String? regular) => _$this._regular = regular; - String _small; - String get small => _$this._small; - set small(String small) => _$this._small = small; + String? _small; + String? get small => _$this._small; + set small(String? small) => _$this._small = small; - String _thumb; - String get thumb => _$this._thumb; - set thumb(String thumb) => _$this._thumb = thumb; + String? _thumb; + String? get thumb => _$this._thumb; + set thumb(String? thumb) => _$this._thumb = thumb; UrlsBuilder(); @@ -200,7 +200,7 @@ class UrlsBuilder implements Builder { } @override - void update(void Function(UrlsBuilder) updates) { + void update(void Function(UrlsBuilder)? updates) { if (updates != null) updates(this); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/user.dart b/experimental/desktop_photo_search/lib/src/unsplash/user.dart index f84d8b562..c8b141179 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/user.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/user.dart @@ -13,16 +13,15 @@ import 'links.dart'; part 'user.g.dart'; abstract class User implements Built { - factory User([void Function(UserBuilder) updates]) = _$User; + factory User([void Function(UserBuilder)? updates]) = _$User; User._(); @BuiltValueField(wireName: 'id') String get id; - @nullable @BuiltValueField(wireName: 'updated_at') - String get updatedAt; + String? get updatedAt; @BuiltValueField(wireName: 'username') String get username; @@ -30,39 +29,32 @@ abstract class User implements Built { @BuiltValueField(wireName: 'name') String get name; - @nullable @BuiltValueField(wireName: 'portfolio_url') - String get portfolioUrl; + String? get portfolioUrl; - @nullable @BuiltValueField(wireName: 'bio') - String get bio; + String? get bio; - @nullable @BuiltValueField(wireName: 'location') - String get location; + String? get location; - @nullable @BuiltValueField(wireName: 'total_likes') - int get totalLikes; + int? get totalLikes; - @nullable @BuiltValueField(wireName: 'total_photos') - int get totalPhotos; + int? get totalPhotos; - @nullable @BuiltValueField(wireName: 'total_collections') - int get totalCollections; + int? get totalCollections; - @nullable @BuiltValueField(wireName: 'links') - Links get links; + Links? get links; String toJson() { return json.encode(serializers.serializeWith(User.serializer, this)); } - static User fromJson(String jsonString) { + static User? fromJson(String jsonString) { return serializers.deserializeWith( User.serializer, json.decode(jsonString)); } diff --git a/experimental/desktop_photo_search/lib/src/unsplash/user.g.dart b/experimental/desktop_photo_search/lib/src/unsplash/user.g.dart index d3bc02759..2aa30d209 100644 --- a/experimental/desktop_photo_search/lib/src/unsplash/user.g.dart +++ b/experimental/desktop_photo_search/lib/src/unsplash/user.g.dart @@ -19,9 +19,9 @@ class _$UserSerializer implements StructuredSerializer { final String wireName = 'User'; @override - Iterable serialize(Serializers serializers, User object, + Iterable serialize(Serializers serializers, User object, {FullType specifiedType = FullType.unspecified}) { - final result = [ + final result = [ 'id', serializers.serialize(object.id, specifiedType: const FullType(String)), 'username', @@ -30,7 +30,7 @@ class _$UserSerializer implements StructuredSerializer { 'name', serializers.serialize(object.name, specifiedType: const FullType(String)), ]; - Object value; + Object? value; value = object.updatedAt; if (value != null) { result @@ -88,7 +88,7 @@ class _$UserSerializer implements StructuredSerializer { } @override - User deserialize(Serializers serializers, Iterable serialized, + User deserialize(Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new UserBuilder(); @@ -96,7 +96,7 @@ class _$UserSerializer implements StructuredSerializer { while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'id': result.id = serializers.deserialize(value, @@ -140,7 +140,7 @@ class _$UserSerializer implements StructuredSerializer { break; case 'links': result.links.replace(serializers.deserialize(value, - specifiedType: const FullType(Links)) as Links); + specifiedType: const FullType(Links))! as Links); break; } } @@ -153,34 +153,34 @@ class _$User extends User { @override final String id; @override - final String updatedAt; + final String? updatedAt; @override final String username; @override final String name; @override - final String portfolioUrl; + final String? portfolioUrl; @override - final String bio; + final String? bio; @override - final String location; + final String? location; @override - final int totalLikes; + final int? totalLikes; @override - final int totalPhotos; + final int? totalPhotos; @override - final int totalCollections; + final int? totalCollections; @override - final Links links; + final Links? links; - factory _$User([void Function(UserBuilder) updates]) => + factory _$User([void Function(UserBuilder)? updates]) => (new UserBuilder()..update(updates)).build(); _$User._( - {this.id, + {required this.id, this.updatedAt, - this.username, - this.name, + required this.username, + required this.name, this.portfolioUrl, this.bio, this.location, @@ -261,52 +261,52 @@ class _$User extends User { } class UserBuilder implements Builder { - _$User _$v; + _$User? _$v; - String _id; - String get id => _$this._id; - set id(String id) => _$this._id = id; + String? _id; + String? get id => _$this._id; + set id(String? id) => _$this._id = id; - String _updatedAt; - String get updatedAt => _$this._updatedAt; - set updatedAt(String updatedAt) => _$this._updatedAt = updatedAt; + String? _updatedAt; + String? get updatedAt => _$this._updatedAt; + set updatedAt(String? updatedAt) => _$this._updatedAt = updatedAt; - String _username; - String get username => _$this._username; - set username(String username) => _$this._username = username; + String? _username; + String? get username => _$this._username; + set username(String? username) => _$this._username = username; - String _name; - String get name => _$this._name; - set name(String name) => _$this._name = name; + String? _name; + String? get name => _$this._name; + set name(String? name) => _$this._name = name; - String _portfolioUrl; - String get portfolioUrl => _$this._portfolioUrl; - set portfolioUrl(String portfolioUrl) => _$this._portfolioUrl = portfolioUrl; + String? _portfolioUrl; + String? get portfolioUrl => _$this._portfolioUrl; + set portfolioUrl(String? portfolioUrl) => _$this._portfolioUrl = portfolioUrl; - String _bio; - String get bio => _$this._bio; - set bio(String bio) => _$this._bio = bio; + String? _bio; + String? get bio => _$this._bio; + set bio(String? bio) => _$this._bio = bio; - String _location; - String get location => _$this._location; - set location(String location) => _$this._location = location; + String? _location; + String? get location => _$this._location; + set location(String? location) => _$this._location = location; - int _totalLikes; - int get totalLikes => _$this._totalLikes; - set totalLikes(int totalLikes) => _$this._totalLikes = totalLikes; + int? _totalLikes; + int? get totalLikes => _$this._totalLikes; + set totalLikes(int? totalLikes) => _$this._totalLikes = totalLikes; - int _totalPhotos; - int get totalPhotos => _$this._totalPhotos; - set totalPhotos(int totalPhotos) => _$this._totalPhotos = totalPhotos; + int? _totalPhotos; + int? get totalPhotos => _$this._totalPhotos; + set totalPhotos(int? totalPhotos) => _$this._totalPhotos = totalPhotos; - int _totalCollections; - int get totalCollections => _$this._totalCollections; - set totalCollections(int totalCollections) => + int? _totalCollections; + int? get totalCollections => _$this._totalCollections; + set totalCollections(int? totalCollections) => _$this._totalCollections = totalCollections; - LinksBuilder _links; + LinksBuilder? _links; LinksBuilder get links => _$this._links ??= new LinksBuilder(); - set links(LinksBuilder links) => _$this._links = links; + set links(LinksBuilder? links) => _$this._links = links; UserBuilder(); @@ -336,7 +336,7 @@ class UserBuilder implements Builder { } @override - void update(void Function(UserBuilder) updates) { + void update(void Function(UserBuilder)? updates) { if (updates != null) updates(this); } @@ -359,7 +359,7 @@ class UserBuilder implements Builder { totalCollections: totalCollections, links: _links?.build()); } catch (_) { - String _$failedField; + late String _$failedField; try { _$failedField = 'links'; _links?.build(); diff --git a/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart b/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart index 5eb2e181d..f36de91bf 100644 --- a/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart +++ b/experimental/desktop_photo_search/lib/src/widgets/about_dialog.dart @@ -7,8 +7,8 @@ import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart' as url_launcher; class PolicyDialog extends StatelessWidget { - PolicyDialog({ - Key key, + const PolicyDialog({ + Key? key, this.radius = 8, }) : super(key: key); @@ -23,7 +23,7 @@ class PolicyDialog extends StatelessWidget { builder: (context) { var height = MediaQuery.of(context).size.height; var width = MediaQuery.of(context).size.width; - return Container( + return SizedBox( height: height / 4, width: width / 4, child: Column( @@ -41,16 +41,16 @@ class PolicyDialog extends StatelessWidget { textAlign: TextAlign.left, text: TextSpan( text: '• ', - style: TextStyle(color: Colors.black, fontSize: 18), + style: const TextStyle(color: Colors.black, fontSize: 18), children: [ TextSpan( text: 'https://policies.google.com/terms', - style: TextStyle( + style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.lightBlue), recognizer: TapGestureRecognizer() ..onTap = () async { - final url = 'https://policies.google.com/terms'; + const url = 'https://policies.google.com/terms'; if (await url_launcher.canLaunch(url)) { await url_launcher.launch(url); } @@ -63,16 +63,16 @@ class PolicyDialog extends StatelessWidget { textAlign: TextAlign.left, text: TextSpan( text: '• ', - style: TextStyle(color: Colors.black, fontSize: 18), + style: const TextStyle(color: Colors.black, fontSize: 18), children: [ TextSpan( text: 'https://unsplash.com/terms', - style: TextStyle( + style: const TextStyle( fontWeight: FontWeight.bold, color: Colors.lightBlue), recognizer: TapGestureRecognizer() ..onTap = () async { - final url = 'https://unsplash.com/terms'; + const url = 'https://unsplash.com/terms'; if (await url_launcher.canLaunch(url)) { await url_launcher.launch(url); } @@ -93,7 +93,7 @@ class PolicyDialog extends StatelessWidget { }, child: Text( 'CLOSE'.toUpperCase(), - style: TextStyle(fontSize: 20), + style: const TextStyle(fontSize: 20), ), ), ], diff --git a/experimental/desktop_photo_search/lib/src/widgets/photo_details.dart b/experimental/desktop_photo_search/lib/src/widgets/photo_details.dart index a4ab01dd2..9c5ca82b0 100644 --- a/experimental/desktop_photo_search/lib/src/widgets/photo_details.dart +++ b/experimental/desktop_photo_search/lib/src/widgets/photo_details.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; -import 'package:meta/meta.dart'; import 'package:transparent_image/transparent_image.dart'; import 'package:url_launcher/link.dart'; @@ -17,8 +16,8 @@ typedef PhotoDetailsPhotoSaveCallback = void Function(Photo); class PhotoDetails extends StatefulWidget { const PhotoDetails({ - @required this.photo, - @required this.onPhotoSave, + required this.photo, + required this.onPhotoSave, }); final Photo photo; final PhotoDetailsPhotoSaveCallback onPhotoSave; @@ -32,21 +31,21 @@ class _PhotoDetailsState extends State Widget _buildPhotoAttribution(BuildContext context) { return Row( children: [ - Text('Photo by '), + const Text('Photo by '), Link( uri: Uri.parse( - 'https://unsplash.com/@${widget.photo.user.username}?utm_source=$unsplashAppName&utm_medium=referral'), + 'https://unsplash.com/@${widget.photo.user!.username}?utm_source=$unsplashAppName&utm_medium=referral'), builder: (context, followLink) => TextButton( onPressed: followLink, - child: Text(widget.photo.user.name), + child: Text(widget.photo.user!.name), ), ), - Text(' on '), + const Text(' on '), Link( uri: _unsplashHomepage, builder: (context, followLink) => TextButton( onPressed: followLink, - child: Text('Unsplash'), + child: const Text('Unsplash'), ), ), ], @@ -65,22 +64,22 @@ class _PhotoDetailsState extends State const SizedBox(height: 16), Card( shape: ContinuousRectangleBorder( - side: BorderSide(color: Colors.black12), + side: const BorderSide(color: Colors.black12), borderRadius: BorderRadius.circular(4), ), child: AnimatedSize( vsync: this, - duration: Duration(milliseconds: 750), + duration: const Duration(milliseconds: 750), child: Padding( padding: const EdgeInsets.fromLTRB(16, 16, 16, 40), child: ConstrainedBox( - constraints: BoxConstraints( + constraints: const BoxConstraints( minWidth: 400, minHeight: 400, ), child: FadeInImage.memoryNetwork( placeholder: kTransparentImage, - image: widget.photo.urls.small, + image: widget.photo.urls!.small!, ), ), ), @@ -97,7 +96,7 @@ class _PhotoDetailsState extends State const SizedBox(width: 8), IconButton( visualDensity: VisualDensity.compact, - icon: Icon(Icons.cloud_download), + icon: const Icon(Icons.cloud_download), onPressed: () => widget.onPhotoSave(widget.photo), ), ], diff --git a/experimental/desktop_photo_search/lib/src/widgets/split.dart b/experimental/desktop_photo_search/lib/src/widgets/split.dart index 68be03408..95a2e30d1 100644 --- a/experimental/desktop_photo_search/lib/src/widgets/split.dart +++ b/experimental/desktop_photo_search/lib/src/widgets/split.dart @@ -24,15 +24,12 @@ import 'package:flutter/material.dart'; class Split extends StatefulWidget { /// Builds a split oriented along [axis]. const Split({ - Key key, - @required this.axis, - @required this.firstChild, - @required this.secondChild, - double initialFirstFraction, + Key? key, + required this.axis, + required this.firstChild, + required this.secondChild, + double? initialFirstFraction, }) : initialFirstFraction = initialFirstFraction ?? 0.5, - assert(axis != null), - assert(firstChild != null), - assert(secondChild != null), super(key: key); /// The main axis the children will lay out on. @@ -81,7 +78,7 @@ class Split extends StatefulWidget { } class _SplitState extends State { - double firstFraction; + late double firstFraction; double get secondFraction => 1 - firstFraction; @@ -111,9 +108,8 @@ class _SplitState extends State { var secondSize = axisSize * secondFraction; // Clamp the sizes to be sure there is enough space for the dividers. - firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider) as double; - secondSize = - secondSize.clamp(halfDivider, axisSize - halfDivider) as double; + firstSize = firstSize.clamp(halfDivider, axisSize - halfDivider); + secondSize = secondSize.clamp(halfDivider, axisSize - halfDivider); // Remove space from each child to place the divider in the middle. firstSize = firstSize - halfDivider; @@ -126,7 +122,7 @@ class _SplitState extends State { // Update the fraction of space consumed by the children, // being sure not to allocate any negative space. firstFraction += fractionalDelta; - firstFraction = firstFraction.clamp(0.0, 1.0) as double; + firstFraction = firstFraction.clamp(0.0, 1.0); }); } diff --git a/experimental/desktop_photo_search/macos/Podfile.lock b/experimental/desktop_photo_search/macos/Podfile.lock index a4e3b1f48..f98e4a07d 100644 --- a/experimental/desktop_photo_search/macos/Podfile.lock +++ b/experimental/desktop_photo_search/macos/Podfile.lock @@ -31,4 +31,4 @@ SPEC CHECKSUMS: PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c -COCOAPODS: 1.10.0 +COCOAPODS: 1.10.1 diff --git a/experimental/desktop_photo_search/pubspec.lock b/experimental/desktop_photo_search/pubspec.lock index aa99683e4..f9cdde5fc 100644 --- a/experimental/desktop_photo_search/pubspec.lock +++ b/experimental/desktop_photo_search/pubspec.lock @@ -7,28 +7,28 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "14.0.0" + version: "22.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.41.2" + version: "1.7.1" ansicolor: dependency: transitive description: name: ansicolor url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "2.0.1" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.1.1" async: dependency: "direct dev" description: @@ -49,42 +49,42 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "2.0.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.5" + version: "1.0.0" build_daemon: dependency: transitive description: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "2.1.10" + version: "3.0.0" build_resolvers: dependency: transitive description: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "2.0.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.11.1" + version: "2.0.4" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.1.7" + version: "7.0.0" built_collection: dependency: "direct main" description: @@ -98,14 +98,14 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.3" + version: "8.0.6" built_value_generator: dependency: "direct dev" description: name: built_value_generator url: "https://pub.dartlang.org" source: hosted - version: "8.0.3" + version: "8.0.6" characters: dependency: transitive description: @@ -126,14 +126,14 @@ packages: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" cli_util: dependency: transitive description: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" clock: dependency: transitive description: @@ -147,7 +147,7 @@ packages: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "4.0.0" collection: dependency: transitive description: @@ -175,21 +175,21 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" cupertino_icons: dependency: "direct main" description: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" dart_style: dependency: transitive description: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.12" + version: "2.0.1" fake_async: dependency: transitive description: @@ -203,7 +203,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.1" file_selector: dependency: "direct main" description: @@ -258,13 +258,20 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_simple_treeview: dependency: "direct main" description: name: flutter_simple_treeview url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "3.0.0-nullsafety.1" flutter_test: dependency: "direct dev" description: flutter @@ -275,41 +282,48 @@ packages: description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.1" graphs: dependency: transitive description: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "2.0.0" grinder: dependency: "direct dev" description: name: grinder url: "https://pub.dartlang.org" source: hosted - version: "0.8.6" + version: "0.9.0" http: dependency: "direct main" description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.0" + version: "0.13.3" http_multi_server: dependency: transitive description: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "3.0.1" http_parser: dependency: transitive description: @@ -317,20 +331,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.0" - intl: + injector: dependency: transitive description: - name: intl + name: injector url: "https://pub.dartlang.org" source: hosted - version: "0.16.1" + version: "2.0.0" io: dependency: transitive description: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.5" + version: "1.0.0" js: dependency: transitive description: @@ -344,14 +358,21 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.0.0" + version: "4.0.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: "direct main" description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "0.11.4" + version: "1.0.1" matcher: dependency: transitive description: @@ -364,7 +385,7 @@ packages: description: path: "plugins/menubar" ref: HEAD - resolved-ref: "7812516a5c1fc8ef379e244106953a2b534432b9" + resolved-ref: e48abe7c3e9ebfe0b81622167c5201d4e783bb81 url: "https://github.com/google/flutter-desktop-embedding.git" source: git version: "0.1.0" @@ -388,7 +409,7 @@ packages: name: msix url: "https://pub.dartlang.org" source: hosted - version: "0.1.19" + version: "2.1.2" nested: dependency: transitive description: @@ -396,27 +417,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.0.0" path: dependency: transitive description: @@ -425,7 +432,7 @@ packages: source: hosted version: "1.8.0" pedantic: - dependency: "direct main" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" @@ -465,28 +472,28 @@ packages: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.8" + version: "1.0.0" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "1.1.4" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.4+1" + version: "1.0.1" sky_engine: dependency: transitive description: flutter @@ -498,7 +505,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+3" + version: "1.0.1" source_span: dependency: transitive description: @@ -554,7 +561,7 @@ packages: name: timing url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+3" + version: "1.0.0" transparent_image: dependency: "direct main" description: @@ -575,7 +582,7 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.2" + version: "6.0.6" url_launcher_linux: dependency: transitive description: @@ -596,14 +603,14 @@ packages: name: url_launcher_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.2" + version: "2.0.3" url_launcher_web: dependency: transitive description: name: url_launcher_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" url_launcher_windows: dependency: transitive description: @@ -617,7 +624,7 @@ packages: name: uuid url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.0.4" vector_math: dependency: transitive description: @@ -638,14 +645,14 @@ packages: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.1.0" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" flutter: ">=2.0.0" diff --git a/experimental/desktop_photo_search/pubspec.yaml b/experimental/desktop_photo_search/pubspec.yaml index b213a03ee..a67b4e94c 100644 --- a/experimental/desktop_photo_search/pubspec.yaml +++ b/experimental/desktop_photo_search/pubspec.yaml @@ -4,7 +4,7 @@ version: 1.0.0+1 publish_to: none environment: - sdk: ^2.11.0 + sdk: '>=2.12.0 <3.0.0' flutter: ^2.0.0 dependencies: @@ -18,14 +18,13 @@ dependencies: file_selector_macos: ^0.0.1 file_selector_windows: ^0.0.1 http: ^0.13.0 - logging: ^0.11.3+2 - flutter_simple_treeview: ^2.0.1 + logging: ^1.0.1 + flutter_simple_treeview: ^3.0.0-nullsafety.1 menubar: git: url: https://github.com/google/flutter-desktop-embedding.git path: plugins/menubar meta: ^1.1.8 - pedantic: ^1.9.0 provider: ^5.0.0 transparent_image: ^2.0.0 uuid: ^3.0.1 @@ -35,12 +34,13 @@ dev_dependencies: flutter_test: sdk: flutter async: ^2.4.0 - build: ^1.2.2 - build_runner: ^1.10.4 + build: ^2.0.2 + build_runner: ^2.0.4 built_value_generator: ^8.0.3 - grinder: ^0.8.3 - msix: ^0.1.5 - source_gen: ^0.9.4 + grinder: ^0.9.0 + msix: ^2.1.2 + source_gen: ^1.0.1 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/experimental/desktop_photo_search/test/unsplash_test.dart b/experimental/desktop_photo_search/test/unsplash_test.dart index dea939e5f..41a2789f2 100644 --- a/experimental/desktop_photo_search/test/unsplash_test.dart +++ b/experimental/desktop_photo_search/test/unsplash_test.dart @@ -90,7 +90,7 @@ void main() { } '''; - final photo = Photo.fromJson(input); + final photo = Photo.fromJson(input)!; expect(photo.id, 'Dwu85P9SOIk'); expect(photo.createdAt, '2016-05-03T11:00:28-04:00'); expect(photo.updatedAt, '2016-07-10T11:00:01-05:00'); @@ -99,12 +99,12 @@ void main() { expect(photo.color, '#6E633A'); expect(photo.downloads, 1345); expect(photo.likedByUser, false); - expect(photo.exif.make, 'Canon'); - expect(photo.exif.iso, 100); - expect(photo.location.city, 'Montreal'); - expect(photo.location.country, 'Canada'); - expect(photo.location.position.latitude, 45.4732984); - expect(photo.location.position.longitude, -73.6384879); + expect(photo.exif!.make, 'Canon'); + expect(photo.exif!.iso, 100); + expect(photo.location!.city, 'Montreal'); + expect(photo.location!.country, 'Canada'); + expect(photo.location!.position!.latitude, 45.4732984); + expect(photo.location!.position!.longitude, -73.6384879); }); test('User.fromJson', () { @@ -149,7 +149,7 @@ void main() { } '''; - final user = User.fromJson(input); + final user = User.fromJson(input)!; expect(user.id, 'pXhwzz1JtQU'); }); @@ -207,11 +207,11 @@ void main() { } '''; - final response = SearchPhotosResponse.fromJson(input); + final response = SearchPhotosResponse.fromJson(input)!; expect(response.total, 133); expect(response.totalPages, 7); expect(response.results[0].id, 'eOLpJytrbsQ'); - expect(response.results[0].user.id, 'Ul0QVz12Goo'); + expect(response.results[0].user!.id, 'Ul0QVz12Goo'); }); group('Unsplash API client', () { @@ -283,12 +283,12 @@ void main() { httpClient: httpClient, ); - final response = await unsplashClient.searchPhotos(query: 'red'); + final response = (await unsplashClient.searchPhotos(query: 'red'))!; expect(response.total, 133); expect(response.totalPages, 7); expect(response.results[0].id, 'eOLpJytrbsQ'); - expect(response.results[0].user.id, 'Ul0QVz12Goo'); + expect(response.results[0].user!.id, 'Ul0QVz12Goo'); }); test('handles failure', () async { @@ -525,12 +525,12 @@ void main() { httpClient: httpClient, ); - final response = await unsplashClient.searchPhotos(query: 'red'); + final response = (await unsplashClient.searchPhotos(query: 'red'))!; expect(response.total, 22395); expect(response.totalPages, 2240); expect(response.results[0].id, 'E4u_Zo9PET8'); - expect(response.results[0].user.id, '_2nQcPrbyuE'); - expect(response.results[0].user.name, 'Sergiu Vălenaș'); + expect(response.results[0].user!.id, '_2nQcPrbyuE'); + expect(response.results[0].user!.name, 'Sergiu Vălenaș'); }); } diff --git a/experimental/desktop_photo_search/test/widget_test.dart b/experimental/desktop_photo_search/test/widget_test.dart index e72419bfe..e5ac95dab 100644 --- a/experimental/desktop_photo_search/test/widget_test.dart +++ b/experimental/desktop_photo_search/test/widget_test.dart @@ -67,12 +67,12 @@ class FakeUnsplash implements Unsplash { '''; @override - Future searchPhotos( - {String query, + Future searchPhotos( + {String? query, num page = 1, num perPage = 10, List collections = const [], - SearchPhotosOrientation orientation}) async { + SearchPhotosOrientation? orientation}) async { return SearchPhotosResponse.fromJson(searchPhotosResponse); } diff --git a/experimental/federated_plugin/federated_plugin/analysis_options.yaml b/experimental/federated_plugin/federated_plugin/analysis_options.yaml index b1535cc60..30ac27228 100644 --- a/experimental/federated_plugin/federated_plugin/analysis_options.yaml +++ b/experimental/federated_plugin/federated_plugin/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.11.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/experimental/federated_plugin/federated_plugin/example/lib/main.dart b/experimental/federated_plugin/federated_plugin/example/lib/main.dart index 5c1086fde..4cf60124e 100644 --- a/experimental/federated_plugin/federated_plugin/example/lib/main.dart +++ b/experimental/federated_plugin/federated_plugin/example/lib/main.dart @@ -33,19 +33,19 @@ class _HomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Federated Plugin Demo'), + title: const Text('Federated Plugin Demo'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ batteryLevel == null - ? SizedBox.shrink() + ? const SizedBox.shrink() : Text( 'Battery Level: $batteryLevel', style: Theme.of(context).textTheme.headline5, ), - SizedBox(height: 16), + const SizedBox(height: 16), ElevatedButton( onPressed: () async { try { @@ -64,7 +64,7 @@ class _HomePageState extends State { ); } }, - child: Text('Get Battery Level'), + child: const Text('Get Battery Level'), ), ], ), diff --git a/experimental/federated_plugin/federated_plugin/example/pubspec.lock b/experimental/federated_plugin/federated_plugin/example/pubspec.lock index e7a5d4a3a..37fa5041e 100644 --- a/experimental/federated_plugin/federated_plugin/example/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin/example/pubspec.lock @@ -97,6 +97,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -114,6 +121,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -135,13 +149,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" plugin_platform_interface: dependency: transitive description: diff --git a/experimental/federated_plugin/federated_plugin/example/pubspec.yaml b/experimental/federated_plugin/federated_plugin/example/pubspec.yaml index 3026d27d6..efc056523 100644 --- a/experimental/federated_plugin/federated_plugin/example/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin/example/pubspec.yaml @@ -1,7 +1,7 @@ name: federated_plugin_example description: Demonstrates how to use the federated_plugin plugin. -publish_to: 'none' # Remove this line if you wish to publish to pub.dev +publish_to: "none" # Remove this line if you wish to publish to pub.dev environment: sdk: ">=2.12.0 <3.0.0" @@ -17,7 +17,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart index 8998d87ff..a22356062 100644 --- a/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart +++ b/experimental/federated_plugin/federated_plugin/example/test/widget_test.dart @@ -9,9 +9,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { group('federated plugin demo tests', () { - final batteryLevel = 45; + const batteryLevel = 45; setUpAll(() { - MethodChannel('battery').setMockMethodCallHandler((call) async { + const MethodChannel('battery').setMockMethodCallHandler((call) async { if (call.method == 'getBatteryLevel') { return batteryLevel; } diff --git a/experimental/federated_plugin/federated_plugin/pubspec.lock b/experimental/federated_plugin/federated_plugin/pubspec.lock index 667b6a7ad..8bec5973b 100644 --- a/experimental/federated_plugin/federated_plugin/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin/pubspec.lock @@ -83,6 +83,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -100,6 +107,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -121,13 +135,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" plugin_platform_interface: dependency: transitive description: diff --git a/experimental/federated_plugin/federated_plugin/pubspec.yaml b/experimental/federated_plugin/federated_plugin/pubspec.yaml index 22a7ea2b9..a2be49b94 100644 --- a/experimental/federated_plugin/federated_plugin/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin/pubspec.yaml @@ -1,9 +1,8 @@ name: federated_plugin description: A new flutter plugin project to demonstrate how to implement federated plugin. version: 0.0.1 -homepage: -publish_to: 'none' +publish_to: "none" environment: sdk: ">=2.12.0 <3.0.0" @@ -24,7 +23,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 flutter: plugin: diff --git a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart index 0412af7e5..eba62999b 100644 --- a/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart +++ b/experimental/federated_plugin/federated_plugin/test/federated_plugin_test.dart @@ -10,8 +10,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('Federated Plugin Test', () { - final batteryLevel = 34; - MethodChannel('battery').setMockMethodCallHandler((call) async { + const batteryLevel = 34; + const MethodChannel('battery').setMockMethodCallHandler((call) async { if (call.method == 'getBatteryLevel') { return batteryLevel; } diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/analysis_options.yaml b/experimental/federated_plugin/federated_plugin_platform_interface/analysis_options.yaml index b1535cc60..30ac27228 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/analysis_options.yaml +++ b/experimental/federated_plugin/federated_plugin_platform_interface/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.11.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock index 83e4df8b3..7602896f3 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -55,11 +55,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -81,13 +95,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" plugin_platform_interface: dependency: "direct main" description: @@ -141,7 +148,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml index 702323e74..c3837ede6 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin_platform_interface/pubspec.yaml @@ -17,4 +17,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 diff --git a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart index 920694047..5b0f561ea 100644 --- a/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart +++ b/experimental/federated_plugin/federated_plugin_platform_interface/test/federated_plugin_platform_interface_test.dart @@ -10,8 +10,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('MethodChannel test', () { - final batteryLevel = 89; - MethodChannel('battery').setMockMethodCallHandler((call) async { + const batteryLevel = 89; + const MethodChannel('battery').setMockMethodCallHandler((call) async { if (call.method == 'getBatteryLevel') { return batteryLevel; } diff --git a/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml b/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml index b1535cc60..30ac27228 100644 --- a/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml +++ b/experimental/federated_plugin/federated_plugin_web/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.11.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/experimental/federated_plugin/federated_plugin_web/pubspec.lock b/experimental/federated_plugin/federated_plugin_web/pubspec.lock index 36ad7bc47..42aef24a7 100644 --- a/experimental/federated_plugin/federated_plugin_web/pubspec.lock +++ b/experimental/federated_plugin/federated_plugin_web/pubspec.lock @@ -7,14 +7,14 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "18.0.0" + version: "22.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.7.1" archive: dependency: transitive description: @@ -28,14 +28,14 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.1.1" async: dependency: transitive description: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -49,7 +49,7 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.2" built_collection: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.3" + version: "8.0.6" characters: dependency: transitive description: @@ -98,7 +98,7 @@ packages: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "3.7.0" + version: "4.0.0" collection: dependency: transitive description: @@ -119,14 +119,14 @@ packages: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "3.0.0" + version: "3.0.1" dart_style: dependency: transitive description: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.14" + version: "2.0.1" fake_async: dependency: transitive description: @@ -165,6 +165,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -186,7 +193,7 @@ packages: name: glob url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.1" integration_test: dependency: "direct dev" description: flutter @@ -199,13 +206,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" matcher: dependency: transitive description: @@ -226,7 +240,7 @@ packages: name: mockito url: "https://pub.dartlang.org" source: hosted - version: "5.0.2" + version: "5.0.9" package_config: dependency: transitive description: @@ -242,7 +256,7 @@ packages: source: hosted version: "1.8.0" pedantic: - dependency: "direct dev" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" @@ -268,7 +282,7 @@ packages: name: process url: "https://pub.dartlang.org" source: hosted - version: "4.1.0" + version: "4.2.1" pub_semver: dependency: transitive description: @@ -287,7 +301,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+4" + version: "1.0.1" source_span: dependency: transitive description: @@ -336,7 +350,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: @@ -357,7 +371,7 @@ packages: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "6.1.0+1" + version: "6.2.0" watcher: dependency: transitive description: diff --git a/experimental/federated_plugin/federated_plugin_web/pubspec.yaml b/experimental/federated_plugin/federated_plugin_web/pubspec.yaml index 5f103d7ea..952f9780e 100644 --- a/experimental/federated_plugin/federated_plugin_web/pubspec.yaml +++ b/experimental/federated_plugin/federated_plugin_web/pubspec.yaml @@ -1,7 +1,6 @@ name: federated_plugin_web description: Web implementation of federated_plugin to retrieve current battery level. version: 0.0.1 -homepage: publish_to: none environment: @@ -21,7 +20,7 @@ dev_dependencies: sdk: flutter integration_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 mockito: ^5.0.2 flutter: diff --git a/experimental/web_dashboard/analysis_options.yaml b/experimental/web_dashboard/analysis_options.yaml index dda88dcb3..42db08ec0 100644 --- a/experimental/web_dashboard/analysis_options.yaml +++ b/experimental/web_dashboard/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.8.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,16 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements \ No newline at end of file + avoid_print: false + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/experimental/web_dashboard/lib/src/api/firebase.dart b/experimental/web_dashboard/lib/src/api/firebase.dart index 5bdd981b5..443e39f23 100644 --- a/experimental/web_dashboard/lib/src/api/firebase.dart +++ b/experimental/web_dashboard/lib/src/api/firebase.dart @@ -28,10 +28,8 @@ class FirebaseEntryApi implements EntryApi { @override Stream> subscribe(String categoryId) { - var snapshots = _categoriesRef - .document('$categoryId') - .collection('entries') - .snapshots(); + var snapshots = + _categoriesRef.document(categoryId).collection('entries').snapshots(); var result = snapshots.map((querySnapshot) { return querySnapshot.documents.map((snapshot) { return Entry.fromJson(snapshot.data)..id = snapshot.documentID; @@ -54,7 +52,7 @@ class FirebaseEntryApi implements EntryApi { @override Future insert(String categoryId, Entry entry) async { var document = await _categoriesRef - .document('$categoryId') + .document(categoryId) .collection('entries') .add(entry.toJson()); return await get(categoryId, document.documentID); @@ -62,8 +60,7 @@ class FirebaseEntryApi implements EntryApi { @override Future> list(String categoryId) async { - var entriesRef = - _categoriesRef.document('$categoryId').collection('entries'); + var entriesRef = _categoriesRef.document(categoryId).collection('entries'); var querySnapshot = await entriesRef.getDocuments(); var entries = querySnapshot.documents .map((doc) => Entry.fromJson(doc.data)..id = doc.documentID) @@ -110,7 +107,7 @@ class FirebaseCategoryApi implements CategoryApi { @override Future delete(String id) async { - var document = _categoriesRef.document('$id'); + var document = _categoriesRef.document(id); var categories = await get(document.documentID); await document.delete(); @@ -120,7 +117,7 @@ class FirebaseCategoryApi implements CategoryApi { @override Future get(String id) async { - var document = _categoriesRef.document('$id'); + var document = _categoriesRef.document(id); var snapshot = await document.get(); return Category.fromJson(snapshot.data)..id = snapshot.documentID; } @@ -143,7 +140,7 @@ class FirebaseCategoryApi implements CategoryApi { @override Future update(Category category, String id) async { - var document = _categoriesRef.document('$id'); + var document = _categoriesRef.document(id); await document.setData(category.toJson()); var snapshot = await document.get(); return Category.fromJson(snapshot.data)..id = snapshot.documentID; diff --git a/experimental/web_dashboard/lib/src/api/mock.dart b/experimental/web_dashboard/lib/src/api/mock.dart index 6f47200c5..6303e2d25 100644 --- a/experimental/web_dashboard/lib/src/api/mock.dart +++ b/experimental/web_dashboard/lib/src/api/mock.dart @@ -20,11 +20,11 @@ class MockDashboardApi implements DashboardApi { /// Creates a [MockDashboardApi] filled with mock data for the last 30 days. Future fillWithMockData() async { - await Future.delayed(Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); var category1 = await categories.insert(Category('Coffee (oz)')); var category2 = await categories.insert(Category('Running (miles)')); var category3 = await categories.insert(Category('Git Commits')); - var monthAgo = DateTime.now().subtract(Duration(days: 30)); + var monthAgo = DateTime.now().subtract(const Duration(days: 30)); for (var category in [category1, category2, category3]) { for (var i = 0; i < 30; i++) { @@ -37,8 +37,8 @@ class MockDashboardApi implements DashboardApi { } class MockCategoryApi implements CategoryApi { - Map _storage = {}; - StreamController> _streamController = + final Map _storage = {}; + final StreamController> _streamController = StreamController>.broadcast(); @override @@ -74,6 +74,7 @@ class MockCategoryApi implements CategoryApi { return category..id = id; } + @override Stream> subscribe() => _streamController.stream; void _emit() { @@ -82,8 +83,8 @@ class MockCategoryApi implements CategoryApi { } class MockEntryApi implements EntryApi { - Map _storage = {}; - StreamController<_EntriesEvent> _streamController = + final Map _storage = {}; + final StreamController<_EntriesEvent> _streamController = StreamController.broadcast(); @override diff --git a/experimental/web_dashboard/lib/src/app.dart b/experimental/web_dashboard/lib/src/app.dart index 345759260..c5eed6636 100644 --- a/experimental/web_dashboard/lib/src/app.dart +++ b/experimental/web_dashboard/lib/src/app.dart @@ -26,14 +26,14 @@ class AppState { /// Creates a [DashboardApi] for the given user. This allows users of this /// widget to specify whether [MockDashboardApi] or [ApiBuilder] should be /// created when the user logs in. -typedef DashboardApi ApiBuilder(User user); +typedef ApiBuilder = DashboardApi Function(User user); /// An app that displays a personalized dashboard. class DashboardApp extends StatefulWidget { - static ApiBuilder _mockApiBuilder = - (user) => MockDashboardApi()..fillWithMockData(); - static ApiBuilder _apiBuilder = - (user) => FirebaseDashboardApi(Firestore.instance, user.uid); + static DashboardApi _mockApiBuilder(User user) => + MockDashboardApi()..fillWithMockData(); + static DashboardApi _apiBuilder(User user) => + FirebaseDashboardApi(Firestore.instance, user.uid); final Auth auth; final ApiBuilder apiBuilder; @@ -55,6 +55,7 @@ class DashboardApp extends StatefulWidget { class _DashboardAppState extends State { AppState _appState; + @override void initState() { super.initState(); _appState = AppState(widget.auth); @@ -80,7 +81,7 @@ class SignInSwitcher extends StatefulWidget { final AppState appState; final ApiBuilder apiBuilder; - SignInSwitcher({ + const SignInSwitcher({ this.appState, this.apiBuilder, }); @@ -97,7 +98,7 @@ class _SignInSwitcherState extends State { return AnimatedSwitcher( switchInCurve: Curves.easeOut, switchOutCurve: Curves.easeOut, - duration: Duration(milliseconds: 200), + duration: const Duration(milliseconds: 200), child: _isSignedIn ? HomePage( onSignOut: _handleSignOut, diff --git a/experimental/web_dashboard/lib/src/auth/firebase.dart b/experimental/web_dashboard/lib/src/auth/firebase.dart index 99a308092..9fcd2881c 100644 --- a/experimental/web_dashboard/lib/src/auth/firebase.dart +++ b/experimental/web_dashboard/lib/src/auth/firebase.dart @@ -12,8 +12,10 @@ class FirebaseAuthService implements Auth { final GoogleSignIn _googleSignIn = GoogleSignIn(); final FirebaseAuth _auth = FirebaseAuth.instance; + @override Future get isSignedIn => _googleSignIn.isSignedIn(); + @override Future signIn() async { try { return await _signIn(); @@ -41,6 +43,7 @@ class FirebaseAuthService implements Auth { return _FirebaseUser(authResult.user.uid); } + @override Future signOut() async { await Future.wait([ _auth.signOut(), @@ -50,6 +53,7 @@ class FirebaseAuthService implements Auth { } class _FirebaseUser implements User { + @override final String uid; _FirebaseUser(this.uid); diff --git a/experimental/web_dashboard/lib/src/auth/mock.dart b/experimental/web_dashboard/lib/src/auth/mock.dart index 6dbf8ba46..e5cfb500b 100644 --- a/experimental/web_dashboard/lib/src/auth/mock.dart +++ b/experimental/web_dashboard/lib/src/auth/mock.dart @@ -7,6 +7,7 @@ import 'dart:math'; import 'auth.dart'; class MockAuthService implements Auth { + @override Future get isSignedIn async => false; @override @@ -26,5 +27,6 @@ class MockAuthService implements Auth { } class MockUser implements User { + @override String get uid => "123"; } diff --git a/experimental/web_dashboard/lib/src/pages/dashboard.dart b/experimental/web_dashboard/lib/src/pages/dashboard.dart index 93772b99c..0c98bf7a1 100644 --- a/experimental/web_dashboard/lib/src/pages/dashboard.dart +++ b/experimental/web_dashboard/lib/src/pages/dashboard.dart @@ -10,13 +10,14 @@ import '../app.dart'; import '../widgets/category_chart.dart'; class DashboardPage extends StatelessWidget { + @override Widget build(BuildContext context) { var appState = Provider.of(context); return FutureBuilder>( future: appState.api.categories.list(), builder: (context, futureSnapshot) { if (!futureSnapshot.hasData) { - return Center( + return const Center( child: CircularProgressIndicator(), ); } @@ -25,7 +26,7 @@ class DashboardPage extends StatelessWidget { stream: appState.api.categories.subscribe(), builder: (context, snapshot) { if (snapshot.data == null) { - return Center( + return const Center( child: CircularProgressIndicator(), ); } @@ -40,14 +41,14 @@ class DashboardPage extends StatelessWidget { class Dashboard extends StatelessWidget { final List categories; - Dashboard(this.categories); + const Dashboard(this.categories); @override Widget build(BuildContext context) { var api = Provider.of(context).api; return Scrollbar( child: GridView( - gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent( + gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( childAspectRatio: 2, maxCrossAxisExtent: 500, ), diff --git a/experimental/web_dashboard/lib/src/pages/entries.dart b/experimental/web_dashboard/lib/src/pages/entries.dart index 19b2672b8..dc1a70a37 100644 --- a/experimental/web_dashboard/lib/src/pages/entries.dart +++ b/experimental/web_dashboard/lib/src/pages/entries.dart @@ -29,7 +29,7 @@ class _EntriesPageState extends State { onSelected: (category) => setState(() => _selected = category)), Expanded( child: _selected == null - ? Center(child: CircularProgressIndicator()) + ? const Center(child: CircularProgressIndicator()) : EntriesList( category: _selected, api: appState.api.entries, @@ -89,7 +89,7 @@ class _EntriesListState extends State { } Widget _buildLoadingIndicator() { - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); } } @@ -97,7 +97,7 @@ class EntryTile extends StatelessWidget { final Category category; final Entry entry; - EntryTile({ + const EntryTile({ this.category, this.entry, }); @@ -111,7 +111,7 @@ class EntryTile extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ TextButton( - child: Text('Edit'), + child: const Text('Edit'), onPressed: () { showDialog( context: context, @@ -122,19 +122,19 @@ class EntryTile extends StatelessWidget { }, ), TextButton( - child: Text('Delete'), + child: const Text('Delete'), onPressed: () async { var shouldDelete = await showDialog( context: context, builder: (context) => AlertDialog( - title: Text('Delete entry?'), + title: const Text('Delete entry?'), actions: [ TextButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () => Navigator.of(context).pop(false), ), TextButton( - child: Text('Delete'), + child: const Text('Delete'), onPressed: () => Navigator.of(context).pop(true), ), ], @@ -147,7 +147,7 @@ class EntryTile extends StatelessWidget { .delete(category.id, entry.id); ScaffoldMessenger.of(context).showSnackBar( - SnackBar( + const SnackBar( content: Text('Entry deleted'), ), ); diff --git a/experimental/web_dashboard/lib/src/pages/home.dart b/experimental/web_dashboard/lib/src/pages/home.dart index e788e6c79..4213b3784 100644 --- a/experimental/web_dashboard/lib/src/pages/home.dart +++ b/experimental/web_dashboard/lib/src/pages/home.dart @@ -12,7 +12,7 @@ import 'entries.dart'; class HomePage extends StatefulWidget { final VoidCallback onSignOut; - HomePage({ + const HomePage({ @required this.onSignOut, }); @@ -26,19 +26,19 @@ class _HomePageState extends State { @override Widget build(BuildContext context) { return AdaptiveScaffold( - title: Text('Dashboard App'), + title: const Text('Dashboard App'), actions: [ Padding( padding: const EdgeInsets.all(8.0), child: TextButton( style: TextButton.styleFrom(primary: Colors.white), onPressed: () => _handleSignOut(), - child: Text('Sign Out'), + child: const Text('Sign Out'), ), ) ], currentIndex: _pageIndex, - destinations: [ + destinations: const [ AdaptiveScaffoldDestination(title: 'Home', icon: Icons.home), AdaptiveScaffoldDestination(title: 'Entries', icon: Icons.list), AdaptiveScaffoldDestination(title: 'Settings', icon: Icons.settings), @@ -61,7 +61,7 @@ class _HomePageState extends State { FloatingActionButton _buildFab(BuildContext context) { return FloatingActionButton( - child: Icon(Icons.add), + child: const Icon(Icons.add), onPressed: () => _handleFabPressed(), ); } @@ -88,16 +88,16 @@ class _HomePageState extends State { var shouldSignOut = await showDialog( context: context, builder: (context) => AlertDialog( - title: Text('Are you sure you want to sign out?'), + title: const Text('Are you sure you want to sign out?'), actions: [ TextButton( - child: Text('No'), + child: const Text('No'), onPressed: () { Navigator.of(context).pop(false); }, ), TextButton( - child: Text('Yes'), + child: const Text('Yes'), onPressed: () { Navigator.of(context).pop(true); }, @@ -122,6 +122,6 @@ class _HomePageState extends State { return EntriesPage(); } - return Center(child: Text('Settings page')); + return const Center(child: Text('Settings page')); } } diff --git a/experimental/web_dashboard/lib/src/pages/sign_in.dart b/experimental/web_dashboard/lib/src/pages/sign_in.dart index ca4cc9d92..f91c99c4f 100644 --- a/experimental/web_dashboard/lib/src/pages/sign_in.dart +++ b/experimental/web_dashboard/lib/src/pages/sign_in.dart @@ -10,7 +10,7 @@ class SignInPage extends StatelessWidget { final Auth auth; final ValueChanged onSuccess; - SignInPage({ + const SignInPage({ @required this.auth, @required this.onSuccess, }); @@ -29,7 +29,7 @@ class SignInButton extends StatefulWidget { final Auth auth; final ValueChanged onSuccess; - SignInButton({ + const SignInButton({ @required this.auth, @required this.onSuccess, }); @@ -78,7 +78,7 @@ class _SignInButtonState extends State { var alreadySignedIn = snapshot.data; if (snapshot.connectionState != ConnectionState.done || alreadySignedIn == true) { - return CircularProgressIndicator(); + return const CircularProgressIndicator(); } // If sign in failed, show toast and the login button @@ -87,7 +87,7 @@ class _SignInButtonState extends State { } return ElevatedButton( - child: Text('Sign In with Google'), + child: const Text('Sign In with Google'), onPressed: () => _signIn(), ); }, @@ -96,7 +96,7 @@ class _SignInButtonState extends State { void _showError() { ScaffoldMessenger.of(context).showSnackBar( - SnackBar( + const SnackBar( content: Text('Unable to sign in.'), ), ); diff --git a/experimental/web_dashboard/lib/src/utils/chart_utils.dart b/experimental/web_dashboard/lib/src/utils/chart_utils.dart index 29f691234..11d76cc09 100644 --- a/experimental/web_dashboard/lib/src/utils/chart_utils.dart +++ b/experimental/web_dashboard/lib/src/utils/chart_utils.dart @@ -60,6 +60,6 @@ Iterable> _entriesInRangeImpl( } yield es; - d = d.add(Duration(days: 1)); + d = d.add(const Duration(days: 1)); } } diff --git a/experimental/web_dashboard/lib/src/utils/day_helpers.dart b/experimental/web_dashboard/lib/src/utils/day_helpers.dart index 20afdde92..9b8993889 100644 --- a/experimental/web_dashboard/lib/src/utils/day_helpers.dart +++ b/experimental/web_dashboard/lib/src/utils/day_helpers.dart @@ -10,6 +10,6 @@ extension DayUtils on DateTime { /// Checks that the two [DateTime]s share the same date. bool isSameDay(DateTime d2) { - return this.year == d2.year && this.month == d2.month && this.day == d2.day; + return year == d2.year && month == d2.month && day == d2.day; } } diff --git a/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart b/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart index c162647d6..b8daa5543 100644 --- a/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart +++ b/experimental/web_dashboard/lib/src/widgets/categories_dropdown.dart @@ -13,7 +13,7 @@ class CategoryDropdown extends StatefulWidget { final CategoryApi api; final ValueChanged onSelected; - CategoryDropdown({ + const CategoryDropdown({ @required this.api, @required this.onSelected, }); @@ -27,6 +27,7 @@ class _CategoryDropdownState extends State { Future> _future; Stream> _stream; + @override void initState() { super.initState(); @@ -69,7 +70,7 @@ class _CategoryDropdownState extends State { builder: (context, futureSnapshot) { // Show an empty dropdown while the data is loading. if (!futureSnapshot.hasData) { - return DropdownButton(items: [], onChanged: null); + return DropdownButton(items: const [], onChanged: null); } return StreamBuilder>( diff --git a/experimental/web_dashboard/lib/src/widgets/category_chart.dart b/experimental/web_dashboard/lib/src/widgets/category_chart.dart index 6e91ccb94..1940e073e 100644 --- a/experimental/web_dashboard/lib/src/widgets/category_chart.dart +++ b/experimental/web_dashboard/lib/src/widgets/category_chart.dart @@ -18,11 +18,12 @@ class CategoryChart extends StatelessWidget { final Category category; final DashboardApi api; - CategoryChart({ + const CategoryChart({ @required this.category, @required this.api, }); + @override Widget build(BuildContext context) { return Column( children: [ @@ -33,7 +34,7 @@ class CategoryChart extends StatelessWidget { children: [ Text(category.name), IconButton( - icon: Icon(Icons.settings), + icon: const Icon(Icons.settings), onPressed: () { showDialog( context: context, @@ -73,14 +74,14 @@ class CategoryChart extends StatelessWidget { } Widget _buildLoadingIndicator() { - return Center(child: CircularProgressIndicator()); + return const Center(child: CircularProgressIndicator()); } } class _BarChart extends StatelessWidget { final List entries; - _BarChart({this.entries}); + const _BarChart({this.entries}); @override Widget build(BuildContext context) { diff --git a/experimental/web_dashboard/lib/src/widgets/category_forms.dart b/experimental/web_dashboard/lib/src/widgets/category_forms.dart index 8bc85a421..1c2ad0921 100644 --- a/experimental/web_dashboard/lib/src/widgets/category_forms.dart +++ b/experimental/web_dashboard/lib/src/widgets/category_forms.dart @@ -13,7 +13,7 @@ class NewCategoryForm extends StatefulWidget { } class _NewCategoryFormState extends State { - Category _category = Category(''); + final Category _category = Category(''); @override Widget build(BuildContext context) { @@ -34,7 +34,7 @@ class EditCategoryForm extends StatefulWidget { final Category category; final ValueChanged onDone; - EditCategoryForm({ + const EditCategoryForm({ @required this.category, @required this.onDone, }); @@ -57,7 +57,7 @@ class _EditCategoryFormState extends State { padding: const EdgeInsets.all(8.0), child: TextFormField( initialValue: widget.category.name, - decoration: InputDecoration( + decoration: const InputDecoration( labelText: 'Name', ), onChanged: (newValue) { @@ -77,7 +77,7 @@ class _EditCategoryFormState extends State { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: ElevatedButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () { widget.onDone(false); }, @@ -86,7 +86,7 @@ class _EditCategoryFormState extends State { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: ElevatedButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () { if (_formKey.currentState.validate()) { widget.onDone(true); diff --git a/experimental/web_dashboard/lib/src/widgets/dialogs.dart b/experimental/web_dashboard/lib/src/widgets/dialogs.dart index 3fd8fb174..0ec805840 100644 --- a/experimental/web_dashboard/lib/src/widgets/dialogs.dart +++ b/experimental/web_dashboard/lib/src/widgets/dialogs.dart @@ -14,7 +14,7 @@ class NewCategoryDialog extends StatelessWidget { @override Widget build(BuildContext context) { return SimpleDialog( - title: Text('New Category'), + title: const Text('New Category'), children: [ NewCategoryForm(), ], @@ -25,7 +25,7 @@ class NewCategoryDialog extends StatelessWidget { class EditCategoryDialog extends StatelessWidget { final Category category; - EditCategoryDialog({ + const EditCategoryDialog({ @required this.category, }); @@ -34,7 +34,7 @@ class EditCategoryDialog extends StatelessWidget { var api = Provider.of(context).api; return SimpleDialog( - title: Text('Edit Category'), + title: const Text('Edit Category'), children: [ EditCategoryForm( category: category, @@ -59,7 +59,7 @@ class _NewEntryDialogState extends State { @override Widget build(BuildContext context) { return SimpleDialog( - title: Text('New Entry'), + title: const Text('New Entry'), children: [ NewEntryForm(), ], @@ -71,7 +71,7 @@ class EditEntryDialog extends StatelessWidget { final Category category; final Entry entry; - EditEntryDialog({ + const EditEntryDialog({ this.category, this.entry, }); @@ -81,7 +81,7 @@ class EditEntryDialog extends StatelessWidget { var api = Provider.of(context).api; return SimpleDialog( - title: Text('Edit Entry'), + title: const Text('Edit Entry'), children: [ EditEntryForm( entry: entry, diff --git a/experimental/web_dashboard/lib/src/widgets/edit_entry.dart b/experimental/web_dashboard/lib/src/widgets/edit_entry.dart index ddb25bd1a..fc35f02a2 100644 --- a/experimental/web_dashboard/lib/src/widgets/edit_entry.dart +++ b/experimental/web_dashboard/lib/src/widgets/edit_entry.dart @@ -17,7 +17,7 @@ class NewEntryForm extends StatefulWidget { class _NewEntryFormState extends State { Category _selected; - Entry _entry = Entry(0, DateTime.now()); + final Entry _entry = Entry(0, DateTime.now()); @override Widget build(BuildContext context) { @@ -55,7 +55,7 @@ class EditEntryForm extends StatefulWidget { final Entry entry; final ValueChanged onDone; - EditEntryForm({ + const EditEntryForm({ @required this.entry, @required this.onDone, }); @@ -75,10 +75,10 @@ class _EditEntryFormState extends State { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), child: TextFormField( initialValue: widget.entry.value.toString(), - decoration: InputDecoration(labelText: 'Value'), + decoration: const InputDecoration(labelText: 'Value'), keyboardType: TextInputType.number, validator: (value) { try { @@ -98,18 +98,19 @@ class _EditEntryFormState extends State { ), ), Padding( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text(intl.DateFormat('MM/dd/yyyy').format(widget.entry.time)), ElevatedButton( - child: Text('Edit'), + child: const Text('Edit'), onPressed: () async { var result = await showDatePicker( context: context, initialDate: widget.entry.time, - firstDate: DateTime.now().subtract(Duration(days: 365)), + firstDate: + DateTime.now().subtract(const Duration(days: 365)), lastDate: DateTime.now()); if (result == null) { return; @@ -128,7 +129,7 @@ class _EditEntryFormState extends State { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: ElevatedButton( - child: Text('Cancel'), + child: const Text('Cancel'), onPressed: () { widget.onDone(false); }, @@ -137,7 +138,7 @@ class _EditEntryFormState extends State { Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), child: ElevatedButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () { if (_formKey.currentState.validate()) { widget.onDone(true); diff --git a/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart b/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart index f89b96687..ddb3e63e8 100644 --- a/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart +++ b/experimental/web_dashboard/lib/src/widgets/third_party/adaptive_scaffold.dart @@ -35,7 +35,7 @@ class AdaptiveScaffold extends StatefulWidget { final ValueChanged onNavigationIndexChange; final FloatingActionButton floatingActionButton; - AdaptiveScaffold({ + const AdaptiveScaffold({ this.title, this.body, this.actions = const [], diff --git a/experimental/web_dashboard/pubspec.lock b/experimental/web_dashboard/pubspec.lock index 008211f51..b8fc1583c 100644 --- a/experimental/web_dashboard/pubspec.lock +++ b/experimental/web_dashboard/pubspec.lock @@ -84,14 +84,14 @@ packages: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "4.3.2" + version: "5.0.0" built_value: dependency: transitive description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "7.1.0" + version: "8.0.6" characters: dependency: transitive description: @@ -133,7 +133,7 @@ packages: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" clock: dependency: transitive description: @@ -252,14 +252,14 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.4.5" + version: "0.4.4" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.0" firebase_core_web: dependency: transitive description: @@ -273,12 +273,19 @@ packages: name: fixnum url: "https://pub.dartlang.org" source: hosted - version: "0.10.11" + version: "1.0.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -302,21 +309,21 @@ packages: name: google_sign_in url: "https://pub.dartlang.org" source: hosted - version: "4.5.9" + version: "5.0.4" google_sign_in_platform_interface: dependency: transitive description: name: google_sign_in_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.2" + version: "2.0.1" google_sign_in_web: dependency: transitive description: name: google_sign_in_web url: "https://pub.dartlang.org" source: hosted - version: "0.9.2" + version: "0.10.0" graphs: dependency: transitive description: @@ -387,6 +394,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.5.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: @@ -456,7 +470,7 @@ packages: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.10.0-nullsafety.3" + version: "1.11.0" plugin_platform_interface: dependency: transitive description: @@ -498,7 +512,14 @@ packages: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" + quiver_hashcode: + dependency: transitive + description: + name: quiver_hashcode + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" shelf: dependency: transitive description: @@ -524,7 +545,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+1" + version: "0.9.10+3" source_span: dependency: transitive description: @@ -625,4 +646,4 @@ packages: version: "2.2.1" sdks: dart: ">=2.12.0 <3.0.0" - flutter: ">=1.16.0" + flutter: ">=1.20.0" diff --git a/experimental/web_dashboard/pubspec.yaml b/experimental/web_dashboard/pubspec.yaml index 3837d81e4..7ad09b2b8 100644 --- a/experimental/web_dashboard/pubspec.yaml +++ b/experimental/web_dashboard/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: cupertino_icons: ^0.1.2 firebase_auth: ^0.16.1 firebase_core: ^0.4.3 - google_sign_in: ^4.4 0 + google_sign_in: ^5.0.0 json_annotation: ^3.0.0 provider: ^4.0.0 uuid: ^2.0.0 @@ -21,5 +21,6 @@ dev_dependencies: build_runner: ^1.8.0 json_serializable: ^3.3.0 grinder: ^0.8.4 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/experimental/web_dashboard/tool/grind.dart b/experimental/web_dashboard/tool/grind.dart index 88eace491..46adf7a12 100644 --- a/experimental/web_dashboard/tool/grind.dart +++ b/experimental/web_dashboard/tool/grind.dart @@ -95,7 +95,7 @@ Stream _filesWithoutCopyright() async* { var firstThreeLines = await file .openRead() .transform(utf8.decoder) - .transform(LineSplitter()) + .transform(const LineSplitter()) .take(3) .fold('', (previous, element) { if (previous == '') return element; diff --git a/flutter_maps_firestore/analysis_options.yaml b/flutter_maps_firestore/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/flutter_maps_firestore/analysis_options.yaml +++ b/flutter_maps_firestore/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/flutter_maps_firestore/lib/main.dart b/flutter_maps_firestore/lib/main.dart index 13987efca..f2fcf0fe3 100644 --- a/flutter_maps_firestore/lib/main.dart +++ b/flutter_maps_firestore/lib/main.dart @@ -76,7 +76,7 @@ class _HomePageState extends State { return Center(child: Text('Error: ${snapshot.error}')); } if (!snapshot.hasData) { - return Center(child: const Text('Loading...')); + return const Center(child: Text('Loading...')); } return Stack( @@ -211,7 +211,7 @@ class _StoreListTileState extends State { return ListTile( title: Text(widget.document['name'] as String), subtitle: Text(widget.document['address'] as String), - leading: Container( + leading: SizedBox( width: 100, height: 100, child: _placePhotoUrl.isNotEmpty diff --git a/flutter_maps_firestore/pubspec.lock b/flutter_maps_firestore/pubspec.lock index c9ee896c6..7209239c3 100644 --- a/flutter_maps_firestore/pubspec.lock +++ b/flutter_maps_firestore/pubspec.lock @@ -42,21 +42,21 @@ packages: name: cloud_firestore url: "https://pub.dartlang.org" source: hosted - version: "0.17.0-1.0.nullsafety.2" + version: "2.2.1" cloud_firestore_platform_interface: dependency: transitive description: name: cloud_firestore_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-1.0.nullsafety.2" + version: "5.1.1" cloud_firestore_web: dependency: transitive description: name: cloud_firestore_web url: "https://pub.dartlang.org" source: hosted - version: "0.4.0-1.0.nullsafety.2" + version: "2.1.1" collection: dependency: transitive description: @@ -77,33 +77,40 @@ packages: name: firebase_core url: "https://pub.dartlang.org" source: hosted - version: "0.8.0-1.0.nullsafety.2" + version: "1.2.1" firebase_core_platform_interface: dependency: transitive description: name: firebase_core_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-1.0.nullsafety.1" + version: "4.0.1" firebase_core_web: dependency: transitive description: name: firebase_core_web url: "https://pub.dartlang.org" source: hosted - version: "0.3.0-1.0.nullsafety.1" + version: "1.1.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_plugin_android_lifecycle: dependency: transitive description: name: flutter_plugin_android_lifecycle url: "https://pub.dartlang.org" source: hosted - version: "2.0.1" + version: "2.0.2" flutter_test: dependency: "direct dev" description: flutter @@ -120,28 +127,28 @@ packages: name: google_maps_flutter url: "https://pub.dartlang.org" source: hosted - version: "2.0.3" + version: "2.0.6" google_maps_flutter_platform_interface: dependency: transitive description: name: google_maps_flutter_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0" + version: "2.0.4" google_maps_webservice: dependency: "direct main" description: name: google_maps_webservice url: "https://pub.dartlang.org" source: hosted - version: "0.0.20-nullsafety.4" + version: "0.0.20-nullsafety.5" http: dependency: transitive description: name: http url: "https://pub.dartlang.org" source: hosted - version: "0.13.2" + version: "0.13.3" http_parser: dependency: transitive description: @@ -163,27 +170,34 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "4.0.1" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" location: dependency: "direct main" description: name: location url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.0" + version: "4.1.1" location_platform_interface: dependency: transitive description: name: location_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.0" + version: "2.1.0" location_web: dependency: transitive description: name: location_web url: "https://pub.dartlang.org" source: hosted - version: "2.0.0-nullsafety.0" + version: "3.0.0" matcher: dependency: transitive description: @@ -206,7 +220,7 @@ packages: source: hosted version: "1.8.0" pedantic: - dependency: "direct dev" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" @@ -218,7 +232,7 @@ packages: name: plugin_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.2" + version: "2.0.0" sky_engine: dependency: transitive description: flutter diff --git a/flutter_maps_firestore/pubspec.yaml b/flutter_maps_firestore/pubspec.yaml index 2386e42ab..85eb994b1 100644 --- a/flutter_maps_firestore/pubspec.yaml +++ b/flutter_maps_firestore/pubspec.yaml @@ -3,13 +3,13 @@ description: A new Flutter project. version: 1.0.0+1 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - cloud_firestore: ^0.17.0-1.0.nullsafety.2 - firebase_core: ^0.8.0-1.0.nullsafety.2 + cloud_firestore: ^2.2.0 + firebase_core: ^1.2.0 google_maps_flutter: ^2.0.0 google_maps_webservice: ^0.0.20-nullsafety.0 location: ^4.0.0-nullsafety.0 @@ -17,7 +17,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.10.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/infinite_list/analysis_options.yaml b/infinite_list/analysis_options.yaml index f5c207c72..30ac27228 100644 --- a/infinite_list/analysis_options.yaml +++ b/infinite_list/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/infinite_list/lib/main.dart b/infinite_list/lib/main.dart index 6bd57252a..898e757e9 100644 --- a/infinite_list/lib/main.dart +++ b/infinite_list/lib/main.dart @@ -30,7 +30,7 @@ class MyHomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Infinite List Sample'), + title: const Text('Infinite List Sample'), ), body: Selector( // Selector is a widget from package:provider. It allows us to listen @@ -54,7 +54,7 @@ class MyHomePage extends StatelessWidget { var item = catalog.getByIndex(index); if (item.isLoading) { - return LoadingItemTile(); + return const LoadingItemTile(); } return ItemTile(item: item); diff --git a/infinite_list/lib/src/item_tile.dart b/infinite_list/lib/src/item_tile.dart index 4a740deed..adcbae8a5 100644 --- a/infinite_list/lib/src/item_tile.dart +++ b/infinite_list/lib/src/item_tile.dart @@ -11,7 +11,7 @@ import 'api/item.dart'; class ItemTile extends StatelessWidget { final Item item; - ItemTile({required this.item, Key? key}) : super(key: key); + const ItemTile({required this.item, Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -41,12 +41,12 @@ class LoadingItemTile extends StatelessWidget { return Padding( padding: const EdgeInsets.all(8.0), child: ListTile( - leading: AspectRatio( + leading: const AspectRatio( aspectRatio: 1, child: Placeholder(), ), title: Text('...', style: Theme.of(context).textTheme.headline6), - trailing: Text('\$ ...'), + trailing: const Text('\$ ...'), ), ); } diff --git a/infinite_list/pubspec.lock b/infinite_list/pubspec.lock index 6ecf59d9b..322dc1313 100644 --- a/infinite_list/pubspec.lock +++ b/infinite_list/pubspec.lock @@ -49,7 +49,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -62,11 +62,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -87,7 +101,7 @@ packages: name: nested url: "https://pub.dartlang.org" source: hosted - version: "0.0.5-nullsafety.1" + version: "1.0.0" path: dependency: transitive description: @@ -95,20 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.3" + version: "5.0.0" sky_engine: dependency: transitive description: flutter diff --git a/infinite_list/pubspec.yaml b/infinite_list/pubspec.yaml index c368a7560..e662ddeb6 100644 --- a/infinite_list/pubspec.yaml +++ b/infinite_list/pubspec.yaml @@ -5,7 +5,7 @@ description: > version: 1.0.0+1 environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: @@ -18,8 +18,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - - pedantic: ^1.10.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/infinite_list/test/smoke_test.dart b/infinite_list/test/smoke_test.dart index 05a053cb3..0b22519f0 100644 --- a/infinite_list/test/smoke_test.dart +++ b/infinite_list/test/smoke_test.dart @@ -25,7 +25,7 @@ void main() { expect(find.text('Color #1'), findsOneWidget); // Flinging up quickly (i.e. scrolling down). - await tester.fling(find.byType(ListView), Offset(0, -2000), 5000); + await tester.fling(find.byType(ListView), const Offset(0, -2000), 5000); // As we scroll down, we should see more items loading. expect(find.text('...'), findsWidgets); diff --git a/isolate_example/analysis_options.yaml b/isolate_example/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/isolate_example/analysis_options.yaml +++ b/isolate_example/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/isolate_example/lib/data_transfer_page.dart b/isolate_example/lib/data_transfer_page.dart index 7ac517449..c05f1fa0b 100644 --- a/isolate_example/lib/data_transfer_page.dart +++ b/isolate_example/lib/data_transfer_page.dart @@ -43,7 +43,7 @@ class DataTransferPage extends StatelessWidget { 'Number Generator Progress', style: Theme.of(context).textTheme.headline6, ), - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), ), LinearProgressIndicator( value: controller.progressPercent, @@ -213,7 +213,7 @@ class RunningList extends StatelessWidget { ), color: Colors.lightGreenAccent, ), - Divider( + const Divider( color: Colors.blue, height: 3, ), diff --git a/isolate_example/lib/infinite_process_page.dart b/isolate_example/lib/infinite_process_page.dart index 4152a8678..c3e686119 100644 --- a/isolate_example/lib/infinite_process_page.dart +++ b/isolate_example/lib/infinite_process_page.dart @@ -76,7 +76,7 @@ class InfiniteProcessPage extends StatelessWidget { inactiveTrackColor: Colors.deepOrangeAccent, inactiveThumbColor: Colors.black, ), - Text('Pause/Resume'), + const Text('Pause/Resume'), ], ), Row( @@ -207,7 +207,7 @@ class RunningList extends StatelessWidget { ? Colors.lightGreenAccent : Colors.deepOrangeAccent, ), - Divider( + const Divider( color: Colors.blue, height: 3, ), diff --git a/isolate_example/lib/main.dart b/isolate_example/lib/main.dart index d3ba4695e..8fe5fc7a9 100644 --- a/isolate_example/lib/main.dart +++ b/isolate_example/lib/main.dart @@ -34,7 +34,7 @@ class HomePage extends StatelessWidget { length: 3, child: Scaffold( appBar: AppBar( - bottom: TabBar( + bottom: const TabBar( tabs: [ Tab( icon: Icon(Icons.flash_on), @@ -50,7 +50,7 @@ class HomePage extends StatelessWidget { ), ], ), - title: Text('Isolate Example'), + title: const Text('Isolate Example'), ), body: TabBarView( children: [ diff --git a/isolate_example/lib/performance_page.dart b/isolate_example/lib/performance_page.dart index 1f600a15d..51100c12b 100644 --- a/isolate_example/lib/performance_page.dart +++ b/isolate_example/lib/performance_page.dart @@ -46,7 +46,7 @@ class _PerformancePageState extends State { SmoothAnimationWidget(), Container( alignment: Alignment.bottomCenter, - padding: EdgeInsets.only(top: 150), + padding: const EdgeInsets.only(top: 150), child: Column( children: [ FutureBuilder( @@ -85,7 +85,7 @@ class _PerformancePageState extends State { void handleComputeOnMain(BuildContext context) { var future = computeOnMainIsolate() ..then((_) { - var snackBar = SnackBar( + var snackBar = const SnackBar( content: Text('Main Isolate Done!'), ); ScaffoldMessenger.of(context).showSnackBar(snackBar); @@ -99,7 +99,7 @@ class _PerformancePageState extends State { void handleComputeOnSecondary(BuildContext context) { var future = computeOnSecondaryIsolate() ..then((_) { - var snackBar = SnackBar( + var snackBar = const SnackBar( content: Text('Secondary Isolate Done!'), ); ScaffoldMessenger.of(context).showSnackBar(snackBar); @@ -114,7 +114,7 @@ class _PerformancePageState extends State { // A delay is added here to give Flutter the chance to redraw the UI at // least once before the computation (which, since it's run on the main // isolate, will lock up the app) begins executing. - await Future.delayed(Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); fib(45); } @@ -156,14 +156,14 @@ class SmoothAnimationWidgetState extends State animation: _borderAnimation, builder: (context, child) { return Container( - child: FlutterLogo( + child: const FlutterLogo( size: 200, ), alignment: Alignment.bottomCenter, width: 350, height: 200, decoration: BoxDecoration( - gradient: LinearGradient( + gradient: const LinearGradient( begin: Alignment.topLeft, colors: [ Colors.blueAccent, diff --git a/isolate_example/pubspec.lock b/isolate_example/pubspec.lock index 4196e3796..421c3deee 100644 --- a/isolate_example/pubspec.lock +++ b/isolate_example/pubspec.lock @@ -55,11 +55,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -88,20 +102,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.5" + version: "5.0.0" sky_engine: dependency: transitive description: flutter diff --git a/isolate_example/pubspec.yaml b/isolate_example/pubspec.yaml index 0ff5ea9dc..08cf2cb82 100644 --- a/isolate_example/pubspec.yaml +++ b/isolate_example/pubspec.yaml @@ -3,18 +3,17 @@ description: A Flutter sample to demonstrate isolates version: 1.0.0+1 environment: - sdk: ">=2.12.0-0 <3.0.0" + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter - provider: ^5.0.0-0 + provider: ^5.0.0 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.10.0 - + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/jsonexample/analysis_options.yaml b/jsonexample/analysis_options.yaml index 301602ff8..fdf8d9bff 100644 --- a/jsonexample/analysis_options.yaml +++ b/jsonexample/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: exclude: @@ -10,25 +10,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/jsonexample/lib/built_value/built_complex_object.g.dart b/jsonexample/lib/built_value/built_complex_object.g.dart index 59cc27334..7c2032a68 100644 --- a/jsonexample/lib/built_value/built_complex_object.g.dart +++ b/jsonexample/lib/built_value/built_complex_object.g.dart @@ -17,9 +17,10 @@ class _$BuiltComplexObjectSerializer final String wireName = 'BuiltComplexObject'; @override - Iterable serialize(Serializers serializers, BuiltComplexObject object, + Iterable serialize( + Serializers serializers, BuiltComplexObject object, {FullType specifiedType = FullType.unspecified}) { - final result = []; + final result = []; Object? value; value = object.aString; if (value != null) { @@ -85,7 +86,7 @@ class _$BuiltComplexObjectSerializer @override BuiltComplexObject deserialize( - Serializers serializers, Iterable serialized, + Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new BuiltComplexObjectBuilder(); @@ -93,7 +94,7 @@ class _$BuiltComplexObjectSerializer while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'aString': result.aString = serializers.deserialize(value, @@ -109,31 +110,31 @@ class _$BuiltComplexObjectSerializer break; case 'anObject': result.anObject.replace(serializers.deserialize(value, - specifiedType: const FullType(BuiltSimpleObject)) + specifiedType: const FullType(BuiltSimpleObject))! as BuiltSimpleObject); break; case 'aListOfStrings': result.aListOfStrings.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, const [const FullType(String)])) + specifiedType: const FullType( + BuiltList, const [const FullType(String)]))! as BuiltList); break; case 'aListOfInts': result.aListOfInts.replace(serializers.deserialize(value, specifiedType: - const FullType(BuiltList, const [const FullType(int)])) + const FullType(BuiltList, const [const FullType(int)]))! as BuiltList); break; case 'aListOfDoubles': result.aListOfDoubles.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, const [const FullType(double)])) + specifiedType: const FullType( + BuiltList, const [const FullType(double)]))! as BuiltList); break; case 'aListOfObjects': result.aListOfObjects.replace(serializers.deserialize(value, specifiedType: const FullType( - BuiltList, const [const FullType(BuiltSimpleObject)])) + BuiltList, const [const FullType(BuiltSimpleObject)]))! as BuiltList); break; } diff --git a/jsonexample/lib/built_value/built_simple_object.g.dart b/jsonexample/lib/built_value/built_simple_object.g.dart index 92e9ad9cf..f8e641286 100644 --- a/jsonexample/lib/built_value/built_simple_object.g.dart +++ b/jsonexample/lib/built_value/built_simple_object.g.dart @@ -17,9 +17,9 @@ class _$BuiltSimpleObjectSerializer final String wireName = 'BuiltSimpleObject'; @override - Iterable serialize(Serializers serializers, BuiltSimpleObject object, + Iterable serialize(Serializers serializers, BuiltSimpleObject object, {FullType specifiedType = FullType.unspecified}) { - final result = []; + final result = []; Object? value; value = object.aString; if (value != null) { @@ -70,7 +70,7 @@ class _$BuiltSimpleObjectSerializer @override BuiltSimpleObject deserialize( - Serializers serializers, Iterable serialized, + Serializers serializers, Iterable serialized, {FullType specifiedType = FullType.unspecified}) { final result = new BuiltSimpleObjectBuilder(); @@ -78,7 +78,7 @@ class _$BuiltSimpleObjectSerializer while (iterator.moveNext()) { final key = iterator.current as String; iterator.moveNext(); - final Object value = iterator.current; + final Object? value = iterator.current; switch (key) { case 'aString': result.aString = serializers.deserialize(value, @@ -94,20 +94,20 @@ class _$BuiltSimpleObjectSerializer break; case 'aListOfStrings': result.aListOfStrings.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, const [const FullType(String)])) + specifiedType: const FullType( + BuiltList, const [const FullType(String)]))! as BuiltList); break; case 'aListOfInts': result.aListOfInts.replace(serializers.deserialize(value, specifiedType: - const FullType(BuiltList, const [const FullType(int)])) + const FullType(BuiltList, const [const FullType(int)]))! as BuiltList); break; case 'aListOfDoubles': result.aListOfDoubles.replace(serializers.deserialize(value, - specifiedType: - const FullType(BuiltList, const [const FullType(double)])) + specifiedType: const FullType( + BuiltList, const [const FullType(double)]))! as BuiltList); break; } diff --git a/jsonexample/lib/json_strings.dart b/jsonexample/lib/json_strings.dart index 0f4ba171b..68dfc34a2 100644 --- a/jsonexample/lib/json_strings.dart +++ b/jsonexample/lib/json_strings.dart @@ -3,22 +3,22 @@ // found in the LICENSE file. abstract class JsonStrings { - static final String listOfInts = '[1, 2, 3]'; + static const listOfInts = '[1, 2, 3]'; - static final String listOfDoubles = '[1.0, 2.0, 3.0]'; + static const listOfDoubles = '[1.0, 2.0, 3.0]'; - static final String listOfStrings = '["one", "two", "three"]'; + static const listOfStrings = '["one", "two", "three"]'; - static final String listOfDynamics = '[1, "two", 3.0]'; + static const listOfDynamics = '[1, "two", 3.0]'; - static final String mapOfDynamics = ''' + static const mapOfDynamics = ''' { "anInt": 1, "aString": "Blah, blah, blah.", "aDouble": 1.0 }'''; - static final String listOfSimpleObjects = ''' + static const listOfSimpleObjects = ''' [ { "aString": "Blah, blah, blah.", @@ -97,7 +97,7 @@ abstract class JsonStrings { ] '''; - static final List simpleObjects = [ + static final simpleObjects = [ ''' { "aString": "Blah, blah, blah.", @@ -184,7 +184,7 @@ abstract class JsonStrings { }''', ]; - static final List complexObjects = [ + static final complexObjects = [ ''' { "aString": "Blah, blah, blah.", diff --git a/jsonexample/lib/main.dart b/jsonexample/lib/main.dart index 1db98aa55..f53519f98 100644 --- a/jsonexample/lib/main.dart +++ b/jsonexample/lib/main.dart @@ -15,13 +15,13 @@ class MyApp extends StatelessWidget { theme: ThemeData( primarySwatch: Colors.blue, ), - home: MyHomePage(), + home: const MyHomePage(), ); } } class MyHomePage extends StatelessWidget { - MyHomePage({Key? key}) : super(key: key); + const MyHomePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/jsonexample/lib/widgets.dart b/jsonexample/lib/widgets.dart index 609c0164f..3db907004 100644 --- a/jsonexample/lib/widgets.dart +++ b/jsonexample/lib/widgets.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; import 'package:jsonexample/utils.dart'; class SimpleObjectView extends StatelessWidget { - SimpleObjectView(dynamic obj) : simpleObject = obj; + const SimpleObjectView(this.simpleObject); final dynamic simpleObject; @@ -93,7 +93,7 @@ class SimpleObjectView extends StatelessWidget { } class SimpleObjectViewList extends StatelessWidget { - SimpleObjectViewList(List objects) : simpleObjects = objects; + const SimpleObjectViewList(this.simpleObjects); final List simpleObjects; @@ -125,7 +125,7 @@ class SimpleObjectViewList extends StatelessWidget { class ComplexObjectView extends StatelessWidget { final dynamic complexObject; - ComplexObjectView(dynamic obj) : complexObject = obj; + const ComplexObjectView(this.complexObject); List _generateSimpleObjectWidgets(Iterable? simpleObjects) { if (simpleObjects == null) { @@ -267,7 +267,7 @@ class ComplexObjectView extends StatelessWidget { } class ComplexObjectViewList extends StatelessWidget { - ComplexObjectViewList(List objects) : complexObjects = objects; + const ComplexObjectViewList(this.complexObjects); final List complexObjects; diff --git a/jsonexample/pubspec.lock b/jsonexample/pubspec.lock index 938ae79bf..05c5943ee 100644 --- a/jsonexample/pubspec.lock +++ b/jsonexample/pubspec.lock @@ -7,21 +7,21 @@ packages: name: _fe_analyzer_shared url: "https://pub.dartlang.org" source: hosted - version: "12.0.0" + version: "22.0.0" analyzer: dependency: transitive description: name: analyzer url: "https://pub.dartlang.org" source: hosted - version: "0.40.6" + version: "1.7.1" args: dependency: transitive description: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.1.1" async: dependency: transitive description: @@ -42,63 +42,63 @@ packages: name: build url: "https://pub.dartlang.org" source: hosted - version: "1.6.2" + version: "2.0.2" build_config: dependency: transitive description: name: build_config url: "https://pub.dartlang.org" source: hosted - version: "0.4.5" + version: "1.0.0" build_daemon: dependency: transitive description: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "2.1.7" + version: "3.0.0" build_resolvers: dependency: transitive description: name: build_resolvers url: "https://pub.dartlang.org" source: hosted - version: "1.5.3" + version: "2.0.3" build_runner: dependency: "direct dev" description: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "1.11.1" + version: "2.0.4" build_runner_core: dependency: transitive description: name: build_runner_core url: "https://pub.dartlang.org" source: hosted - version: "6.1.7" + version: "7.0.0" built_collection: dependency: "direct main" description: name: built_collection url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.0" + version: "5.0.0" built_value: dependency: "direct main" description: name: built_value url: "https://pub.dartlang.org" source: hosted - version: "8.0.0-nullsafety.0" + version: "8.0.6" built_value_generator: dependency: "direct dev" description: name: built_value_generator url: "https://pub.dartlang.org" source: hosted - version: "8.0.0-nullsafety.0" + version: "8.0.6" characters: dependency: transitive description: @@ -119,14 +119,14 @@ packages: name: checked_yaml url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" cli_util: dependency: transitive description: name: cli_util url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "0.3.0" clock: dependency: transitive description: @@ -140,7 +140,7 @@ packages: name: code_builder url: "https://pub.dartlang.org" source: hosted - version: "3.6.0" + version: "4.0.0" collection: dependency: transitive description: @@ -154,21 +154,21 @@ packages: name: convert url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "3.0.0" crypto: dependency: transitive description: name: crypto url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" dart_style: dependency: transitive description: name: dart_style url: "https://pub.dartlang.org" source: hosted - version: "1.3.10" + version: "2.0.1" fake_async: dependency: transitive description: @@ -182,7 +182,7 @@ packages: name: file url: "https://pub.dartlang.org" source: hosted - version: "5.2.1" + version: "6.1.1" fixnum: dependency: transitive description: @@ -195,53 +195,60 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + frontend_server_client: + dependency: transitive + description: + name: frontend_server_client + url: "https://pub.dartlang.org" + source: hosted + version: "2.1.0" glob: dependency: transitive description: name: glob url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.1" graphs: dependency: transitive description: name: graphs url: "https://pub.dartlang.org" source: hosted - version: "0.2.0" + version: "2.0.0" http_multi_server: dependency: transitive description: name: http_multi_server url: "https://pub.dartlang.org" source: hosted - version: "2.2.0" + version: "3.0.1" http_parser: dependency: transitive description: name: http_parser url: "https://pub.dartlang.org" source: hosted - version: "3.1.4" - intl: - dependency: transitive - description: - name: intl - url: "https://pub.dartlang.org" - source: hosted - version: "0.16.1" + version: "4.0.0" io: dependency: transitive description: name: io url: "https://pub.dartlang.org" source: hosted - version: "0.3.4" + version: "1.0.0" js: dependency: transitive description: @@ -255,21 +262,28 @@ packages: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.0" + version: "4.0.1" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.0" + version: "4.1.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: name: logging url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.0.1" matcher: dependency: transitive description: @@ -291,27 +305,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.0" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.1" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" package_config: dependency: transitive description: name: package_config url: "https://pub.dartlang.org" source: hosted - version: "1.9.3" + version: "2.0.0" path: dependency: transitive description: @@ -320,54 +320,54 @@ packages: source: hosted version: "1.8.0" pedantic: - dependency: "direct dev" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" source: hosted - version: "1.10.0" + version: "1.11.0" pool: dependency: transitive description: name: pool url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.5.0" pub_semver: dependency: transitive description: name: pub_semver url: "https://pub.dartlang.org" source: hosted - version: "1.4.4" + version: "2.0.0" pubspec_parse: dependency: transitive description: name: pubspec_parse url: "https://pub.dartlang.org" source: hosted - version: "0.1.7" + version: "1.0.0" quiver: dependency: transitive description: name: quiver url: "https://pub.dartlang.org" source: hosted - version: "2.1.5" + version: "3.0.1" shelf: dependency: transitive description: name: shelf url: "https://pub.dartlang.org" source: hosted - version: "0.7.9" + version: "1.1.4" shelf_web_socket: dependency: transitive description: name: shelf_web_socket url: "https://pub.dartlang.org" source: hosted - version: "0.2.4" + version: "1.0.1" sky_engine: dependency: transitive description: flutter @@ -379,7 +379,7 @@ packages: name: source_gen url: "https://pub.dartlang.org" source: hosted - version: "0.9.10+1" + version: "1.0.1" source_span: dependency: transitive description: @@ -407,7 +407,7 @@ packages: name: stream_transform url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.0.0" string_scanner: dependency: transitive description: @@ -435,7 +435,7 @@ packages: name: timing url: "https://pub.dartlang.org" source: hosted - version: "0.1.1+3" + version: "1.0.0" typed_data: dependency: transitive description: @@ -456,20 +456,20 @@ packages: name: watcher url: "https://pub.dartlang.org" source: hosted - version: "0.9.7+15" + version: "1.0.0" web_socket_channel: dependency: transitive description: name: web_socket_channel url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "2.1.0" yaml: dependency: transitive description: name: yaml url: "https://pub.dartlang.org" source: hosted - version: "2.2.1" + version: "3.1.0" sdks: dart: ">=2.12.0 <3.0.0" diff --git a/jsonexample/pubspec.yaml b/jsonexample/pubspec.yaml index b414041bc..fcc85db34 100644 --- a/jsonexample/pubspec.yaml +++ b/jsonexample/pubspec.yaml @@ -2,12 +2,12 @@ name: jsonexample description: A demonstration of JSON parsing environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: - json_annotation: ^4.0.0-0 - built_collection: ^5.0.0-0 - built_value: ^8.0.0-0 + json_annotation: ^4.0.0 + built_collection: ^5.0.0 + built_value: ^8.0.0 flutter: sdk: flutter @@ -15,10 +15,10 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - build_runner: ^1.11.1 - built_value_generator: ^8.0.0-0 - json_serializable: ^4.0.0-0 - pedantic: ^1.9.0 + build_runner: ^2.0.4 + built_value_generator: ^8.0.0 + json_serializable: ^4.0.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/jsonexample/test/complex_object_unit_test.dart b/jsonexample/test/complex_object_unit_test.dart index 97c6e43d2..978f120e6 100644 --- a/jsonexample/test/complex_object_unit_test.dart +++ b/jsonexample/test/complex_object_unit_test.dart @@ -325,7 +325,7 @@ void main() { group('BuiltComplexObject unit tests', () { test('Typical object is converted correctly', () { final complexObject = serializers.deserializeWith( - BuiltComplexObject.serializer, typicalObjectJson); + BuiltComplexObject.serializer, typicalObjectJson)!; expect(complexObject.aString, 'Blah, blah, blah.'); expect(complexObject.anInt, 1); @@ -354,8 +354,8 @@ void main() { }); test('Empty object results in null fields', () { - final complexObject = - serializers.deserializeWith(BuiltComplexObject.serializer, emptyJson); + final complexObject = serializers.deserializeWith( + BuiltComplexObject.serializer, emptyJson)!; expect(complexObject.aString, isNull); expect(complexObject.anInt, isNull); @@ -369,7 +369,7 @@ void main() { test('Empty simple objects result in instances with null fields', () { final complexObject = serializers.deserializeWith( - BuiltComplexObject.serializer, emptySimpleObjectsJson); + BuiltComplexObject.serializer, emptySimpleObjectsJson)!; expect(complexObject.aString, 'Blah, blah, blah.'); expect(complexObject.anInt, 1); @@ -397,7 +397,7 @@ void main() { test('Unexpected properties are ignored', () { final complexObject = serializers.deserializeWith( - BuiltComplexObject.serializer, unexpectedPropertiesJson); + BuiltComplexObject.serializer, unexpectedPropertiesJson)!; expect(complexObject.aString, 'Blah, blah, blah.'); expect(complexObject.anInt, 1); diff --git a/jsonexample/test/simple_object_unit_test.dart b/jsonexample/test/simple_object_unit_test.dart index e67d7539c..701eda470 100644 --- a/jsonexample/test/simple_object_unit_test.dart +++ b/jsonexample/test/simple_object_unit_test.dart @@ -146,7 +146,7 @@ void main() { group('BuiltSimpleObject unit tests', () { test('Typical object is converted correctly', () { final simpleObject = serializers.deserializeWith( - BuiltSimpleObject.serializer, typicalObjectJson); + BuiltSimpleObject.serializer, typicalObjectJson)!; expect(simpleObject, isNotNull); expect(simpleObject.aString, 'Blah, blah, blah.'); @@ -159,7 +159,7 @@ void main() { test('Empty object results in null fields', () { final simpleObject = - serializers.deserializeWith(BuiltSimpleObject.serializer, emptyJson); + serializers.deserializeWith(BuiltSimpleObject.serializer, emptyJson)!; expect(simpleObject, isNotNull); expect(simpleObject.aString, isNull); @@ -172,7 +172,7 @@ void main() { test('Empty lists are converted as empty lists', () { final simpleObject = serializers.deserializeWith( - BuiltSimpleObject.serializer, emptyListJson); + BuiltSimpleObject.serializer, emptyListJson)!; expect(simpleObject, isNotNull); expect(simpleObject.aString, 'Blah, blah, blah.'); @@ -185,7 +185,7 @@ void main() { test('Unexpected properties are ignored', () { final simpleObject = serializers.deserializeWith( - BuiltSimpleObject.serializer, unexpectedPropertiesJson); + BuiltSimpleObject.serializer, unexpectedPropertiesJson)!; expect(simpleObject, isNotNull); expect(simpleObject.aString, 'Blah, blah, blah.'); diff --git a/jsonexample/test/widget_tests_test.dart b/jsonexample/test/widget_tests_test.dart index 09ecdec8b..7b674e497 100644 --- a/jsonexample/test/widget_tests_test.dart +++ b/jsonexample/test/widget_tests_test.dart @@ -11,7 +11,7 @@ import 'package:jsonexample/widgets.dart'; void main() { group('SimpleObjectView widget test', () { testWidgets('Typical object is displayed correctly', (tester) async { - final simpleObject = ConvertedSimpleObject( + const simpleObject = ConvertedSimpleObject( aString: 'Blah, blah, blah', anInt: 1, aDouble: 1.0, @@ -21,7 +21,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SimpleObjectView(simpleObject), ), ); @@ -35,7 +35,7 @@ void main() { }); testWidgets('Empty lists are displayed as brackets', (tester) async { - final simpleObject = ConvertedSimpleObject( + const simpleObject = ConvertedSimpleObject( aString: 'Blah, blah, blah', anInt: 1, aDouble: 1.0, @@ -45,7 +45,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SimpleObjectView(simpleObject), ), ); @@ -54,7 +54,7 @@ void main() { }); testWidgets('Null values are displayed as NULL', (tester) async { - final simpleObject = ConvertedSimpleObject( + const simpleObject = ConvertedSimpleObject( aString: null, anInt: null, aDouble: null, @@ -64,7 +64,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: SimpleObjectView(simpleObject), ), ); @@ -75,7 +75,7 @@ void main() { group('ComplexObjectView widget test', () { testWidgets('Typical object is displayed correctly', (tester) async { - final complexObject = ConvertedComplexObject( + const complexObject = ConvertedComplexObject( aString: 'Blah, blah, blah', anInt: 1, aDouble: 1.0, @@ -119,7 +119,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: ComplexObjectView(complexObject), ), ); @@ -142,7 +142,7 @@ void main() { }); testWidgets('Empty lists are displayed as brackets', (tester) async { - final complexObject = ConvertedComplexObject( + const complexObject = ConvertedComplexObject( aString: 'Blah, blah, blah', anInt: 1, aDouble: 1.0, @@ -161,7 +161,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: ComplexObjectView(complexObject), ), ); @@ -170,7 +170,7 @@ void main() { }); testWidgets('Null values are displayed as NULL', (tester) async { - final complexObject = ConvertedComplexObject( + const complexObject = ConvertedComplexObject( aString: null, anInt: null, aDouble: null, @@ -182,7 +182,7 @@ void main() { ); await tester.pumpWidget( - MaterialApp( + const MaterialApp( home: ComplexObjectView(complexObject), ), ); diff --git a/place_tracker/analysis_options.yaml b/place_tracker/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/place_tracker/analysis_options.yaml +++ b/place_tracker/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/place_tracker/lib/place_details.dart b/place_tracker/lib/place_details.dart index 582583eba..15fb186a3 100644 --- a/place_tracker/lib/place_details.dart +++ b/place_tracker/lib/place_details.dart @@ -37,7 +37,7 @@ class PlaceDetailsState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('${_place.name}'), + title: Text(_place.name), backgroundColor: Colors.green[700], actions: [ Padding( diff --git a/place_tracker/lib/place_list.dart b/place_tracker/lib/place_list.dart index 8d8feaf99..88d63a161 100644 --- a/place_tracker/lib/place_list.dart +++ b/place_tracker/lib/place_list.dart @@ -92,7 +92,7 @@ class _CategoryButton extends StatelessWidget { } return Container( - margin: EdgeInsets.symmetric(vertical: 12.0), + margin: const EdgeInsets.symmetric(vertical: 12.0), decoration: BoxDecoration( border: Border( bottom: BorderSide( @@ -179,14 +179,14 @@ class _PlaceListTile extends StatelessWidget { }), ), child: Container( - padding: EdgeInsets.only(top: 16.0), + padding: const EdgeInsets.only(top: 16.0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( place.name, textAlign: TextAlign.left, - style: TextStyle( + style: const TextStyle( fontWeight: FontWeight.bold, fontSize: 20.0, ), @@ -209,7 +209,7 @@ class _PlaceListTile extends StatelessWidget { maxLines: 4, overflow: TextOverflow.ellipsis, ), - SizedBox(height: 16.0), + const SizedBox(height: 16.0), Divider( height: 2.0, color: Colors.grey[700], diff --git a/place_tracker/lib/place_map.dart b/place_tracker/lib/place_map.dart index dd09e2750..82e29dfd0 100644 --- a/place_tracker/lib/place_map.dart +++ b/place_tracker/lib/place_map.dart @@ -206,7 +206,7 @@ class PlaceMapState extends State { // Show a confirmation snackbar that has an action to edit the new place. ScaffoldMessenger.of(context).showSnackBar( SnackBar( - duration: Duration(seconds: 3), + duration: const Duration(seconds: 3), content: const Text('New place added.', style: TextStyle(fontSize: 16.0)), action: SnackBarAction( @@ -293,7 +293,7 @@ class PlaceMapState extends State { final newMarker = Marker( markerId: MarkerId(_lastMapPosition.toString()), position: _lastMapPosition, - infoWindow: InfoWindow(title: 'New Place'), + infoWindow: const InfoWindow(title: 'New Place'), draggable: true, icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueGreen), ); @@ -433,12 +433,12 @@ class PlaceMapState extends State { switch (category) { case PlaceCategory.favorite: return BitmapDescriptor.fromAssetImage( - createLocalImageConfiguration(context, size: Size.square(32)), + createLocalImageConfiguration(context, size: const Size.square(32)), 'assets/heart.png'); break; case PlaceCategory.visited: return BitmapDescriptor.fromAssetImage( - createLocalImageConfiguration(context, size: Size.square(32)), + createLocalImageConfiguration(context, size: const Size.square(32)), 'assets/visited.png'); break; case PlaceCategory.wantToGo: @@ -598,7 +598,7 @@ class _MapFabs extends StatelessWidget { backgroundColor: Colors.green, child: const Icon(Icons.add_location, size: 36.0), ), - SizedBox(height: 12.0), + const SizedBox(height: 12.0), FloatingActionButton( heroTag: 'toggle_map_type_button', onPressed: onToggleMapTypePressed, diff --git a/place_tracker/lib/place_tracker_app.dart b/place_tracker/lib/place_tracker_app.dart index ab28b4a4f..a320c34e1 100644 --- a/place_tracker/lib/place_tracker_app.dart +++ b/place_tracker/lib/place_tracker_app.dart @@ -19,7 +19,7 @@ enum PlaceTrackerViewType { class PlaceTrackerApp extends StatelessWidget { @override Widget build(BuildContext context) { - return MaterialApp( + return const MaterialApp( home: _PlaceTrackerHomePage(), ); } @@ -46,7 +46,7 @@ class _PlaceTrackerHomePage extends StatelessWidget { backgroundColor: Colors.green[700], actions: [ Padding( - padding: EdgeInsets.fromLTRB(0.0, 0.0, 16.0, 0.0), + padding: const EdgeInsets.fromLTRB(0.0, 0.0, 16.0, 0.0), child: IconButton( icon: Icon( state.viewType == PlaceTrackerViewType.map @@ -67,8 +67,8 @@ class _PlaceTrackerHomePage extends StatelessWidget { ), body: IndexedStack( index: state.viewType == PlaceTrackerViewType.map ? 0 : 1, - children: [ - PlaceMap(center: const LatLng(45.521563, -122.677433)), + children: const [ + PlaceMap(center: LatLng(45.521563, -122.677433)), PlaceList() ], ), diff --git a/place_tracker/pubspec.lock b/place_tracker/pubspec.lock index 469a7854b..6eb84093a 100644 --- a/place_tracker/pubspec.lock +++ b/place_tracker/pubspec.lock @@ -83,6 +83,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_plugin_android_lifecycle: dependency: transitive description: @@ -149,6 +156,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.5.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -177,13 +191,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.2" plugin_platform_interface: dependency: transitive description: diff --git a/place_tracker/pubspec.yaml b/place_tracker/pubspec.yaml index 9432ca490..9c1fea174 100644 --- a/place_tracker/pubspec.yaml +++ b/place_tracker/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + flutter_lints: ^1.0.0 flutter: assets: diff --git a/platform_channels/analysis_options.yaml b/platform_channels/analysis_options.yaml index f5c207c72..be4f27226 100644 --- a/platform_channels/analysis_options.yaml +++ b/platform_channels/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,15 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/platform_channels/lib/main.dart b/platform_channels/lib/main.dart index 1f3a550d4..80c0cb602 100644 --- a/platform_channels/lib/main.dart +++ b/platform_channels/lib/main.dart @@ -68,7 +68,7 @@ class HomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Platform Channel Sample'), + title: const Text('Platform Channel Sample'), ), body: ListView( children: demoList.map((demoInfo) => DemoTile(demoInfo)).toList(), @@ -81,7 +81,7 @@ class HomePage extends StatelessWidget { class DemoTile extends StatelessWidget { final DemoInfo demoInfo; - DemoTile(this.demoInfo); + const DemoTile(this.demoInfo); @override Widget build(BuildContext context) { diff --git a/platform_channels/lib/src/accelerometer_event_channel.dart b/platform_channels/lib/src/accelerometer_event_channel.dart index 1655a8332..c6af4cc49 100644 --- a/platform_channels/lib/src/accelerometer_event_channel.dart +++ b/platform_channels/lib/src/accelerometer_event_channel.dart @@ -8,7 +8,7 @@ import 'package:flutter/services.dart'; /// changes from the Accelerometer sensor from native side. It has a [readings] /// getter to provide a stream of [AccelerometerReadings]. class Accelerometer { - static final _eventChannel = const EventChannel('eventChannelDemo'); + static const _eventChannel = EventChannel('eventChannelDemo'); /// Method responsible for providing a stream of [AccelerometerReadings] to listen /// to value changes from the Accelerometer sensor. diff --git a/platform_channels/lib/src/add_pet_details.dart b/platform_channels/lib/src/add_pet_details.dart index ea42908af..bb4834152 100644 --- a/platform_channels/lib/src/add_pet_details.dart +++ b/platform_channels/lib/src/add_pet_details.dart @@ -22,10 +22,10 @@ class _AddPetDetailsState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Add Pet Details'), + title: const Text('Add Pet Details'), actions: [ IconButton( - icon: Icon(Icons.add), + icon: const Icon(Icons.add), onPressed: () { PetListMessageChannel.addPetDetails( PetDetails( @@ -43,19 +43,19 @@ class _AddPetDetailsState extends State { padding: const EdgeInsets.all(8.0), child: Column( children: [ - SizedBox( + const SizedBox( height: 8, ), TextField( controller: breedTextController, - decoration: InputDecoration( + decoration: const InputDecoration( border: OutlineInputBorder(), filled: true, hintText: 'Breed of pet', labelText: 'Breed', ), ), - SizedBox( + const SizedBox( height: 8, ), RadioListTile( diff --git a/platform_channels/lib/src/event_channel_demo.dart b/platform_channels/lib/src/event_channel_demo.dart index 1489d5476..02d569a83 100644 --- a/platform_channels/lib/src/event_channel_demo.dart +++ b/platform_channels/lib/src/event_channel_demo.dart @@ -19,7 +19,7 @@ class EventChannelDemo extends StatelessWidget { final textStyle = Theme.of(context).textTheme.headline5; return Scaffold( appBar: AppBar( - title: Text('EventChannel Demo'), + title: const Text('EventChannel Demo'), ), body: Center( child: StreamBuilder( diff --git a/platform_channels/lib/src/image_basic_message_channel.dart b/platform_channels/lib/src/image_basic_message_channel.dart index d3cfa82e1..6c127dc70 100644 --- a/platform_channels/lib/src/image_basic_message_channel.dart +++ b/platform_channels/lib/src/image_basic_message_channel.dart @@ -10,8 +10,8 @@ import 'package:flutter/services.dart'; /// from a native asset. The [BasicMessageChannel] uses [StandardMessageCodec] /// since it supports [Uint8List], which is used to transport the image data. class PlatformImageFetcher { - static final _basicMessageChannel = const BasicMessageChannel( - 'platformImageDemo', StandardMessageCodec()); + static const _basicMessageChannel = + BasicMessageChannel('platformImageDemo', StandardMessageCodec()); /// Method responsible for providing the platform image. static Future getImage() async { diff --git a/platform_channels/lib/src/method_channel_demo.dart b/platform_channels/lib/src/method_channel_demo.dart index c993f2746..6b80e5f4a 100644 --- a/platform_channels/lib/src/method_channel_demo.dart +++ b/platform_channels/lib/src/method_channel_demo.dart @@ -29,7 +29,7 @@ class _MethodChannelDemoState extends State { 'Value of count is $count', style: Theme.of(context).textTheme.headline5, ), - SizedBox( + const SizedBox( height: 16, ), Row( @@ -49,8 +49,8 @@ class _MethodChannelDemoState extends State { ); } }, - icon: Icon(Icons.add), - label: Text('Increment'), + icon: const Icon(Icons.add), + label: const Text('Increment'), ), // Whenever users press the ElevatedButton, it invokes @@ -67,8 +67,8 @@ class _MethodChannelDemoState extends State { ); } }, - icon: Icon(Icons.remove), - label: Text('Decrement'), + icon: const Icon(Icons.remove), + label: const Text('Decrement'), ) ], ) diff --git a/platform_channels/lib/src/pet_list_message_channel.dart b/platform_channels/lib/src/pet_list_message_channel.dart index 14410eaea..3db2fc8d0 100644 --- a/platform_channels/lib/src/pet_list_message_channel.dart +++ b/platform_channels/lib/src/pet_list_message_channel.dart @@ -9,10 +9,10 @@ import 'package:flutter/services.dart'; /// This class includes two methods [addPetDetails] and [removePet] which are used /// to add a new pet and remove a pet from the the list respectively. class PetListMessageChannel { - static final _jsonMessageCodecChannel = + static const _jsonMessageCodecChannel = BasicMessageChannel('jsonMessageCodecDemo', JSONMessageCodec()); - static final _binaryCodecChannel = + static const _binaryCodecChannel = BasicMessageChannel('binaryCodecDemo', BinaryCodec()); /// Method to add a new pet to the list. diff --git a/platform_channels/lib/src/pet_list_screen.dart b/platform_channels/lib/src/pet_list_screen.dart index 909815ae1..2775c6244 100644 --- a/platform_channels/lib/src/pet_list_screen.dart +++ b/platform_channels/lib/src/pet_list_screen.dart @@ -22,7 +22,7 @@ class _PetListScreenState extends State { super.initState(); // Receives a string of json object from the platform and converts it // to PetModel. - BasicMessageChannel('stringCodecDemo', StringCodec()) + const BasicMessageChannel('stringCodecDemo', StringCodec()) .setMessageHandler((message) async { if (message == null) { showSnackBar('An error occurred while adding pet details.', context); @@ -40,16 +40,16 @@ class _PetListScreenState extends State { return Scaffold( key: scaffoldKey, appBar: AppBar( - title: Text('Pet List'), + title: const Text('Pet List'), ), floatingActionButton: FloatingActionButton( - child: Icon(Icons.add), + child: const Icon(Icons.add), onPressed: () { Navigator.pushNamed(context, '/addPetDetails'); }, ), body: petListModel?.petList?.isEmpty ?? true - ? Center(child: Text('Enter Pet Details')) + ? const Center(child: Text('Enter Pet Details')) : BuildPetList(petListModel.petList), ); } @@ -59,12 +59,12 @@ class _PetListScreenState extends State { class BuildPetList extends StatelessWidget { final List petList; - BuildPetList(this.petList); + const BuildPetList(this.petList); @override Widget build(BuildContext context) { return ListView.builder( - padding: EdgeInsets.all(8), + padding: const EdgeInsets.all(8), itemCount: petList.length, itemBuilder: (context, index) { return ListTile( @@ -73,7 +73,7 @@ class BuildPetList extends StatelessWidget { 'Pet type: ${petList[index].petType}', ), trailing: IconButton( - icon: Icon(Icons.delete), + icon: const Icon(Icons.delete), onPressed: () async { try { await PetListMessageChannel.removePet(index); diff --git a/platform_channels/lib/src/platform_image_demo.dart b/platform_channels/lib/src/platform_image_demo.dart index 05af6967a..6689e0cae 100644 --- a/platform_channels/lib/src/platform_image_demo.dart +++ b/platform_channels/lib/src/platform_image_demo.dart @@ -24,7 +24,7 @@ class _PlatformImageDemoState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Platform Image Demo'), + title: const Text('Platform Image Demo'), ), body: Center( child: Column( @@ -38,7 +38,7 @@ class _PlatformImageDemoState extends State { future: imageData, builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.none) { - return Placeholder(); + return const Placeholder(); } else if (snapshot.hasError) { return Center( child: Text(snapshot.error.toString()), @@ -50,12 +50,12 @@ class _PlatformImageDemoState extends State { fit: BoxFit.fill, ); } - return CircularProgressIndicator(); + return const CircularProgressIndicator(); }, ), ), ), - SizedBox( + const SizedBox( height: 16, ), ElevatedButton( @@ -66,7 +66,7 @@ class _PlatformImageDemoState extends State { imageData = PlatformImageFetcher.getImage(); }); }, - child: Text('Get Image'), + child: const Text('Get Image'), ) ], ), diff --git a/platform_channels/pubspec.lock b/platform_channels/pubspec.lock index 7323a0126..2c85bc0f8 100644 --- a/platform_channels/pubspec.lock +++ b/platform_channels/pubspec.lock @@ -62,11 +62,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -88,13 +102,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.2" sky_engine: dependency: transitive description: flutter diff --git a/platform_channels/pubspec.yaml b/platform_channels/pubspec.yaml index 44963ead1..fb8b16ea8 100644 --- a/platform_channels/pubspec.yaml +++ b/platform_channels/pubspec.yaml @@ -15,8 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - - pedantic: ^1.9.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/platform_channels/test/src/add_pet_details_test.dart b/platform_channels/test/src/add_pet_details_test.dart index 6486e6672..fc2db28bb 100644 --- a/platform_channels/test/src/add_pet_details_test.dart +++ b/platform_channels/test/src/add_pet_details_test.dart @@ -12,7 +12,8 @@ void main() { var petList = []; setUpAll(() { - BasicMessageChannel('jsonMessageCodecDemo', JSONMessageCodec()) + const BasicMessageChannel( + 'jsonMessageCodecDemo', JSONMessageCodec()) .setMockMessageHandler((dynamic message) async { petList.add(message as Map); }); diff --git a/platform_channels/test/src/method_channel_demo_test.dart b/platform_channels/test/src/method_channel_demo_test.dart index 61c0b4585..2cb743b1a 100644 --- a/platform_channels/test/src/method_channel_demo_test.dart +++ b/platform_channels/test/src/method_channel_demo_test.dart @@ -10,7 +10,7 @@ import 'package:platform_channels/src/method_channel_demo.dart'; void main() { group('MethodChannelDemo tests', () { setUpAll(() { - final methodChannel = MethodChannel('methodChannelDemo'); + const methodChannel = MethodChannel('methodChannelDemo'); // Register a mock MethodCallHandler. methodChannel.setMockMethodCallHandler((call) async { diff --git a/platform_channels/test/src/pet_list_screen_test.dart b/platform_channels/test/src/pet_list_screen_test.dart index d7967695d..0687ab592 100644 --- a/platform_channels/test/src/pet_list_screen_test.dart +++ b/platform_channels/test/src/pet_list_screen_test.dart @@ -12,7 +12,7 @@ import 'package:platform_channels/src/pet_list_screen.dart'; void main() { group('PetListScreen tests', () { - final basicMessageChannel = + const basicMessageChannel = BasicMessageChannel('stringCodecDemo', StringCodec()); var petList = [ @@ -33,7 +33,7 @@ void main() { // Mock for the index received from the Dart to delete the pet details, // and send the updated pet list back to Dart. - BasicMessageChannel('binaryCodecDemo', BinaryCodec()) + const BasicMessageChannel('binaryCodecDemo', BinaryCodec()) .setMockMessageHandler((message) async { // Convert the ByteData to String. final index = utf8.decoder.convert(message.buffer diff --git a/platform_channels/test/src/platform_image_demo_test.dart b/platform_channels/test/src/platform_image_demo_test.dart index eb9459521..d5d736b78 100644 --- a/platform_channels/test/src/platform_image_demo_test.dart +++ b/platform_channels/test/src/platform_image_demo_test.dart @@ -11,7 +11,8 @@ void main() { group('Platform Image Demo tests', () { setUpAll(() { // Register a mock for MessageHandler. - BasicMessageChannel('platformImageDemo', StandardMessageCodec()) + const BasicMessageChannel( + 'platformImageDemo', StandardMessageCodec()) .setMockMessageHandler((dynamic message) async { var byteData = await rootBundle.load('assets/eat_new_orleans.jpg'); return byteData.buffer.asUint8List(); diff --git a/platform_design/analysis_options.yaml b/platform_design/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/platform_design/analysis_options.yaml +++ b/platform_design/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/platform_design/ios/Runner.xcodeproj/project.pbxproj b/platform_design/ios/Runner.xcodeproj/project.pbxproj index 9e2ac78a5..152a559a5 100644 --- a/platform_design/ios/Runner.xcodeproj/project.pbxproj +++ b/platform_design/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/platform_design/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/platform_design/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16e..919434a62 100644 --- a/platform_design/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/platform_design/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/platform_design/lib/main.dart b/platform_design/lib/main.dart index a634de31e..a3b089d55 100644 --- a/platform_design/lib/main.dart +++ b/platform_design/lib/main.dart @@ -30,7 +30,7 @@ class MyAdaptingApp extends StatelessWidget { // Instead of letting Cupertino widgets auto-adapt to the Material // theme (which is green), this app will use a different theme // for Cupertino (which is blue by default). - data: CupertinoThemeData(), + data: const CupertinoThemeData(), child: Material(child: child), ); }, @@ -82,7 +82,7 @@ class _PlatformAdaptingHomePageState extends State { Widget _buildIosHomePage(BuildContext context) { return CupertinoTabScaffold( tabBar: CupertinoTabBar( - items: [ + items: const [ BottomNavigationBarItem( label: SongsTab.title, icon: SongsTab.iosIcon, @@ -116,7 +116,7 @@ class _PlatformAdaptingHomePageState extends State { ); default: assert(false, 'Unexpected tab'); - return SizedBox.shrink(); + return const SizedBox.shrink(); } }, ); @@ -139,7 +139,7 @@ class _AndroidDrawer extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.stretch, children: [ DrawerHeader( - decoration: BoxDecoration(color: Colors.green), + decoration: const BoxDecoration(color: Colors.green), child: Padding( padding: const EdgeInsets.only(bottom: 20), child: Icon( @@ -151,14 +151,14 @@ class _AndroidDrawer extends StatelessWidget { ), ListTile( leading: SongsTab.androidIcon, - title: Text(SongsTab.title), + title: const Text(SongsTab.title), onTap: () { Navigator.pop(context); }, ), ListTile( leading: NewsTab.androidIcon, - title: Text(NewsTab.title), + title: const Text(NewsTab.title), onTap: () { Navigator.pop(context); Navigator.push( @@ -167,7 +167,7 @@ class _AndroidDrawer extends StatelessWidget { ), ListTile( leading: ProfileTab.androidIcon, - title: Text(ProfileTab.title), + title: const Text(ProfileTab.title), onTap: () { Navigator.pop(context); Navigator.push(context, @@ -175,13 +175,13 @@ class _AndroidDrawer extends StatelessWidget { }, ), // Long drawer contents are often segmented. - Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + const Padding( + padding: EdgeInsets.symmetric(horizontal: 16), child: Divider(), ), ListTile( leading: SettingsTab.androidIcon, - title: Text(SettingsTab.title), + title: const Text(SettingsTab.title), onTap: () { Navigator.pop(context); Navigator.push(context, diff --git a/platform_design/lib/news_tab.dart b/platform_design/lib/news_tab.dart index d74f6a2a4..a9aa83166 100644 --- a/platform_design/lib/news_tab.dart +++ b/platform_design/lib/news_tab.dart @@ -41,7 +41,7 @@ class _NewsTabState extends State { bottom: false, child: Card( elevation: 1.5, - margin: EdgeInsets.fromLTRB(6, 12, 6, 0), + margin: const EdgeInsets.fromLTRB(6, 12, 6, 0), shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(4), ), @@ -58,22 +58,22 @@ class _NewsTabState extends State { backgroundColor: colors[index], child: Text( titles[index].substring(0, 1), - style: TextStyle(color: Colors.white), + style: const TextStyle(color: Colors.white), ), ), - Padding(padding: EdgeInsets.only(left: 16)), + const Padding(padding: EdgeInsets.only(left: 16)), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( titles[index], - style: TextStyle( + style: const TextStyle( fontSize: 15, fontWeight: FontWeight.w500, ), ), - Padding(padding: EdgeInsets.only(top: 8)), + const Padding(padding: EdgeInsets.only(top: 8)), Text( contents[index], ), @@ -95,20 +95,18 @@ class _NewsTabState extends State { Widget _buildAndroid(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(NewsTab.title), + title: const Text(NewsTab.title), ), - body: Container( - child: ListView.builder( - itemCount: _itemsLength, - itemBuilder: _listBuilder, - ), + body: ListView.builder( + itemCount: _itemsLength, + itemBuilder: _listBuilder, ), ); } Widget _buildIos(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar(), + navigationBar: const CupertinoNavigationBar(), child: ListView.builder( itemCount: _itemsLength, itemBuilder: _listBuilder, diff --git a/platform_design/lib/profile_tab.dart b/platform_design/lib/profile_tab.dart index 06c106e4b..70b571404 100644 --- a/platform_design/lib/profile_tab.dart +++ b/platform_design/lib/profile_tab.dart @@ -19,7 +19,7 @@ class ProfileTab extends StatelessWidget { padding: const EdgeInsets.all(24.0), child: Column( children: [ - Padding( + const Padding( padding: EdgeInsets.all(8), child: Center( child: Text( @@ -31,7 +31,7 @@ class ProfileTab extends StatelessWidget { ), ), ), - PreferenceCard( + const PreferenceCard( header: 'MY INTENSITY PREFERENCE', content: '🔥', preferenceChoices: [ @@ -42,7 +42,7 @@ class ProfileTab extends StatelessWidget { 'My neighbor hates me', ], ), - PreferenceCard( + const PreferenceCard( header: 'CURRENT MOOD', content: '🤘🏾🚀', preferenceChoices: [ @@ -70,7 +70,7 @@ class ProfileTab extends StatelessWidget { Widget _buildAndroid(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(title), + title: const Text(title), ), body: _buildBody(context), ); @@ -123,18 +123,18 @@ class PreferenceCard extends StatelessWidget { Widget build(context) { return PressableCard( color: Colors.green, - flattenAnimation: AlwaysStoppedAnimation(0), + flattenAnimation: const AlwaysStoppedAnimation(0), child: Stack( children: [ - Container( + SizedBox( height: 120, width: 250, child: Padding( - padding: EdgeInsets.only(top: 40), + padding: const EdgeInsets.only(top: 40), child: Center( child: Text( content, - style: TextStyle(fontSize: 48), + style: const TextStyle(fontSize: 48), ), ), ), @@ -146,11 +146,11 @@ class PreferenceCard extends StatelessWidget { child: Container( color: Colors.black12, height: 40, - padding: EdgeInsets.only(left: 12), + padding: const EdgeInsets.only(left: 12), alignment: Alignment.centerLeft, child: Text( header, - style: TextStyle( + style: const TextStyle( color: Colors.white, fontSize: 14, fontWeight: FontWeight.w600, @@ -182,7 +182,7 @@ class LogOutButton extends StatelessWidget { Widget _buildAndroid(BuildContext context) { return ElevatedButton( - child: Text('LOG OUT', style: TextStyle(color: Colors.red)), + child: const Text('LOG OUT', style: TextStyle(color: Colors.red)), onPressed: () { // You should do something with the result of the dialog prompt in a // real app but this is just a demo. @@ -190,7 +190,7 @@ class LogOutButton extends StatelessWidget { context: context, builder: (context) { return AlertDialog( - title: Text('Log out?'), + title: const Text('Log out?'), content: _logoutMessage, actions: [ TextButton( @@ -212,7 +212,7 @@ class LogOutButton extends StatelessWidget { Widget _buildIos(BuildContext context) { return CupertinoButton( color: CupertinoColors.destructiveRed, - child: Text('Log out'), + child: const Text('Log out'), onPressed: () { // You should do something with the result of the action sheet prompt // in a real app but this is just a demo. @@ -220,7 +220,7 @@ class LogOutButton extends StatelessWidget { context: context, builder: (context) { return CupertinoActionSheet( - title: Text('Log out?'), + title: const Text('Log out?'), message: _logoutMessage, actions: [ CupertinoActionSheetAction( diff --git a/platform_design/lib/settings_tab.dart b/platform_design/lib/settings_tab.dart index 01ec1b99d..ae29d5cf7 100644 --- a/platform_design/lib/settings_tab.dart +++ b/platform_design/lib/settings_tab.dart @@ -28,9 +28,9 @@ class _SettingsTabState extends State { Widget _buildList() { return ListView( children: [ - Padding(padding: EdgeInsets.only(top: 24)), + const Padding(padding: EdgeInsets.only(top: 24)), ListTile( - title: Text('Send me marketing emails'), + title: const Text('Send me marketing emails'), // The Material switch has a platform adaptive constructor. trailing: Switch.adaptive( value: switch1, @@ -38,42 +38,42 @@ class _SettingsTabState extends State { ), ), ListTile( - title: Text('Enable notifications'), + title: const Text('Enable notifications'), trailing: Switch.adaptive( value: switch2, onChanged: (value) => setState(() => switch2 = value), ), ), ListTile( - title: Text('Remind me to rate this app'), + title: const Text('Remind me to rate this app'), trailing: Switch.adaptive( value: switch3, onChanged: (value) => setState(() => switch3 = value), ), ), ListTile( - title: Text('Background song refresh'), + title: const Text('Background song refresh'), trailing: Switch.adaptive( value: switch4, onChanged: (value) => setState(() => switch4 = value), ), ), ListTile( - title: Text('Recommend me songs based on my location'), + title: const Text('Recommend me songs based on my location'), trailing: Switch.adaptive( value: switch5, onChanged: (value) => setState(() => switch5 = value), ), ), ListTile( - title: Text('Auto-transition playback to cast devices'), + title: const Text('Auto-transition playback to cast devices'), trailing: Switch.adaptive( value: switch6, onChanged: (value) => setState(() => switch6 = value), ), ), ListTile( - title: Text('Find friends from my contact list'), + title: const Text('Find friends from my contact list'), trailing: Switch.adaptive( value: switch7, onChanged: (value) => setState(() => switch7 = value), @@ -90,7 +90,7 @@ class _SettingsTabState extends State { Widget _buildAndroid(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(SettingsTab.title), + title: const Text(SettingsTab.title), ), body: _buildList(), ); @@ -98,7 +98,7 @@ class _SettingsTabState extends State { Widget _buildIos(BuildContext context) { return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar(), + navigationBar: const CupertinoNavigationBar(), child: _buildList(), ); } diff --git a/platform_design/lib/song_detail_tab.dart b/platform_design/lib/song_detail_tab.dart index fc91bf213..67811a104 100644 --- a/platform_design/lib/song_detail_tab.dart +++ b/platform_design/lib/song_detail_tab.dart @@ -35,7 +35,7 @@ class SongDetailTab extends StatelessWidget { child: HeroAnimatingSongCard( song: song, color: color, - heroAnimation: AlwaysStoppedAnimation(1), + heroAnimation: const AlwaysStoppedAnimation(1), ), // This app uses a flightShuttleBuilder to specify the exact widget // to build while the hero transition is mid-flight. @@ -50,7 +50,7 @@ class SongDetailTab extends StatelessWidget { ); }, ), - Divider( + const Divider( height: 0, color: Colors.grey, ), @@ -59,9 +59,8 @@ class SongDetailTab extends StatelessWidget { itemCount: 10, itemBuilder: (context, index) { if (index == 0) { - return Padding( - padding: - const EdgeInsets.only(left: 15, top: 16, bottom: 8), + return const Padding( + padding: EdgeInsets.only(left: 15, top: 16, bottom: 8), child: Text( 'You might also like:', style: TextStyle( diff --git a/platform_design/lib/songs_tab.dart b/platform_design/lib/songs_tab.dart index 8fd79b404..6acf3d334 100644 --- a/platform_design/lib/songs_tab.dart +++ b/platform_design/lib/songs_tab.dart @@ -67,7 +67,7 @@ class _SongsTabState extends State { child: HeroAnimatingSongCard( song: songNames[index], color: color, - heroAnimation: AlwaysStoppedAnimation(0), + heroAnimation: const AlwaysStoppedAnimation(0), onPressed: () => Navigator.of(context).push( MaterialPageRoute( builder: (context) => SongDetailTab( @@ -113,15 +113,15 @@ class _SongsTabState extends State { Widget _buildAndroid(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text(SongsTab.title), + title: const Text(SongsTab.title), actions: [ IconButton( - icon: Icon(Icons.refresh), + icon: const Icon(Icons.refresh), onPressed: () async => await _androidRefreshKey.currentState!.show(), ), IconButton( - icon: Icon(Icons.shuffle), + icon: const Icon(Icons.shuffle), onPressed: _togglePlatform, ), ], @@ -131,7 +131,7 @@ class _SongsTabState extends State { key: _androidRefreshKey, onRefresh: _refreshData, child: ListView.builder( - padding: EdgeInsets.symmetric(vertical: 12), + padding: const EdgeInsets.symmetric(vertical: 12), itemCount: _itemsLength, itemBuilder: _listBuilder, ), @@ -145,7 +145,7 @@ class _SongsTabState extends State { CupertinoSliverNavigationBar( trailing: CupertinoButton( padding: EdgeInsets.zero, - child: Icon(CupertinoIcons.shuffle), + child: const Icon(CupertinoIcons.shuffle), onPressed: _togglePlatform, ), ), @@ -155,7 +155,7 @@ class _SongsTabState extends State { SliverSafeArea( top: false, sliver: SliverPadding( - padding: EdgeInsets.symmetric(vertical: 12), + padding: const EdgeInsets.symmetric(vertical: 12), sliver: SliverList( delegate: SliverChildBuilderDelegate( _listBuilder, diff --git a/platform_design/lib/widgets.dart b/platform_design/lib/widgets.dart index 89e3263df..7645010da 100644 --- a/platform_design/lib/widgets.dart +++ b/platform_design/lib/widgets.dart @@ -26,7 +26,7 @@ class PlatformWidget extends StatelessWidget { return iosBuilder(context); default: assert(false, 'Unexpected platform $defaultTargetPlatform'); - return SizedBox.shrink(); + return const SizedBox.shrink(); } } } @@ -107,8 +107,9 @@ class _PressableCardState extends State // in your own app. scale: 1 - elevationAnimation.value * 0.03, child: Padding( - padding: EdgeInsets.symmetric(vertical: 16, horizontal: 16) * - flatten, + padding: + const EdgeInsets.symmetric(vertical: 16, horizontal: 16) * + flatten, child: PhysicalModel( elevation: ((1 - elevationAnimation.value) * 10 + 10) * flatten, @@ -134,7 +135,7 @@ class _PressableCardState extends State /// This is an example of a custom widget that an app developer might create for /// use on both iOS and Android as part of their brand's unique design. class HeroAnimatingSongCard extends StatelessWidget { - HeroAnimatingSongCard({ + const HeroAnimatingSongCard({ required this.song, required this.color, required this.heroAnimation, @@ -177,10 +178,10 @@ class HeroAnimatingSongCard extends StatelessWidget { height: 80, color: Colors.black12, alignment: Alignment.centerLeft, - padding: EdgeInsets.symmetric(horizontal: 12), + padding: const EdgeInsets.symmetric(horizontal: 12), child: Text( song, - style: TextStyle( + style: const TextStyle( fontSize: 21, fontWeight: FontWeight.w500, ), @@ -189,12 +190,12 @@ class HeroAnimatingSongCard extends StatelessWidget { ), // The play button grows in the hero animation. Padding( - padding: - EdgeInsets.only(bottom: 45) * (1 - heroAnimation.value), + padding: const EdgeInsets.only(bottom: 45) * + (1 - heroAnimation.value), child: Container( height: playButtonSize, width: playButtonSize, - decoration: BoxDecoration( + decoration: const BoxDecoration( shape: BoxShape.circle, color: Colors.black12, ), @@ -222,14 +223,14 @@ class SongPlaceholderTile extends StatelessWidget { return SizedBox( height: 95, child: Padding( - padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8), + padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8), child: Row( children: [ Container( color: Theme.of(context).textTheme.bodyText2!.color, width: 130, ), - Padding( + const Padding( padding: EdgeInsets.only(left: 12), ), Expanded( @@ -238,27 +239,27 @@ class SongPlaceholderTile extends StatelessWidget { children: [ Container( height: 9, - margin: EdgeInsets.only(right: 60), + margin: const EdgeInsets.only(right: 60), color: Theme.of(context).textTheme.bodyText2!.color, ), Container( height: 9, - margin: EdgeInsets.only(right: 20, top: 8), + margin: const EdgeInsets.only(right: 20, top: 8), color: Theme.of(context).textTheme.bodyText2!.color, ), Container( height: 9, - margin: EdgeInsets.only(right: 40, top: 8), + margin: const EdgeInsets.only(right: 40, top: 8), color: Theme.of(context).textTheme.bodyText2!.color, ), Container( height: 9, - margin: EdgeInsets.only(right: 80, top: 8), + margin: const EdgeInsets.only(right: 80, top: 8), color: Theme.of(context).textTheme.bodyText2!.color, ), Container( height: 9, - margin: EdgeInsets.only(right: 50, top: 8), + margin: const EdgeInsets.only(right: 50, top: 8), color: Theme.of(context).textTheme.bodyText2!.color, ), ], @@ -289,7 +290,7 @@ void showChoices(BuildContext context, List choices) { builder: (context) { int? selectedRadio = 1; return AlertDialog( - contentPadding: EdgeInsets.only(top: 12), + contentPadding: const EdgeInsets.only(top: 12), content: StatefulBuilder( builder: (context, setState) { return Column( @@ -309,11 +310,11 @@ void showChoices(BuildContext context, List choices) { ), actions: [ TextButton( - child: Text('OK'), + child: const Text('OK'), onPressed: () => Navigator.of(context).pop(), ), TextButton( - child: Text('CANCEL'), + child: const Text('CANCEL'), onPressed: () => Navigator.of(context).pop(), ), ], @@ -337,7 +338,7 @@ void showChoices(BuildContext context, List choices) { return Center( child: Text( choices[index], - style: TextStyle( + style: const TextStyle( fontSize: 21, ), ), diff --git a/platform_design/pubspec.lock b/platform_design/pubspec.lock index 4b9da3483..3294c3bed 100644 --- a/platform_design/pubspec.lock +++ b/platform_design/pubspec.lock @@ -56,7 +56,7 @@ packages: name: english_words url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.0" + version: "4.0.0" fake_async: dependency: transitive description: @@ -69,6 +69,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_lorem: dependency: "direct main" description: @@ -81,6 +88,13 @@ packages: description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -102,13 +116,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" sky_engine: dependency: transitive description: flutter diff --git a/platform_design/pubspec.yaml b/platform_design/pubspec.yaml index 4f0aa33d7..e0d70976c 100644 --- a/platform_design/pubspec.yaml +++ b/platform_design/pubspec.yaml @@ -3,10 +3,10 @@ description: A project showcasing a Flutter app following different platform IA version: 1.0.0+1 environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: - english_words: ^4.0.0-nullsafety.0 + english_words: ^4.0.0 flutter_lorem: ^2.0.0 flutter: sdk: flutter @@ -16,7 +16,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.10.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/platform_view_swift/analysis_options.yaml b/platform_view_swift/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/platform_view_swift/analysis_options.yaml +++ b/platform_view_swift/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/platform_view_swift/lib/main.dart b/platform_view_swift/lib/main.dart index 1f78da2cc..6b0eea99c 100644 --- a/platform_view_swift/lib/main.dart +++ b/platform_view_swift/lib/main.dart @@ -49,7 +49,7 @@ class _HomePageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Home page'), + title: const Text('Home page'), ), body: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -63,7 +63,7 @@ class _HomePageState extends State { 'Button tapped $_counter time${_counter == 1 ? '' : 's'}.', style: Theme.of(context).textTheme.subtitle2, ), - SizedBox(height: 18), + const SizedBox(height: 18), ElevatedButton( child: const Text('Continue in iOS view'), onPressed: _launchPlatformCount, @@ -76,7 +76,7 @@ class _HomePageState extends State { padding: const EdgeInsets.only(bottom: 15, left: 5), child: Row( children: [ - FlutterLogo(), + const FlutterLogo(), Text( 'Flutter', style: Theme.of(context).textTheme.headline5, diff --git a/platform_view_swift/pubspec.lock b/platform_view_swift/pubspec.lock index 6f7c51ac2..aab87e4d8 100644 --- a/platform_view_swift/pubspec.lock +++ b/platform_view_swift/pubspec.lock @@ -62,11 +62,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -88,13 +102,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.9.2" sky_engine: dependency: transitive description: flutter diff --git a/platform_view_swift/pubspec.yaml b/platform_view_swift/pubspec.yaml index 0790bb986..1016acaa1 100644 --- a/platform_view_swift/pubspec.yaml +++ b/platform_view_swift/pubspec.yaml @@ -15,9 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.9.0 + flutter_lints: ^1.0.0 flutter: - uses-material-design: true - diff --git a/provider_counter/analysis_options.yaml b/provider_counter/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/provider_counter/analysis_options.yaml +++ b/provider_counter/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/provider_counter/ios/Runner.xcodeproj/project.pbxproj b/provider_counter/ios/Runner.xcodeproj/project.pbxproj index 29116b53d..669f0f641 100644 --- a/provider_counter/ios/Runner.xcodeproj/project.pbxproj +++ b/provider_counter/ios/Runner.xcodeproj/project.pbxproj @@ -241,7 +241,6 @@ /* Begin XCBuildConfiguration section */ 249021D3217E4FDB00AE95B9 /* Profile */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -318,7 +317,6 @@ }; 97C147031CF9000F007C117D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; @@ -374,7 +372,6 @@ }; 97C147041CF9000F007C117D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_ANALYZER_NONNULL = YES; diff --git a/provider_counter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/provider_counter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16e..919434a62 100644 --- a/provider_counter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/provider_counter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/provider_counter/lib/main.dart b/provider_counter/lib/main.dart index 2ce4f4bf0..6b3dec60e 100644 --- a/provider_counter/lib/main.dart +++ b/provider_counter/lib/main.dart @@ -54,13 +54,13 @@ class MyHomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Flutter Demo Home Page'), + title: const Text('Flutter Demo Home Page'), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text('You have pushed the button this many times:'), + const Text('You have pushed the button this many times:'), // Consumer looks for an ancestor Provider widget // and retrieves its model (Counter, in this case). // Then it uses that model to build widgets, and will trigger @@ -96,7 +96,7 @@ class MyHomePage extends StatelessWidget { counter.increment(); }, tooltip: 'Increment', - child: Icon(Icons.add), + child: const Icon(Icons.add), ), ); } diff --git a/provider_counter/pubspec.lock b/provider_counter/pubspec.lock index 606b7c6e0..5aec9ed9b 100644 --- a/provider_counter/pubspec.lock +++ b/provider_counter/pubspec.lock @@ -49,7 +49,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -62,11 +62,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -95,20 +109,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.5" + version: "5.0.0" sky_engine: dependency: transitive description: flutter diff --git a/provider_counter/pubspec.yaml b/provider_counter/pubspec.yaml index a9588f248..8146fcb4d 100644 --- a/provider_counter/pubspec.yaml +++ b/provider_counter/pubspec.yaml @@ -11,13 +11,13 @@ dependencies: flutter: sdk: flutter - provider: ^5.0.0-nullsafety.5 - cupertino_icons: ^1.0.2 + provider: ^5.0.0 + cupertino_icons: ^1.0.3 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.10.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/provider_shopper/analysis_options.yaml b/provider_shopper/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/provider_shopper/analysis_options.yaml +++ b/provider_shopper/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/provider_shopper/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/provider_shopper/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16e..919434a62 100644 --- a/provider_shopper/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/provider_shopper/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/provider_shopper/lib/common/theme.dart b/provider_shopper/lib/common/theme.dart index d76612720..34f10f83c 100644 --- a/provider_shopper/lib/common/theme.dart +++ b/provider_shopper/lib/common/theme.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; final appTheme = ThemeData( primarySwatch: Colors.yellow, - textTheme: TextTheme( + textTheme: const TextTheme( headline1: TextStyle( fontFamily: 'Corben', fontWeight: FontWeight.w700, diff --git a/provider_shopper/lib/screens/cart.dart b/provider_shopper/lib/screens/cart.dart index c155256f2..75d76f158 100644 --- a/provider_shopper/lib/screens/cart.dart +++ b/provider_shopper/lib/screens/cart.dart @@ -24,7 +24,7 @@ class MyCart extends StatelessWidget { child: _CartList(), ), ), - Divider(height: 4, color: Colors.black), + const Divider(height: 4, color: Colors.black), _CartTotal() ], ), @@ -45,9 +45,9 @@ class _CartList extends StatelessWidget { return ListView.builder( itemCount: cart.items.length, itemBuilder: (context, index) => ListTile( - leading: Icon(Icons.done), + leading: const Icon(Icons.done), trailing: IconButton( - icon: Icon(Icons.remove_circle_outline), + icon: const Icon(Icons.remove_circle_outline), onPressed: () { cart.remove(cart.items[index]); }, @@ -82,14 +82,14 @@ class _CartTotal extends StatelessWidget { Consumer( builder: (context, cart, child) => Text('\$${cart.totalPrice}', style: hugeStyle)), - SizedBox(width: 24), + const SizedBox(width: 24), TextButton( onPressed: () { ScaffoldMessenger.of(context).showSnackBar( - SnackBar(content: Text('Buying not supported yet.'))); + const SnackBar(content: Text('Buying not supported yet.'))); }, style: TextButton.styleFrom(primary: Colors.white), - child: Text('BUY'), + child: const Text('BUY'), ), ], ), diff --git a/provider_shopper/lib/screens/catalog.dart b/provider_shopper/lib/screens/catalog.dart index c9e7d2a7a..4b765324d 100644 --- a/provider_shopper/lib/screens/catalog.dart +++ b/provider_shopper/lib/screens/catalog.dart @@ -14,7 +14,7 @@ class MyCatalog extends StatelessWidget { body: CustomScrollView( slivers: [ _MyAppBar(), - SliverToBoxAdapter(child: SizedBox(height: 12)), + const SliverToBoxAdapter(child: SizedBox(height: 12)), SliverList( delegate: SliverChildBuilderDelegate( (context, index) => _MyListItem(index)), @@ -62,7 +62,9 @@ class _AddButton extends StatelessWidget { return null; // Defer to the widget's default. }), ), - child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'), + child: isInCart + ? const Icon(Icons.check, semanticLabel: 'ADDED') + : const Text('ADD'), ); } } @@ -75,7 +77,7 @@ class _MyAppBar extends StatelessWidget { floating: true, actions: [ IconButton( - icon: Icon(Icons.shopping_cart), + icon: const Icon(Icons.shopping_cart), onPressed: () => Navigator.pushNamed(context, '/cart'), ), ], @@ -86,7 +88,7 @@ class _MyAppBar extends StatelessWidget { class _MyListItem extends StatelessWidget { final int index; - _MyListItem(this.index, {Key? key}) : super(key: key); + const _MyListItem(this.index, {Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -109,11 +111,11 @@ class _MyListItem extends StatelessWidget { color: item.color, ), ), - SizedBox(width: 24), + const SizedBox(width: 24), Expanded( child: Text(item.name, style: textTheme), ), - SizedBox(width: 24), + const SizedBox(width: 24), _AddButton(item: item), ], ), diff --git a/provider_shopper/lib/screens/login.dart b/provider_shopper/lib/screens/login.dart index 220ce7e39..46343ca77 100644 --- a/provider_shopper/lib/screens/login.dart +++ b/provider_shopper/lib/screens/login.dart @@ -10,7 +10,7 @@ class MyLogin extends StatelessWidget { return Scaffold( body: Center( child: Container( - padding: EdgeInsets.all(80.0), + padding: const EdgeInsets.all(80.0), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ @@ -19,21 +19,21 @@ class MyLogin extends StatelessWidget { style: Theme.of(context).textTheme.headline1, ), TextFormField( - decoration: InputDecoration( + decoration: const InputDecoration( hintText: 'Username', ), ), TextFormField( - decoration: InputDecoration( + decoration: const InputDecoration( hintText: 'Password', ), obscureText: true, ), - SizedBox( + const SizedBox( height: 24, ), ElevatedButton( - child: Text('ENTER'), + child: const Text('ENTER'), onPressed: () { Navigator.pushReplacementNamed(context, '/catalog'); }, diff --git a/provider_shopper/pubspec.lock b/provider_shopper/pubspec.lock index 4196e3796..421c3deee 100644 --- a/provider_shopper/pubspec.lock +++ b/provider_shopper/pubspec.lock @@ -55,11 +55,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -88,20 +102,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.0" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.10.0" provider: dependency: "direct main" description: name: provider url: "https://pub.dartlang.org" source: hosted - version: "5.0.0-nullsafety.5" + version: "5.0.0" sky_engine: dependency: transitive description: flutter diff --git a/provider_shopper/pubspec.yaml b/provider_shopper/pubspec.yaml index 2aa55e913..df66d3e19 100644 --- a/provider_shopper/pubspec.yaml +++ b/provider_shopper/pubspec.yaml @@ -4,19 +4,19 @@ description: A shopping app sample that uses Provider for state management. version: 1.0.0+1 environment: - sdk: '>=2.12.0-259.16.beta <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: sdk: flutter # Import the provider package. - provider: '>=5.0.0-nullsafety.5 <6.0.0' + provider: ^5.0.0 dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.10.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/testing_app/analysis_options.yaml b/testing_app/analysis_options.yaml index f5c207c72..be4f27226 100644 --- a/testing_app/analysis_options.yaml +++ b/testing_app/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,15 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/testing_app/integration_test/app_test.dart b/testing_app/integration_test/app_test.dart index f08a5c62d..b97825c6d 100644 --- a/testing_app/integration_test/app_test.dart +++ b/testing_app/integration_test/app_test.dart @@ -15,7 +15,7 @@ void main() { await tester.pumpWidget(TestingApp()); // Create variables for finders that are used multiple times. - final itemFinder = find.byKey(ValueKey('text_25')); + final itemFinder = find.byKey(const ValueKey('text_25')); // Scroll until the item to be found appears. await tester.scrollUntilVisible( @@ -31,22 +31,22 @@ void main() { await tester.pumpWidget(TestingApp()); // Create a finder for the icon. - final iconFinder = find.byKey(ValueKey('icon_0')); + final iconFinder = find.byKey(const ValueKey('icon_0')); // Tap on the icon. await tester.tap(iconFinder); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if appropriate message appears. expect(find.text('Added to favorites.'), findsOneWidget); // Tap on the icon again. await tester.tap(iconFinder); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if appropriate message appears. expect(find.text('Removed from favorites.'), findsOneWidget); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); }); testWidgets('Verifying whether item gets added to favorites', @@ -54,8 +54,8 @@ void main() { await tester.pumpWidget(TestingApp()); // Add item to favorites. - await tester.tap(find.byKey(ValueKey('icon_5'))); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.tap(find.byKey(const ValueKey('icon_5'))); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Tap on the favorites button on the AppBar. // The Favorites List should appear. @@ -63,7 +63,10 @@ void main() { await tester.pumpAndSettle(); // Check if the added item has appeared in the list. - expect(tester.widget(find.byKey(ValueKey('favorites_text_5'))).data, + expect( + tester + .widget(find.byKey(const ValueKey('favorites_text_5'))) + .data, equals('Item 5')); }); @@ -71,16 +74,16 @@ void main() { await tester.pumpWidget(TestingApp()); // Add item to favorites. - await tester.tap(find.byKey(ValueKey('icon_5'))); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.tap(find.byKey(const ValueKey('icon_5'))); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Navigate to Favorites screen. await tester.tap(find.text('Favorites')); await tester.pumpAndSettle(); // Tap on the remove icon. - await tester.tap(find.byKey(ValueKey('remove_icon_5'))); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.tap(find.byKey(const ValueKey('remove_icon_5'))); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if it disappears. expect(find.text('Item 5'), findsNothing); diff --git a/testing_app/integration_test/perf_test.dart b/testing_app/integration_test/perf_test.dart index 968a63fb1..88a2c8b40 100644 --- a/testing_app/integration_test/perf_test.dart +++ b/testing_app/integration_test/perf_test.dart @@ -66,7 +66,7 @@ void main() { for (var icon in iconKeys) { // Tap onto the icon. await tester.tap(find.byKey(ValueKey(icon))); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if appropriate message appears. expect(find.text('Added to favorites.'), findsOneWidget); @@ -87,7 +87,7 @@ void main() { for (final iconKey in removeIconKeys) { // Tap onto the remove icon. await tester.tap(find.byKey(ValueKey(iconKey))); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if appropriate message appears. expect(find.text('Removed from favorites.'), findsOneWidget); diff --git a/testing_app/lib/screens/favorites.dart b/testing_app/lib/screens/favorites.dart index cf63e27ea..a0ae28a5d 100644 --- a/testing_app/lib/screens/favorites.dart +++ b/testing_app/lib/screens/favorites.dart @@ -13,7 +13,7 @@ class FavoritesPage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Favorites'), + title: const Text('Favorites'), ), body: Consumer( builder: (context, value, child) => value.items.isNotEmpty @@ -23,7 +23,7 @@ class FavoritesPage extends StatelessWidget { itemBuilder: (context, index) => FavoriteItemTile(value.items[index]), ) - : Center( + : const Center( child: Text('No favorites added.'), ), ), @@ -52,11 +52,11 @@ class FavoriteItemTile extends StatelessWidget { ), trailing: IconButton( key: Key('remove_icon_$itemNo'), - icon: Icon(Icons.close), + icon: const Icon(Icons.close), onPressed: () { Provider.of(context, listen: false).remove(itemNo); ScaffoldMessenger.of(context).showSnackBar( - SnackBar( + const SnackBar( content: Text('Removed from favorites.'), duration: Duration(seconds: 1), ), diff --git a/testing_app/lib/screens/home.dart b/testing_app/lib/screens/home.dart index 56c4a6fda..15f2074dd 100644 --- a/testing_app/lib/screens/home.dart +++ b/testing_app/lib/screens/home.dart @@ -14,15 +14,15 @@ class HomePage extends StatelessWidget { Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('Testing Sample'), + title: const Text('Testing Sample'), actions: [ TextButton.icon( style: TextButton.styleFrom(primary: Colors.white), onPressed: () { Navigator.pushNamed(context, FavoritesPage.routeName); }, - icon: Icon(Icons.favorite_border), - label: Text('Favorites'), + icon: const Icon(Icons.favorite_border), + label: const Text('Favorites'), ), ], ), @@ -61,8 +61,8 @@ class ItemTile extends StatelessWidget { trailing: IconButton( key: Key('icon_$itemNo'), icon: favoritesList.items.contains(itemNo) - ? Icon(Icons.favorite) - : Icon(Icons.favorite_border), + ? const Icon(Icons.favorite) + : const Icon(Icons.favorite_border), onPressed: () { !favoritesList.items.contains(itemNo) ? favoritesList.add(itemNo) @@ -72,7 +72,7 @@ class ItemTile extends StatelessWidget { content: Text(favoritesList.items.contains(itemNo) ? 'Added to favorites.' : 'Removed from favorites.'), - duration: Duration(seconds: 1), + duration: const Duration(seconds: 1), ), ); }, diff --git a/testing_app/pubspec.lock b/testing_app/pubspec.lock index 180f075a0..b72694deb 100644 --- a/testing_app/pubspec.lock +++ b/testing_app/pubspec.lock @@ -130,6 +130,13 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -180,6 +187,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" logging: dependency: transitive description: @@ -237,7 +251,7 @@ packages: source: hosted version: "1.8.0" pedantic: - dependency: "direct dev" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" diff --git a/testing_app/pubspec.yaml b/testing_app/pubspec.yaml index ede98a463..3469a1750 100644 --- a/testing_app/pubspec.yaml +++ b/testing_app/pubspec.yaml @@ -4,7 +4,7 @@ description: A sample that shows testing in Flutter. version: 1.0.0+1 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: ">=2.12.0 <3.0.0" dependencies: flutter: @@ -19,7 +19,7 @@ dev_dependencies: flutter_test: sdk: flutter test: ^1.16.8 - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 flutter: uses-material-design: true diff --git a/testing_app/test/home_test.dart b/testing_app/test/home_test.dart index a008beaa3..52d758111 100644 --- a/testing_app/test/home_test.dart +++ b/testing_app/test/home_test.dart @@ -31,7 +31,7 @@ void main() { expect(find.text('Item 0'), findsOneWidget); // Fling i.e scroll down. - await tester.fling(find.byType(ListView), Offset(0, -200), 3000); + await tester.fling(find.byType(ListView), const Offset(0, -200), 3000); await tester.pumpAndSettle(); // Check if "Item 0" disappeared. @@ -46,7 +46,7 @@ void main() { // Tap the first item's icon to add it to favorites. await tester.tap(find.byIcon(Icons.favorite_border).first); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if the appropriate message is shown. expect(find.text('Added to favorites.'), findsOneWidget); @@ -57,7 +57,7 @@ void main() { // Tap the first item's icon which has filled icon to // remove it from favorites. await tester.tap(find.byIcon(Icons.favorite).first); - await tester.pumpAndSettle(Duration(seconds: 1)); + await tester.pumpAndSettle(const Duration(seconds: 1)); // Verify if the appropriate message is shown. expect(find.text('Removed from favorites.'), findsOneWidget); diff --git a/veggieseasons/analysis_options.yaml b/veggieseasons/analysis_options.yaml index c64725cc6..30ac27228 100644 --- a/veggieseasons/analysis_options.yaml +++ b/veggieseasons/analysis_options.yaml @@ -1,4 +1,4 @@ -include: package:pedantic/analysis_options.1.9.0.yaml +include: package:flutter_lints/flutter.yaml analyzer: strong-mode: @@ -7,25 +7,14 @@ analyzer: linter: rules: - - avoid_types_on_closure_parameters - - avoid_void_async - - await_only_futures - - camel_case_types - - cancel_subscriptions - - close_sinks - - constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_statements - - hash_and_equals - - implementation_imports - - non_constant_identifier_names - - package_api_docs - - package_names - - package_prefixed_library_names - - test_types_in_equals - - throw_in_finally - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_new - - unnecessary_statements + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/veggieseasons/lib/data/local_veggie_provider.dart b/veggieseasons/lib/data/local_veggie_provider.dart index 5f7e5e71d..5064bfcf4 100644 --- a/veggieseasons/lib/data/local_veggie_provider.dart +++ b/veggieseasons/lib/data/local_veggie_provider.dart @@ -13,13 +13,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/apple.jpg', category: VeggieCategory.fruit, shortDescription: 'Green or red, they\'re generally round and tasty.', - accentColor: Color(0x40de8c66), + accentColor: const Color(0x40de8c66), seasons: [Season.winter, Season.spring, Season.summer, Season.autumn], vitaminAPercentage: 2, vitaminCPercentage: 8, servingSize: 'One large apple', caloriesPerServing: 130, - trivia: [ + trivia: const [ Trivia( 'A peck of apples (that\'s a real unit of mesaurement!) weighs approximately how many pounds?', [ @@ -91,13 +91,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/artichoke.jpg', category: VeggieCategory.flower, shortDescription: 'The armadillo of vegetables.', - accentColor: Color(0x408ea26d), + accentColor: const Color(0x408ea26d), seasons: [Season.spring, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 25, servingSize: '1 medium artichoke', caloriesPerServing: 60, - trivia: [ + trivia: const [ Trivia( 'Artichokes are which part of the plant?', [ @@ -142,13 +142,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/asparagus.jpg', category: VeggieCategory.fern, shortDescription: 'It\'s been used a food and medicine for millenia.', - accentColor: Color(0x408cb437), + accentColor: const Color(0x408cb437), seasons: [Season.spring], vitaminAPercentage: 10, vitaminCPercentage: 15, servingSize: '5 spears', caloriesPerServing: 20, - trivia: [ + trivia: const [ Trivia( 'The nodules at the tip of an asparagus spear are actually which part of the plant?', [ @@ -193,13 +193,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/avocado.jpg', category: VeggieCategory.stealthFruit, shortDescription: 'One of the oiliest, richest fruits money can buy.', - accentColor: Color(0x40b0ba59), + accentColor: const Color(0x40b0ba59), seasons: [Season.winter, Season.spring, Season.summer], vitaminAPercentage: 0, vitaminCPercentage: 4, servingSize: '1/5 medium avocado', caloriesPerServing: 50, - trivia: [ + trivia: const [ Trivia( 'What\'s the most popular variety of avocado?', [ @@ -244,13 +244,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/blackberry.jpg', category: VeggieCategory.berry, shortDescription: 'Find them on backroads and fences in the Northwest.', - accentColor: Color(0x409d5adb), + accentColor: const Color(0x409d5adb), seasons: [Season.summer], vitaminAPercentage: 6, vitaminCPercentage: 4, servingSize: '1 cup', caloriesPerServing: 62, - trivia: [ + trivia: const [ Trivia( 'What color are unripe blackberries?', [ @@ -286,13 +286,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/cantaloupe.jpg', category: VeggieCategory.melon, shortDescription: 'A fruit so tasty there\'s a utensil just for it.', - accentColor: Color(0x40f6bd56), + accentColor: const Color(0x40f6bd56), seasons: [Season.summer], vitaminAPercentage: 120, vitaminCPercentage: 80, servingSize: '1/4 medium cantaloupe', caloriesPerServing: 50, - trivia: [ + trivia: const [ Trivia( 'Which of these is another name for cantaloupe?', [ @@ -337,13 +337,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/cauliflower.jpg', category: VeggieCategory.cruciferous, shortDescription: 'Looks like white broccoli and explodes when cut.', - accentColor: Color(0x40c891a8), + accentColor: const Color(0x40c891a8), seasons: [Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 100, servingSize: '1/6 medium head', caloriesPerServing: 25, - trivia: [ + trivia: const [ Trivia( 'The quote "Cauliflower is nothing but cabbage with a college education" is attributed to whom?', [ @@ -397,13 +397,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/endive.jpg', category: VeggieCategory.leafy, shortDescription: 'It\'s basically the veal of lettuce.', - accentColor: Color(0x40c5be53), + accentColor: const Color(0x40c5be53), seasons: [Season.winter, Season.spring, Season.autumn], vitaminAPercentage: 10, vitaminCPercentage: 2, servingSize: '1/2 cup, chopped', caloriesPerServing: 4, - trivia: [ + trivia: const [ Trivia( 'What\'s another name for Belgian endive?', [ @@ -439,13 +439,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/fig.jpg', category: VeggieCategory.fruit, shortDescription: 'Delicious when sliced and wrapped in prosciutto.', - accentColor: Color(0x40aa6d7c), + accentColor: const Color(0x40aa6d7c), seasons: [Season.summer, Season.autumn], vitaminAPercentage: 2, vitaminCPercentage: 2, servingSize: '1 large fig', caloriesPerServing: 50, - trivia: [ + trivia: const [ Trivia( 'Which of these isn\'t a variety of figs?', [ @@ -481,13 +481,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/grape.jpg', category: VeggieCategory.berry, shortDescription: 'Couldn\'t have wine without them.', - accentColor: Color(0x40ac708a), + accentColor: const Color(0x40ac708a), seasons: [Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 2, servingSize: '3/4 cup', caloriesPerServing: 90, - trivia: [ + trivia: const [ Trivia( 'How long ago were grapes introduced to the Americas?', [ @@ -532,13 +532,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/green_bell_pepper.jpg', category: VeggieCategory.stealthFruit, shortDescription: 'Pleasantly bitter, like a sad movie.', - accentColor: Color(0x408eb332), + accentColor: const Color(0x408eb332), seasons: [Season.summer], vitaminAPercentage: 4, vitaminCPercentage: 190, servingSize: '1 medium pepper', caloriesPerServing: 25, - trivia: [ + trivia: const [ Trivia( 'What\'s the Australian term for a bell pepper?', [ @@ -574,13 +574,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/habanero.jpg', category: VeggieCategory.stealthFruit, shortDescription: 'Delicious... in extremely small quantities.', - accentColor: Color(0x40ff7a01), + accentColor: const Color(0x40ff7a01), seasons: [Season.summer, Season.autumn], vitaminAPercentage: 9, vitaminCPercentage: 100, servingSize: '1 pepper', caloriesPerServing: 20, - trivia: [ + trivia: const [ Trivia( 'How high can habaneros rate on the Scoville scale?', [ @@ -616,13 +616,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/kale.jpg', category: VeggieCategory.cruciferous, shortDescription: 'The meanest vegetable. Does not want to be eaten.', - accentColor: Color(0x40a86bd8), + accentColor: const Color(0x40a86bd8), seasons: [Season.winter, Season.autumn], vitaminAPercentage: 133, vitaminCPercentage: 134, servingSize: '1 cup, chopped', caloriesPerServing: 33, - trivia: [ + trivia: const [ Trivia( 'Kale is sweeter when harvested after what?', [ @@ -658,13 +658,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/kiwi.jpg', category: VeggieCategory.berry, shortDescription: 'Also known as Chinese gooseberry.', - accentColor: Color(0x40b47b37), + accentColor: const Color(0x40b47b37), seasons: [Season.summer], vitaminAPercentage: 2, vitaminCPercentage: 240, servingSize: '2 medium kiwis', caloriesPerServing: 90, - trivia: [ + trivia: const [ Trivia( 'Europeans sometimes refer to kiwi as what?', [ @@ -700,13 +700,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/lemon.jpg', category: VeggieCategory.citrus, shortDescription: 'Similar to limes, only yellow.', - accentColor: Color(0x40e2a500), + accentColor: const Color(0x40e2a500), seasons: [Season.winter], vitaminAPercentage: 0, vitaminCPercentage: 40, servingSize: '1 medium lemon', caloriesPerServing: 15, - trivia: [ + trivia: const [ Trivia( 'A lemon tree can produce up to how many pounds of fruit each year?', [ @@ -751,13 +751,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/lime.jpg', category: VeggieCategory.citrus, shortDescription: 'Couldn\'t have ceviche and margaritas without them.', - accentColor: Color(0x4089b733), + accentColor: const Color(0x4089b733), seasons: [Season.winter], vitaminAPercentage: 0, vitaminCPercentage: 35, servingSize: '1 medium lime', caloriesPerServing: 20, - trivia: [ + trivia: const [ Trivia( 'Which American state is famous for its Key Lime Pie?', [ @@ -793,13 +793,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/mango.jpg', category: VeggieCategory.tropical, shortDescription: 'A fun orange fruit popular with smoothie enthusiasts.', - accentColor: Color(0x40fcc93c), + accentColor: const Color(0x40fcc93c), seasons: [Season.summer, Season.autumn], vitaminAPercentage: 72, vitaminCPercentage: 203, servingSize: '1 fruit', caloriesPerServing: 201, - trivia: [ + trivia: const [ Trivia( 'In Mexico, mangos are frequently dusted with what spices before being eaten as a snack?', [ @@ -835,13 +835,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/mushroom.jpg', category: VeggieCategory.fungus, shortDescription: 'They\'re not truffles, but they\'re still tasty.', - accentColor: Color(0x40ba754b), + accentColor: const Color(0x40ba754b), seasons: [Season.spring, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 2, servingSize: '5 medium \'shrooms', caloriesPerServing: 20, - trivia: [ + trivia: const [ Trivia( 'Someone who loves eating mushrooms is called what?', [ @@ -886,13 +886,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/nectarine.jpg', category: VeggieCategory.stoneFruit, shortDescription: 'Tiny, bald peaches.', - accentColor: Color(0x40e45b3b), + accentColor: const Color(0x40e45b3b), seasons: [Season.summer], vitaminAPercentage: 8, vitaminCPercentage: 15, servingSize: '1 medium nectarine', caloriesPerServing: 60, - trivia: [ + trivia: const [ Trivia( 'Nectarines are technically a variety of which other fruit?', [ @@ -928,13 +928,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/persimmon.jpg', category: VeggieCategory.fruit, shortDescription: 'It\'s like a plum and an apple had a baby together.', - accentColor: Color(0x40979852), + accentColor: const Color(0x40979852), seasons: [Season.winter, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 27, servingSize: '1 fruit', caloriesPerServing: 32, - trivia: [ + trivia: const [ Trivia( 'What\'s the most commonly grown variety of persimmon?', [ @@ -970,13 +970,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/plum.jpg', category: VeggieCategory.stoneFruit, shortDescription: 'Popular in fruit salads and children\'s tales.', - accentColor: Color(0x40e48b47), + accentColor: const Color(0x40e48b47), seasons: [Season.summer], vitaminAPercentage: 8, vitaminCPercentage: 10, servingSize: '2 medium plums', caloriesPerServing: 70, - trivia: [ + trivia: const [ Trivia( 'Plums should be handled with care because...?', [ @@ -1012,13 +1012,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/potato.jpg', category: VeggieCategory.tuber, shortDescription: 'King of starches and giver of french fries.', - accentColor: Color(0x40c65c63), + accentColor: const Color(0x40c65c63), seasons: [Season.winter, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 45, servingSize: '1 medium spud', caloriesPerServing: 110, - trivia: [ + trivia: const [ Trivia( 'Which country consumes the most fried potatoes per capita?', [ @@ -1054,13 +1054,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/radicchio.jpg', category: VeggieCategory.leafy, shortDescription: 'It\'s that bitter taste in the salad you\'re eating.', - accentColor: Color(0x40d75875), + accentColor: const Color(0x40d75875), seasons: [Season.spring, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 10, servingSize: '2 cups shredded', caloriesPerServing: 20, - trivia: [ + trivia: const [ Trivia( 'Radicchio is a particuarly good source of which mineral?', [ @@ -1096,13 +1096,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/radish.jpg', category: VeggieCategory.root, shortDescription: 'Try roasting them in addition to slicing them up raw.', - accentColor: Color(0x40819e4e), + accentColor: const Color(0x40819e4e), seasons: [Season.spring, Season.autumn], vitaminAPercentage: 0, vitaminCPercentage: 30, servingSize: '7 radishes', caloriesPerServing: 10, - trivia: [ + trivia: const [ Trivia( 'Which ancient civilization is known to have used radish oil?', [ @@ -1138,13 +1138,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/squash.jpg', category: VeggieCategory.gourd, shortDescription: 'Just slather them in butter and pop \'em in the oven.', - accentColor: Color(0x40dbb721), + accentColor: const Color(0x40dbb721), seasons: [Season.winter, Season.autumn], vitaminAPercentage: 297, vitaminCPercentage: 48, servingSize: '1 cup diced butternut', caloriesPerServing: 63, - trivia: [ + trivia: const [ Trivia( 'Which of these is not a type of squash?', [ @@ -1181,13 +1181,13 @@ class LocalVeggieProvider { category: VeggieCategory.berry, shortDescription: 'A delicious fruit that keeps its seeds on the outside.', - accentColor: Color(0x40f06a44), + accentColor: const Color(0x40f06a44), seasons: [Season.spring, Season.summer], vitaminAPercentage: 0, vitaminCPercentage: 160, servingSize: '8 medium strawberries', caloriesPerServing: 50, - trivia: [ + trivia: const [ Trivia( 'How many seeds are in the average strawberry?', [ @@ -1223,13 +1223,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/tangelo.jpg', category: VeggieCategory.citrus, shortDescription: 'No one\'s sure what they are or where they came from.', - accentColor: Color(0x40f88c06), + accentColor: const Color(0x40f88c06), seasons: [Season.winter, Season.autumn], vitaminAPercentage: 6, vitaminCPercentage: 181, servingSize: '1 medium tangelo', caloriesPerServing: 60, - trivia: [ + trivia: const [ Trivia( 'The tangelo is thought to be a cross between oranges and which other fruit?', [ @@ -1265,13 +1265,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/tomato.jpg', category: VeggieCategory.stealthFruit, shortDescription: 'A new world food with old world tradition.', - accentColor: Color(0x40ea3628), + accentColor: const Color(0x40ea3628), seasons: [Season.summer], vitaminAPercentage: 20, vitaminCPercentage: 40, servingSize: '1 medium tomato', caloriesPerServing: 25, - trivia: [ + trivia: const [ Trivia( 'French speakers sometimes refer to tomatoes with which name?', [ @@ -1307,13 +1307,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/watermelon.jpg', category: VeggieCategory.melon, shortDescription: 'Everyone\'s favorite closing act at the picnic.', - accentColor: Color(0x40fa8c75), + accentColor: const Color(0x40fa8c75), seasons: [Season.summer], vitaminAPercentage: 30, vitaminCPercentage: 25, servingSize: '2 cups diced', caloriesPerServing: 80, - trivia: [ + trivia: const [ Trivia( 'How much of a watermelon is water?', [ @@ -1358,13 +1358,13 @@ class LocalVeggieProvider { imageAssetPath: 'assets/images/orange_bell_pepper.jpg', category: VeggieCategory.stealthFruit, shortDescription: 'Like green pepper, but nicer.', - accentColor: Color(0x40fd8e00), + accentColor: const Color(0x40fd8e00), seasons: [Season.summer], vitaminAPercentage: 4, vitaminCPercentage: 190, servingSize: '1 medium pepper', caloriesPerServing: 25, - trivia: [ + trivia: const [ Trivia( 'Which compound (not found in bell peppers) is responsible for many peppers\' spicy taste?', [ diff --git a/veggieseasons/lib/main.dart b/veggieseasons/lib/main.dart index f7cfdd660..de6d9e439 100644 --- a/veggieseasons/lib/main.dart +++ b/veggieseasons/lib/main.dart @@ -61,7 +61,7 @@ class _VeggieAppState extends State with RestorationMixin { child: CupertinoApp( theme: Styles.veggieThemeData, debugShowCheckedModeBanner: false, - home: HomeScreen(restorationId: 'home'), + home: const HomeScreen(restorationId: 'home'), restorationScopeId: 'app', ), ); diff --git a/veggieseasons/lib/screens/details.dart b/veggieseasons/lib/screens/details.dart index d65034c5c..6a4132a3f 100644 --- a/veggieseasons/lib/screens/details.dart +++ b/veggieseasons/lib/screens/details.dart @@ -43,7 +43,7 @@ class ServingInfoChart extends StatelessWidget { final themeData = CupertinoTheme.of(context); return Column( children: [ - SizedBox(height: 16), + const SizedBox(height: 16), Align( alignment: Alignment.centerLeft, child: Padding( @@ -187,9 +187,9 @@ class InfoView extends StatelessWidget { ); }, ), - Spacer(), + const Spacer(), for (Season season in veggie.seasons) ...[ - SizedBox(width: 12), + const SizedBox(width: 12), Padding( padding: Styles.seasonIconPadding[season], child: Icon( @@ -201,18 +201,18 @@ class InfoView extends StatelessWidget { ], ], ), - SizedBox(height: 8), + const SizedBox(height: 8), Text( veggie.name, style: Styles.detailsTitleText(themeData), ), - SizedBox(height: 8), + const SizedBox(height: 8), Text( veggie.shortDescription, style: CupertinoTheme.of(context).textTheme.textStyle, ), ServingInfoChart(veggie, prefs), - SizedBox(height: 24), + const SizedBox(height: 24), Row( mainAxisSize: MainAxisSize.min, children: [ @@ -222,7 +222,7 @@ class InfoView extends StatelessWidget { appState.setFavorite(id, value); }, ), - SizedBox(width: 8), + const SizedBox(width: 8), Text( 'Save to Garden', style: CupertinoTheme.of(context).textTheme.textStyle, @@ -239,7 +239,7 @@ class DetailsScreen extends StatefulWidget { final int id; final String restorationId; - DetailsScreen({this.id, this.restorationId}); + const DetailsScreen({this.id, this.restorationId}); static String show(NavigatorState navigator, int veggieId) { return navigator.restorablePush(_routeBuilder, arguments: veggieId); @@ -321,9 +321,9 @@ class _DetailsScreenState extends State with RestorationMixin { restorationId: 'list', children: [ _buildHeader(context, appState), - SizedBox(height: 20), + const SizedBox(height: 20), CupertinoSegmentedControl( - children: { + children: const { 0: Text( 'Facts & Info', ), diff --git a/veggieseasons/lib/screens/favorites.dart b/veggieseasons/lib/screens/favorites.dart index f499e0546..85081d41d 100644 --- a/veggieseasons/lib/screens/favorites.dart +++ b/veggieseasons/lib/screens/favorites.dart @@ -10,7 +10,7 @@ import 'package:veggieseasons/data/veggie.dart'; import 'package:veggieseasons/widgets/veggie_headline.dart'; class FavoritesScreen extends StatelessWidget { - FavoritesScreen({this.restorationId, Key key}) : super(key: key); + const FavoritesScreen({this.restorationId, Key key}) : super(key: key); final String restorationId; @@ -22,7 +22,7 @@ class FavoritesScreen extends StatelessWidget { final model = Provider.of(context); return CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( + navigationBar: const CupertinoNavigationBar( middle: Text('My Garden'), ), child: Center( @@ -37,10 +37,10 @@ class FavoritesScreen extends StatelessWidget { : ListView( restorationId: 'list', children: [ - SizedBox(height: 24), + const SizedBox(height: 24), for (Veggie veggie in model.favoriteVeggies) Padding( - padding: EdgeInsets.fromLTRB(16, 0, 16, 24), + padding: const EdgeInsets.fromLTRB(16, 0, 16, 24), child: VeggieHeadline(veggie), ), ], diff --git a/veggieseasons/lib/screens/home.dart b/veggieseasons/lib/screens/home.dart index 45fb96bd0..8bcb9eb97 100644 --- a/veggieseasons/lib/screens/home.dart +++ b/veggieseasons/lib/screens/home.dart @@ -10,7 +10,7 @@ import 'package:veggieseasons/screens/search.dart'; import 'package:veggieseasons/screens/settings.dart'; class HomeScreen extends StatelessWidget { - HomeScreen({Key key, this.restorationId}) : super(key: key); + const HomeScreen({Key key, this.restorationId}) : super(key: key); final String restorationId; @@ -20,7 +20,7 @@ class HomeScreen extends StatelessWidget { restorationId: restorationId, child: CupertinoTabScaffold( restorationId: 'scaffold', - tabBar: CupertinoTabBar(items: [ + tabBar: CupertinoTabBar(items: const [ BottomNavigationBarItem( icon: Icon(CupertinoIcons.home), label: 'Home', @@ -40,13 +40,13 @@ class HomeScreen extends StatelessWidget { ]), tabBuilder: (context, index) { if (index == 0) { - return ListScreen(restorationId: 'list'); + return const ListScreen(restorationId: 'list'); } else if (index == 1) { - return FavoritesScreen(restorationId: 'favorites'); + return const FavoritesScreen(restorationId: 'favorites'); } else if (index == 2) { - return SearchScreen(restorationId: 'search'); + return const SearchScreen(restorationId: 'search'); } else { - return SettingsScreen(restorationId: 'settings'); + return const SettingsScreen(restorationId: 'settings'); } }, ), diff --git a/veggieseasons/lib/screens/list.dart b/veggieseasons/lib/screens/list.dart index 167b5df21..1fca2eaa4 100644 --- a/veggieseasons/lib/screens/list.dart +++ b/veggieseasons/lib/screens/list.dart @@ -14,14 +14,14 @@ import 'package:veggieseasons/styles.dart'; import 'package:veggieseasons/widgets/veggie_card.dart'; class ListScreen extends StatelessWidget { - ListScreen({this.restorationId, Key key}) : super(key: key); + const ListScreen({this.restorationId, Key key}) : super(key: key); final String restorationId; Widget _generateVeggieRow(Veggie veggie, Preferences prefs, {bool inSeason = true}) { return Padding( - padding: EdgeInsets.only(left: 16, right: 16, bottom: 24), + padding: const EdgeInsets.only(left: 16, right: 16, bottom: 24), child: FutureBuilder>( future: prefs.preferredCategories, builder: (context, snapshot) { diff --git a/veggieseasons/lib/screens/search.dart b/veggieseasons/lib/screens/search.dart index b5d12ab04..3a659a7e0 100644 --- a/veggieseasons/lib/screens/search.dart +++ b/veggieseasons/lib/screens/search.dart @@ -11,7 +11,7 @@ import 'package:veggieseasons/data/veggie.dart'; import 'package:veggieseasons/widgets/veggie_headline.dart'; class SearchScreen extends StatefulWidget { - SearchScreen({this.restorationId, Key key}) : super(key: key); + const SearchScreen({this.restorationId, Key key}) : super(key: key); final String restorationId; @@ -85,7 +85,7 @@ class _SearchScreenState extends State with RestorationMixin { ); } else { return Padding( - padding: EdgeInsets.only(left: 16, right: 16, bottom: 24), + padding: const EdgeInsets.only(left: 16, right: 16, bottom: 24), child: VeggieHeadline(veggies[i - 1]), ); } diff --git a/veggieseasons/lib/screens/settings.dart b/veggieseasons/lib/screens/settings.dart index b26b1ea5b..79585ae44 100644 --- a/veggieseasons/lib/screens/settings.dart +++ b/veggieseasons/lib/screens/settings.dart @@ -13,7 +13,8 @@ import 'package:veggieseasons/widgets/settings_group.dart'; import 'package:veggieseasons/widgets/settings_item.dart'; class VeggieCategorySettingsScreen extends StatelessWidget { - VeggieCategorySettingsScreen({Key key, this.restorationId}) : super(key: key); + const VeggieCategorySettingsScreen({Key key, this.restorationId}) + : super(key: key); final String restorationId; @@ -24,7 +25,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget { static Route _routeBuilder(BuildContext context, Object argument) { return CupertinoPageRoute( builder: (context) => - VeggieCategorySettingsScreen(restorationId: 'category'), + const VeggieCategorySettingsScreen(restorationId: 'category'), title: 'Preferred Categories', ); } @@ -37,7 +38,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget { return RestorationScope( restorationId: restorationId, child: CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( + navigationBar: const CupertinoNavigationBar( middle: Text('Preferred Categories'), previousPageTitle: 'Settings', ), @@ -65,7 +66,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget { }, ); } else { - toggle = CupertinoSwitch( + toggle = const CupertinoSwitch( value: false, onChanged: null, ); @@ -93,7 +94,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget { } class CalorieSettingsScreen extends StatelessWidget { - CalorieSettingsScreen({Key key, this.restorationId}) : super(key: key); + const CalorieSettingsScreen({Key key, this.restorationId}) : super(key: key); final String restorationId; @@ -107,7 +108,8 @@ class CalorieSettingsScreen extends StatelessWidget { static Route _routeBuilder(BuildContext context, Object argument) { return CupertinoPageRoute( - builder: (context) => CalorieSettingsScreen(restorationId: 'calorie'), + builder: (context) => + const CalorieSettingsScreen(restorationId: 'calorie'), title: 'Calorie Target', ); } @@ -119,7 +121,7 @@ class CalorieSettingsScreen extends StatelessWidget { return RestorationScope( restorationId: restorationId, child: CupertinoPageScaffold( - navigationBar: CupertinoNavigationBar( + navigationBar: const CupertinoNavigationBar( previousPageTitle: 'Settings', ), backgroundColor: Styles.scaffoldBackground(brightness), @@ -152,9 +154,10 @@ class CalorieSettingsScreen extends StatelessWidget { return SettingsGroup( items: steps, - header: SettingsGroupHeader('Available calorie levels'), - footer: SettingsGroupFooter('These are used for serving ' - 'calculations'), + header: const SettingsGroupHeader('Available calorie levels'), + footer: + const SettingsGroupFooter('These are used for serving ' + 'calculations'), ); }, ), @@ -166,14 +169,14 @@ class CalorieSettingsScreen extends StatelessWidget { } class SettingsScreen extends StatelessWidget { - SettingsScreen({this.restorationId, Key key}) : super(key: key); + const SettingsScreen({this.restorationId, Key key}) : super(key: key); final String restorationId; SettingsItem _buildCaloriesItem(BuildContext context, Preferences prefs) { return SettingsItem( label: 'Calorie Target', - icon: SettingsIcon( + icon: const SettingsIcon( backgroundColor: Styles.iconBlue, icon: Styles.calorieIcon, ), @@ -186,8 +189,8 @@ class SettingsScreen extends StatelessWidget { snapshot.data?.toString() ?? '', style: CupertinoTheme.of(context).textTheme.textStyle, ), - SizedBox(width: 8), - SettingsNavigationIndicator(), + const SizedBox(width: 8), + const SettingsNavigationIndicator(), ], ); }, @@ -202,11 +205,11 @@ class SettingsScreen extends StatelessWidget { return SettingsItem( label: 'Preferred Categories', subtitle: 'What types of veggies you prefer!', - icon: SettingsIcon( + icon: const SettingsIcon( backgroundColor: Styles.iconGold, icon: Styles.preferenceIcon, ), - content: SettingsNavigationIndicator(), + content: const SettingsNavigationIndicator(), onPress: () { VeggieCategorySettingsScreen.show(Navigator.of(context)); }, @@ -217,23 +220,23 @@ class SettingsScreen extends StatelessWidget { BuildContext context, Preferences prefs) { return SettingsItem( label: 'Restore Defaults', - icon: SettingsIcon( + icon: const SettingsIcon( backgroundColor: CupertinoColors.systemRed, icon: Styles.resetIcon, ), - content: SettingsNavigationIndicator(), + content: const SettingsNavigationIndicator(), onPress: () { showCupertinoDialog( context: context, builder: (context) => CupertinoAlertDialog( - title: Text('Are you sure?'), - content: Text( + title: const Text('Are you sure?'), + content: const Text( 'Are you sure you want to reset the current settings?', ), actions: [ CupertinoDialogAction( isDestructiveAction: true, - child: Text('Yes'), + child: const Text('Yes'), onPressed: () async { await prefs.restoreDefaults(); Navigator.pop(context); @@ -241,7 +244,7 @@ class SettingsScreen extends StatelessWidget { ), CupertinoDialogAction( isDefaultAction: true, - child: Text('No'), + child: const Text('No'), onPressed: () => Navigator.pop(context), ) ], @@ -264,7 +267,7 @@ class SettingsScreen extends StatelessWidget { child: CustomScrollView( restorationId: 'list', slivers: [ - CupertinoSliverNavigationBar( + const CupertinoSliverNavigationBar( largeTitle: Text('Settings'), ), SliverSafeArea( diff --git a/veggieseasons/lib/styles.dart b/veggieseasons/lib/styles.dart index 76a4656ec..f81d9e2f1 100644 --- a/veggieseasons/lib/styles.dart +++ b/veggieseasons/lib/styles.dart @@ -8,7 +8,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:veggieseasons/data/veggie.dart'; abstract class Styles { - static CupertinoThemeData veggieThemeData = CupertinoThemeData( + static CupertinoThemeData veggieThemeData = const CupertinoThemeData( textTheme: CupertinoTextThemeData( textStyle: TextStyle( color: CupertinoColors.label, @@ -30,7 +30,7 @@ abstract class Styles { static TextStyle minorText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(128, 128, 128, 1), + color: const Color.fromRGBO(128, 128, 128, 1), ); static TextStyle headlineName(CupertinoThemeData themeData) => @@ -41,19 +41,19 @@ abstract class Styles { static TextStyle cardTitleText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(0, 0, 0, 0.9), + color: const Color.fromRGBO(0, 0, 0, 0.9), fontSize: 32, fontWeight: FontWeight.bold, ); static TextStyle cardCategoryText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(255, 255, 255, 0.9), + color: const Color.fromRGBO(255, 255, 255, 0.9), ); static TextStyle cardDescriptionText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(0, 0, 0, 0.9), + color: const Color.fromRGBO(0, 0, 0, 0.9), ); static TextStyle detailsTitleText(CupertinoThemeData themeData) => @@ -69,13 +69,13 @@ abstract class Styles { static TextStyle detailsBoldDescriptionText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(0, 0, 0, 0.9), + color: const Color.fromRGBO(0, 0, 0, 0.9), fontWeight: FontWeight.bold, ); static TextStyle detailsServingHeaderText(CupertinoThemeData themeData) => themeData.textTheme.textStyle.copyWith( - color: Color.fromRGBO(176, 176, 176, 1), + color: const Color.fromRGBO(176, 176, 176, 1), fontWeight: FontWeight.bold, ); @@ -198,7 +198,9 @@ abstract class Styles { : CupertinoColors.darkBackgroundGray; static Color settingsLineation(Brightness brightness) => - brightness == Brightness.light ? Color(0xffbcbbc1) : Color(0xff4c4b4b); + brightness == Brightness.light + ? const Color(0xffbcbbc1) + : const Color(0xff4c4b4b); static const Color settingsBackground = Color(0xffefeff4); diff --git a/veggieseasons/lib/widgets/close_button.dart b/veggieseasons/lib/widgets/close_button.dart index 1238e094f..9cd63b9f0 100644 --- a/veggieseasons/lib/widgets/close_button.dart +++ b/veggieseasons/lib/widgets/close_button.dart @@ -22,7 +22,7 @@ class FrostedBox extends StatelessWidget { return BackdropFilter( filter: ImageFilter.blur(sigmaX: 10, sigmaY: 10), child: DecoratedBox( - decoration: BoxDecoration( + decoration: const BoxDecoration( color: Styles.frostedBackground, ), child: child, @@ -117,7 +117,7 @@ class CloseButtonState extends State { child: Center( child: ColorChangingIcon( CupertinoIcons.clear_thick, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), color: tapInProgress ? Styles.closeButtonPressed : Styles.closeButtonUnpressed, diff --git a/veggieseasons/lib/widgets/settings_group.dart b/veggieseasons/lib/widgets/settings_group.dart index bd7c964dc..49827fc4d 100644 --- a/veggieseasons/lib/widgets/settings_group.dart +++ b/veggieseasons/lib/widgets/settings_group.dart @@ -21,7 +21,7 @@ class SettingsGroupHeader extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( left: 15, right: 15, bottom: 6, @@ -42,7 +42,7 @@ class SettingsGroupFooter extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: EdgeInsets.only( + padding: const EdgeInsets.only( left: 15, right: 15, top: 7.5, diff --git a/veggieseasons/lib/widgets/settings_item.dart b/veggieseasons/lib/widgets/settings_item.dart index ac63e5439..3a81b90fd 100644 --- a/veggieseasons/lib/widgets/settings_item.dart +++ b/veggieseasons/lib/widgets/settings_item.dart @@ -20,7 +20,7 @@ class SettingsNavigationIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return Icon( + return const Icon( CupertinoIcons.forward, color: Styles.settingsMediumGray, size: 21, @@ -99,7 +99,7 @@ class SettingsItemState extends State { }); await widget.onPress(); Future.delayed( - Duration(milliseconds: 150), + const Duration(milliseconds: 150), () { setState(() { pressed = false; @@ -133,10 +133,10 @@ class SettingsItemState extends State { ? Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - SizedBox(height: 8.5), + const SizedBox(height: 8.5), Text(widget.label, style: themeData.textTheme.textStyle), - SizedBox(height: 4), + const SizedBox(height: 4), Text( widget.subtitle, style: Styles.settingsItemSubtitleText(themeData), @@ -144,7 +144,7 @@ class SettingsItemState extends State { ], ) : Padding( - padding: EdgeInsets.only(top: 1.5), + padding: const EdgeInsets.only(top: 1.5), child: Text(widget.label, style: themeData.textTheme.textStyle), ), diff --git a/veggieseasons/lib/widgets/trivia.dart b/veggieseasons/lib/widgets/trivia.dart index 2386ee708..7472477c6 100644 --- a/veggieseasons/lib/widgets/trivia.dart +++ b/veggieseasons/lib/widgets/trivia.dart @@ -135,7 +135,7 @@ class _TriviaViewState extends State with RestorationMixin { 'All done!', style: Styles.triviaFinishedTitleText(themeData), ), - SizedBox(height: 16), + const SizedBox(height: 16), Text('You answered', style: themeData.textTheme.textStyle), Row( mainAxisSize: MainAxisSize.min, @@ -157,9 +157,9 @@ class _TriviaViewState extends State with RestorationMixin { ], ), Text('questions correctly!', style: themeData.textTheme.textStyle), - SizedBox(height: 16), + const SizedBox(height: 16), CupertinoButton( - child: Text('Try Again'), + child: const Text('Try Again'), onPressed: () => _resetGame(), ), ], @@ -173,12 +173,12 @@ class _TriviaViewState extends State with RestorationMixin { padding: const EdgeInsets.all(16), child: Column( children: [ - SizedBox(height: 16), + const SizedBox(height: 16), Text( currentTrivia.question, style: CupertinoTheme.of(context).textTheme.textStyle, ), - SizedBox(height: 32), + const SizedBox(height: 32), for (int i = 0; i < currentTrivia.answers.length; i++) Padding( padding: const EdgeInsets.all(8), @@ -209,9 +209,9 @@ class _TriviaViewState extends State with RestorationMixin { : 'Sorry, that wasn\'t the right answer.', style: CupertinoTheme.of(context).textTheme.textStyle, ), - SizedBox(height: 16), + const SizedBox(height: 16), CupertinoButton( - child: Text('Next Question'), + child: const Text('Next Question'), onPressed: () => setState(() { triviaIndex.value++; status.value = PlayerStatus.readyToAnswer; diff --git a/veggieseasons/lib/widgets/veggie_card.dart b/veggieseasons/lib/widgets/veggie_card.dart index 05df3175e..01bc2b3e7 100644 --- a/veggieseasons/lib/widgets/veggie_card.dart +++ b/veggieseasons/lib/widgets/veggie_card.dart @@ -105,7 +105,7 @@ class _PressableCardState extends State { } class VeggieCard extends StatelessWidget { - VeggieCard(this.veggie, this.isInSeason, this.isPreferredCategory); + const VeggieCard(this.veggie, this.isInSeason, this.isPreferredCategory); /// Veggie to be displayed by the card. final Veggie veggie; @@ -120,7 +120,7 @@ class VeggieCard extends StatelessWidget { Widget _buildDetails(BuildContext context) { final themeData = CupertinoTheme.of(context); return FrostyBackground( - color: Color(0x90ffffff), + color: const Color(0x90ffffff), child: Padding( padding: const EdgeInsets.all(16), child: Column( diff --git a/veggieseasons/lib/widgets/veggie_headline.dart b/veggieseasons/lib/widgets/veggie_headline.dart index 03c70e4ac..8144c21ea 100644 --- a/veggieseasons/lib/widgets/veggie_headline.dart +++ b/veggieseasons/lib/widgets/veggie_headline.dart @@ -49,7 +49,7 @@ class VeggieHeadline extends StatelessWidget { var widgets = []; for (var season in seasons) { - widgets.add(SizedBox(width: 4)); + widgets.add(const SizedBox(width: 4)); widgets.add( Container( height: 10, @@ -80,7 +80,7 @@ class VeggieHeadline extends StatelessWidget { height: 72, width: 72, ), - SizedBox(width: 8), + const SizedBox(width: 8), Flexible( child: Column( mainAxisAlignment: MainAxisAlignment.start, diff --git a/veggieseasons/macos/Podfile b/veggieseasons/macos/Podfile index d60ec7102..dade8dfad 100644 --- a/veggieseasons/macos/Podfile +++ b/veggieseasons/macos/Podfile @@ -9,74 +9,32 @@ project 'Runner', { 'Release' => :release, } -def parse_KV_file(file, separator='=') - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return []; +def flutter_root + generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) + unless File.exist?(generated_xcode_build_settings_path) + raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" end - pods_ary = [] - skip_line_start_symbols = ["#", "/"] - File.foreach(file_abs_path) { |line| - next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ } - plugin = line.split(pattern=separator) - if plugin.length == 2 - podname = plugin[0].strip() - path = plugin[1].strip() - podpath = File.expand_path("#{path}", file_abs_path) - pods_ary.push({:name => podname, :path => podpath}); - else - puts "Invalid plugin specification: #{line}" - end - } - return pods_ary -end -def pubspec_supports_macos(file) - file_abs_path = File.expand_path(file) - if !File.exists? file_abs_path - return false; + File.foreach(generated_xcode_build_settings_path) do |line| + matches = line.match(/FLUTTER_ROOT\=(.*)/) + return matches[1].strip if matches end - File.foreach(file_abs_path) { |line| - return true if line =~ /^\s*macos:/ - } - return false + raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" end +require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) + +flutter_macos_podfile_setup + target 'Runner' do use_frameworks! use_modular_headers! - # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock - # referring to absolute paths on developers' machines. - ephemeral_dir = File.join('Flutter', 'ephemeral') - symlink_dir = File.join(ephemeral_dir, '.symlinks') - symlink_plugins_dir = File.join(symlink_dir, 'plugins') - system("rm -rf #{symlink_dir}") - system("mkdir -p #{symlink_plugins_dir}") + flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) +end - # Flutter Pods - generated_xcconfig = parse_KV_file(File.join(ephemeral_dir, 'Flutter-Generated.xcconfig')) - if generated_xcconfig.empty? - puts "Flutter-Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first." +post_install do |installer| + installer.pods_project.targets.each do |target| + flutter_additional_macos_build_settings(target) end - generated_xcconfig.map { |p| - if p[:name] == 'FLUTTER_FRAMEWORK_DIR' - symlink = File.join(symlink_dir, 'flutter') - File.symlink(File.dirname(p[:path]), symlink) - pod 'FlutterMacOS', :path => File.join(symlink, File.basename(p[:path])) - end - } - - # Plugin Pods - plugin_pods = parse_KV_file('../.flutter-plugins') - plugin_pods.map { |p| - symlink = File.join(symlink_plugins_dir, p[:name]) - File.symlink(p[:path], symlink) - if pubspec_supports_macos(File.join(symlink, 'pubspec.yaml')) - pod p[:name], :path => File.join(symlink, 'macos') - end - } end - -# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system. -install! 'cocoapods', :disable_input_output_paths => true diff --git a/veggieseasons/macos/Podfile.lock b/veggieseasons/macos/Podfile.lock index bc235c2c0..e93f18e31 100644 --- a/veggieseasons/macos/Podfile.lock +++ b/veggieseasons/macos/Podfile.lock @@ -1,27 +1,22 @@ PODS: - FlutterMacOS (1.0.0) - - shared_preferences (0.0.1) - shared_preferences_macos (0.0.1): - FlutterMacOS DEPENDENCIES: - - FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`) - - shared_preferences (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos`) + - FlutterMacOS (from `Flutter/ephemeral`) - shared_preferences_macos (from `Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos`) EXTERNAL SOURCES: FlutterMacOS: - :path: Flutter/ephemeral/.symlinks/flutter/darwin-x64 - shared_preferences: - :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences/macos + :path: Flutter/ephemeral shared_preferences_macos: :path: Flutter/ephemeral/.symlinks/plugins/shared_preferences_macos/macos SPEC CHECKSUMS: - FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9 - shared_preferences: 9fec34d1bd906196a4da48fcf6c3ad521cc00b8d - shared_preferences_macos: 5e5c2839894accb56b7d23328905b757f2bafaf6 + FlutterMacOS: 57701585bf7de1b3fc2bb61f6378d73bbdea8424 + shared_preferences_macos: 480ce071d0666e37cef23fe6c702293a3d21799e -PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7 +PODFILE CHECKSUM: 6eac6b3292e5142cfc23bdeb71848a40ec51c14c -COCOAPODS: 1.8.4 +COCOAPODS: 1.10.1 diff --git a/veggieseasons/macos/Runner.xcodeproj/project.pbxproj b/veggieseasons/macos/Runner.xcodeproj/project.pbxproj index 260cdaa4c..805b71cd9 100644 --- a/veggieseasons/macos/Runner.xcodeproj/project.pbxproj +++ b/veggieseasons/macos/Runner.xcodeproj/project.pbxproj @@ -26,11 +26,7 @@ 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; }; 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; }; 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; }; - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 439430BC46E7EA4F4AD30C97 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 71048CE912B6CDDD9D17E4AB /* Pods_Runner.framework */; }; - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; }; - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -50,8 +46,6 @@ dstPath = ""; dstSubfolderSpec = 10; files = ( - D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */, - 33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */, ); name = "Bundle Framework"; runOnlyForDeploymentPostprocessing = 0; @@ -70,7 +64,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = ""; }; 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = ""; }; 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = ""; }; - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; }; 33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = ""; }; 33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = ""; }; 33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = ""; }; @@ -80,7 +73,6 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; A3B1F279691DA4B9DC4B9D64 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; - D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -88,8 +80,6 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - D73912F022F37F9E000D13A0 /* App.framework in Frameworks */, - 33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */, 439430BC46E7EA4F4AD30C97 /* Pods_Runner.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; @@ -145,8 +135,6 @@ 33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */, 33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */, 33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */, - D73912EF22F37F9E000D13A0 /* App.framework */, - 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */, ); path = Flutter; sourceTree = ""; @@ -281,7 +269,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n"; + shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n"; }; 33CC111E2044C6BF0003C045 /* ShellScript */ = { isa = PBXShellScriptBuildPhase; @@ -308,10 +296,13 @@ buildActionMask = 2147483647; files = ( ); - inputFileListPaths = ( + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/shared_preferences_macos/shared_preferences_macos.framework", ); name = "[CP] Embed Pods Frameworks"; - outputFileListPaths = ( + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/shared_preferences_macos.framework", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; diff --git a/veggieseasons/pubspec.lock b/veggieseasons/pubspec.lock index e48f90bdd..86e3312fd 100644 --- a/veggieseasons/pubspec.lock +++ b/veggieseasons/pubspec.lock @@ -70,7 +70,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.2" + version: "1.0.3" fake_async: dependency: transitive description: @@ -84,14 +84,14 @@ packages: name: ffi url: "https://pub.dartlang.org" source: hosted - version: "1.0.0" + version: "1.1.1" file: dependency: transitive description: name: file url: "https://pub.dartlang.org" source: hosted - version: "6.1.0" + version: "6.1.1" flutter: dependency: "direct main" description: flutter @@ -104,6 +104,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.9.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_test: dependency: "direct dev" description: flutter @@ -142,6 +149,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.6.3" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" matcher: dependency: transitive description: @@ -191,13 +205,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.1" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" petitparser: dependency: transitive description: @@ -239,7 +246,7 @@ packages: name: shared_preferences url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.0.6" shared_preferences_linux: dependency: transitive description: @@ -342,7 +349,7 @@ packages: name: win32 url: "https://pub.dartlang.org" source: hosted - version: "2.0.5" + version: "2.1.3" xdg_directories: dependency: transitive description: @@ -356,7 +363,7 @@ packages: name: xml url: "https://pub.dartlang.org" source: hosted - version: "5.1.0" + version: "5.1.1" yaml: dependency: transitive description: @@ -365,5 +372,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.12.0 <3.0.0" + dart: ">=2.13.0 <3.0.0" flutter: ">=1.20.0" diff --git a/veggieseasons/pubspec.yaml b/veggieseasons/pubspec.yaml index 5b950ca8c..523451255 100644 --- a/veggieseasons/pubspec.yaml +++ b/veggieseasons/pubspec.yaml @@ -19,11 +19,10 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^1.0.0 flutter_launcher_icons: ^0.9.0 flutter: - assets: - assets/images/apple.jpg - assets/images/artichoke.jpg diff --git a/web/_tool/analysis_options.yaml b/web/_tool/analysis_options.yaml new file mode 100644 index 000000000..572dd239d --- /dev/null +++ b/web/_tool/analysis_options.yaml @@ -0,0 +1 @@ +include: package:lints/recommended.yaml diff --git a/web/_tool/common.dart b/web/_tool/common.dart index ae332c101..3065a221a 100644 --- a/web/_tool/common.dart +++ b/web/_tool/common.dart @@ -10,7 +10,7 @@ const ansiMagenta = 35; Future run( String workingDir, String commandName, List args) async { - var commandDescription = '`${([commandName]..addAll(args)).join(' ')}`'; + var commandDescription = '`${([commandName, ...args]).join(' ')}`'; logWrapped(ansiMagenta, ' Running $commandDescription'); diff --git a/web/_tool/pubspec.lock b/web/_tool/pubspec.lock index fe89ca131..1789ea7a9 100644 --- a/web/_tool/pubspec.lock +++ b/web/_tool/pubspec.lock @@ -7,34 +7,41 @@ packages: name: args url: "https://pub.dartlang.org" source: hosted - version: "1.6.0" + version: "2.1.1" charcode: dependency: transitive description: name: charcode url: "https://pub.dartlang.org" source: hosted - version: "1.2.0-nullsafety.3" + version: "1.2.0" + lints: + dependency: "direct dev" + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" markdown: dependency: "direct main" description: name: markdown url: "https://pub.dartlang.org" source: hosted - version: "4.0.0-nullsafety.0" + version: "4.0.0" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.4.0" path: dependency: "direct main" description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0-nullsafety.3" + version: "1.8.0" sdks: - dart: ">=2.12.0-0 <3.0.0" + dart: ">=2.12.0 <3.0.0" diff --git a/web/_tool/pubspec.yaml b/web/_tool/pubspec.yaml index 34e0df8b4..1f196fdd2 100644 --- a/web/_tool/pubspec.yaml +++ b/web/_tool/pubspec.yaml @@ -1,9 +1,12 @@ name: tool publish_to: none -environment: - sdk: '>=2.10.0 <3.0.0' +environment: + sdk: '>=2.12.0 <3.0.0' dependencies: - markdown: ^4.0.0-nullsafety.0 - path: ^1.8.0-nullsafety.3 + markdown: ^4.0.0 + path: ^1.8.0 + +dev_dependencies: + lints: ^1.0.0 diff --git a/web/_tool/verify_packages.dart b/web/_tool/verify_packages.dart index 68294bd65..70a197858 100644 --- a/web/_tool/verify_packages.dart +++ b/web/_tool/verify_packages.dart @@ -27,8 +27,8 @@ void main() async { ])); results.add(await run( dir, - 'dartanalyzer', - ['--fatal-infos', '--fatal-warnings', '.'], + 'flutter', + ['analyze', '--fatal-infos', '--fatal-warnings', '.'], )); _printStatus(results); } diff --git a/web/filipino_cuisine/analysis_options.yaml b/web/filipino_cuisine/analysis_options.yaml new file mode 100644 index 000000000..30ac27228 --- /dev/null +++ b/web/filipino_cuisine/analysis_options.yaml @@ -0,0 +1,20 @@ +include: package:flutter_lints/flutter.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/web/filipino_cuisine/lib/cook.dart b/web/filipino_cuisine/lib/cook.dart index e15e922a6..b121f0df8 100644 --- a/web/filipino_cuisine/lib/cook.dart +++ b/web/filipino_cuisine/lib/cook.dart @@ -1,30 +1,34 @@ import 'package:flutter/material.dart'; class Cook extends StatefulWidget { - final List dr; - final img; - final nme; + final List dr; + final String img; + final String nme; - Cook(this.dr, this.img, this.nme); + const Cook(this.dr, this.img, this.nme); + @override CState createState() => CState(); } class CState extends State { - List cb; + List cb; + @override initState() { super.initState(); cb = []; } - Widget build(ct) { - List dr = widget.dr; + @override + Widget build(context) { + List dr = widget.dr; return Scaffold( - appBar: AppBar( - backgroundColor: Colors.red, - title: Text("INSTRUCTIONS"), - centerTitle: true), - body: Column(children: [ + appBar: AppBar( + backgroundColor: Colors.red, + title: const Text("INSTRUCTIONS"), + centerTitle: true), + body: Column( + children: [ Container( child: ListTile( leading: ClipRRect( @@ -34,23 +38,27 @@ class CState extends State { child: Image.asset(widget.img, fit: BoxFit.cover, width: 100, height: 100))), title: Text(widget.nme, - style: Theme.of(ct) + style: Theme.of(context) .textTheme .headline3 .copyWith(fontFamily: 'ark', color: Colors.black))), - margin: EdgeInsets.only(top: 40, bottom: 30, left: 20)), + margin: const EdgeInsets.only(top: 40, bottom: 30, left: 20)), Expanded( - child: ListView.builder( - itemCount: dr.length, - padding: EdgeInsets.all(10), - itemBuilder: (ct, i) { - cb.add(false); - return ListTile( - title: Text(dr[i]), - trailing: Checkbox( - value: cb[i], - onChanged: (v) => setState(() => cb[i] = v))); - })), - ])); + child: ListView.builder( + itemCount: dr.length, + padding: const EdgeInsets.all(10), + itemBuilder: (ct, i) { + cb.add(false); + return ListTile( + title: Text(dr[i]), + trailing: Checkbox( + value: cb[i], + onChanged: (v) => setState(() => cb[i] = v))); + }, + ), + ), + ], + ), + ); } } diff --git a/web/filipino_cuisine/lib/flutter_page_indicator.dart b/web/filipino_cuisine/lib/flutter_page_indicator.dart index 4e7b63ba0..1273f9a12 100644 --- a/web/filipino_cuisine/lib/flutter_page_indicator.dart +++ b/web/filipino_cuisine/lib/flutter_page_indicator.dart @@ -8,6 +8,7 @@ class WarmPainter extends BasePainter { WarmPainter(PageIndicator widget, double page, int index, Paint paint) : super(widget, page, index, paint); + @override void draw(Canvas canvas, double space, double size, double radius) { double progress = page - index; double distance = size + space; @@ -20,15 +21,13 @@ class WarmPainter extends BasePainter { double left = index * distance + distance * (progress - 0.5) * 2; canvas.drawRRect( - new RRect.fromLTRBR( - left, 0.0, right, size, new Radius.circular(radius)), + RRect.fromLTRBR(left, 0.0, right, size, Radius.circular(radius)), _paint); } else { double right = start + size + distance * progress * 2; canvas.drawRRect( - new RRect.fromLTRBR( - start, 0.0, right, size, new Radius.circular(radius)), + RRect.fromLTRBR(start, 0.0, right, size, Radius.circular(radius)), _paint); } } @@ -48,7 +47,7 @@ class DropPainter extends BasePainter { //lerp(begin, end, progress) canvas.drawCircle( - new Offset(radius + ((page) * (size + space)), + Offset(radius + ((page) * (size + space)), radius - dropHeight * (1 - rate)), radius * (scale + rate * (1.0 - scale)), _paint); @@ -67,10 +66,10 @@ class NonePainter extends BasePainter { : radius + ((index + 1) * (size + space)); if (progress > 0.5) { - canvas.drawCircle(new Offset(secondOffset, radius), radius, _paint); + canvas.drawCircle(Offset(secondOffset, radius), radius, _paint); } else { - canvas.drawCircle(new Offset(radius + (index * (size + space)), radius), - radius, _paint); + canvas.drawCircle( + Offset(radius + (index * (size + space)), radius), radius, _paint); } } } @@ -82,7 +81,7 @@ class SlidePainter extends BasePainter { @override void draw(Canvas canvas, double space, double size, double radius) { canvas.drawCircle( - new Offset(radius + (page * (size + space)), radius), radius, _paint); + Offset(radius + (page * (size + space)), radius), radius, _paint); } } @@ -92,11 +91,11 @@ class ScalePainter extends BasePainter { // 连续的两个点,含有最后一个和第一个 @override - bool _shouldSkip(int i) { - if (index == widget.count - 1) { - return i == 0 || i == index; + bool _shouldSkip(int index) { + if (super.index == widget.count - 1) { + return index == 0 || index == super.index; } - return (i == index || i == index + 1); + return (index == super.index || index == super.index + 1); } @override @@ -109,7 +108,7 @@ class ScalePainter extends BasePainter { if (_shouldSkip(i)) { continue; } - canvas.drawCircle(new Offset(i * (size + space) + radius, radius), + canvas.drawCircle(Offset(i * (size + space) + radius, radius), radius * widget.scale, _paint); } @@ -126,11 +125,11 @@ class ScalePainter extends BasePainter { double progress = page - index; _paint.color = Color.lerp(widget.activeColor, widget.color, progress); //last - canvas.drawCircle(new Offset(radius + (index * (size + space)), radius), + canvas.drawCircle(Offset(radius + (index * (size + space)), radius), lerp(radius, radius * widget.scale, progress), _paint); //first _paint.color = Color.lerp(widget.color, widget.activeColor, progress); - canvas.drawCircle(new Offset(secondOffset, radius), + canvas.drawCircle(Offset(secondOffset, radius), lerp(radius * widget.scale, radius, progress), _paint); } } @@ -141,11 +140,11 @@ class ColorPainter extends BasePainter { // 连续的两个点,含有最后一个和第一个 @override - bool _shouldSkip(int i) { - if (index == widget.count - 1) { - return i == 0 || i == index; + bool _shouldSkip(int index) { + if (super.index == widget.count - 1) { + return index == 0 || index == super.index; } - return (i == index || i == index + 1); + return (index == super.index || index == super.index + 1); } @override @@ -158,10 +157,10 @@ class ColorPainter extends BasePainter { _paint.color = Color.lerp(widget.activeColor, widget.color, progress); //left canvas.drawCircle( - new Offset(radius + (index * (size + space)), radius), radius, _paint); + Offset(radius + (index * (size + space)), radius), radius, _paint); //right _paint.color = Color.lerp(widget.color, widget.activeColor, progress); - canvas.drawCircle(new Offset(secondOffset, radius), radius, _paint); + canvas.drawCircle(Offset(secondOffset, radius), radius, _paint); } } @@ -195,7 +194,7 @@ abstract class BasePainter extends CustomPainter { continue; } canvas.drawCircle( - new Offset(i * (size + space) + radius, radius), radius, _paint); + Offset(i * (size + space) + radius, radius), radius, _paint); } double page = this.page; @@ -214,51 +213,51 @@ abstract class BasePainter extends CustomPainter { class _PageIndicatorState extends State { int index = 0; - Paint _paint = new Paint(); + final Paint _paint = Paint(); BasePainter _createPainer() { switch (widget.layout) { case PageIndicatorLayout.NONE: - return new NonePainter( + return NonePainter( widget, widget.controller.page ?? 0.0, index, _paint); case PageIndicatorLayout.SLIDE: - return new SlidePainter( + return SlidePainter( widget, widget.controller.page ?? 0.0, index, _paint); case PageIndicatorLayout.WARM: - return new WarmPainter( + return WarmPainter( widget, widget.controller.page ?? 0.0, index, _paint); case PageIndicatorLayout.COLOR: - return new ColorPainter( + return ColorPainter( widget, widget.controller.page ?? 0.0, index, _paint); case PageIndicatorLayout.SCALE: - return new ScalePainter( + return ScalePainter( widget, widget.controller.page ?? 0.0, index, _paint); case PageIndicatorLayout.DROP: - return new DropPainter( + return DropPainter( widget, widget.controller.page ?? 0.0, index, _paint); default: - throw new Exception("Not a valid layout"); + throw Exception("Not a valid layout"); } } @override Widget build(BuildContext context) { - Widget child = new SizedBox( + Widget child = SizedBox( width: widget.count * widget.size + (widget.count - 1) * widget.space, height: widget.size, - child: new CustomPaint( + child: CustomPaint( painter: _createPainer(), ), ); if (widget.layout == PageIndicatorLayout.SCALE || widget.layout == PageIndicatorLayout.COLOR) { - child = new ClipRect( + child = ClipRect( child: child, ); } - return new IgnorePointer( + return IgnorePointer( child: child, ); } @@ -292,14 +291,8 @@ class _PageIndicatorState extends State { } } -enum PageIndicatorLayout { - NONE, - SLIDE, - WARM, - COLOR, - SCALE, - DROP, -} +// ignore: constant_identifier_names +enum PageIndicatorLayout { NONE, SLIDE, WARM, COLOR, SCALE, DROP } class PageIndicator extends StatefulWidget { /// size of the dots @@ -330,24 +323,24 @@ class PageIndicator extends StatefulWidget { final double activeSize; - PageIndicator( + const PageIndicator( {Key key, - this.size: 20.0, - this.space: 5.0, - this.count, - this.activeSize: 20.0, - this.controller, - this.color: Colors.white30, - this.layout: PageIndicatorLayout.SLIDE, - this.activeColor: Colors.white, - this.scale: 0.6, - this.dropHeight: 20.0}) + this.size = 20.0, + this.space = 5.0, + @required this.count, + this.activeSize = 20.0, + @required this.controller, + this.color = Colors.white30, + this.layout = PageIndicatorLayout.SLIDE, + this.activeColor = Colors.white, + this.scale = 0.6, + this.dropHeight = 20.0}) : assert(count != null), assert(controller != null), super(key: key); @override State createState() { - return new _PageIndicatorState(); + return _PageIndicatorState(); } } diff --git a/web/filipino_cuisine/lib/flutter_swiper.dart b/web/filipino_cuisine/lib/flutter_swiper.dart index fa921982f..c1e573c31 100644 --- a/web/filipino_cuisine/lib/flutter_swiper.dart +++ b/web/filipino_cuisine/lib/flutter_swiper.dart @@ -1,17 +1,18 @@ // Package flutter_swiper: // https://pub.dartlang.org/packages/flutter_swiper +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter/foundation.dart'; -import 'dart:async'; - import 'flutter_page_indicator.dart'; import 'transformer_page_view.dart'; -typedef void SwiperOnTap(int index); +typedef SwiperOnTap = void Function(int index); -typedef Widget SwiperDataBuilder(BuildContext context, dynamic data, int index); +typedef SwiperDataBuilder = Widget Function( + BuildContext context, dynamic data, int index); /// default auto play delay const int kDefaultAutoplayDelayMs = 3000; @@ -22,6 +23,7 @@ const int kDefaultAutoplayTransactionDuration = 300; const int kMaxValue = 2000000000; const int kMiddleValue = 1000000000; +// ignore_for_file: constant_identifier_names enum SwiperLayout { DEFAULT, STACK, TINDER, CUSTOM } class Swiper extends StatefulWidget { @@ -111,25 +113,25 @@ class Swiper extends StatefulWidget { final PageIndicatorLayout indicatorLayout; - Swiper({ + const Swiper({ this.itemBuilder, - this.indicatorLayout: PageIndicatorLayout.NONE, + this.indicatorLayout = PageIndicatorLayout.NONE, /// this.transformer, @required this.itemCount, - this.autoplay: false, - this.layout: SwiperLayout.DEFAULT, - this.autoplayDelay: kDefaultAutoplayDelayMs, - this.autoplayDisableOnInteraction: true, - this.duration: kDefaultAutoplayTransactionDuration, + this.autoplay = false, + this.layout = SwiperLayout.DEFAULT, + this.autoplayDelay = kDefaultAutoplayDelayMs, + this.autoplayDisableOnInteraction = true, + this.duration = kDefaultAutoplayTransactionDuration, this.onIndexChanged, this.index, this.onTap, this.control, - this.loop: true, - this.curve: Curves.ease, - this.scrollDirection: Axis.horizontal, + this.loop = true, + this.curve = Curves.ease, + this.scrollDirection = Axis.horizontal, this.pagination, this.plugins, this.physics, @@ -140,10 +142,10 @@ class Swiper extends StatefulWidget { /// since v1.0.0 this.containerHeight, this.containerWidth, - this.viewportFraction: 1.0, + this.viewportFraction = 1.0, this.itemHeight, this.itemWidth, - this.outer: false, + this.outer = false, this.scale, this.fade, }) : assert(itemBuilder != null || transformer != null, @@ -160,19 +162,19 @@ class Swiper extends StatefulWidget { super(key: key); factory Swiper.children({ - List children, - bool autoplay: false, + @required List children, + bool autoplay = false, PageTransformer transformer, - int autoplayDelay: kDefaultAutoplayDelayMs, - bool reverse: false, - bool autoplayDisableOnInteraction: true, - int duration: kDefaultAutoplayTransactionDuration, + int autoplayDelay = kDefaultAutoplayDelayMs, + bool reverse = false, + bool autoplayDisableOnInteraction = true, + int duration = kDefaultAutoplayTransactionDuration, ValueChanged onIndexChanged, int index, SwiperOnTap onTap, - bool loop: true, - Curve curve: Curves.ease, - Axis scrollDirection: Axis.horizontal, + bool loop = true, + Curve curve = Curves.ease, + Axis scrollDirection = Axis.horizontal, SwiperPlugin pagination, SwiperPlugin control, List plugins, @@ -182,15 +184,15 @@ class Swiper extends StatefulWidget { ScrollPhysics physics, double containerHeight, double containerWidth, - double viewportFraction: 1.0, + double viewportFraction = 1.0, double itemHeight, double itemWidth, - bool outer: false, - double scale: 1.0, + bool outer = false, + double scale = 1.0, }) { assert(children != null, "children must not be null"); - return new Swiper( + return Swiper( transformer: transformer, customLayoutOption: customLayoutOption, containerHeight: containerHeight, @@ -216,7 +218,7 @@ class Swiper extends StatefulWidget { plugins: plugins, physics: physics, key: key, - itemBuilder: (BuildContext context, int index) { + itemBuilder: (context, index) { return children[index]; }, itemCount: children.length); @@ -227,17 +229,17 @@ class Swiper extends StatefulWidget { List list, CustomLayoutOption customLayoutOption, SwiperDataBuilder builder, - bool autoplay: false, - int autoplayDelay: kDefaultAutoplayDelayMs, - bool reverse: false, - bool autoplayDisableOnInteraction: true, - int duration: kDefaultAutoplayTransactionDuration, + bool autoplay = false, + int autoplayDelay = kDefaultAutoplayDelayMs, + bool reverse = false, + bool autoplayDisableOnInteraction = true, + int duration = kDefaultAutoplayTransactionDuration, ValueChanged onIndexChanged, int index, SwiperOnTap onTap, - bool loop: true, - Curve curve: Curves.ease, - Axis scrollDirection: Axis.horizontal, + bool loop = true, + Curve curve = Curves.ease, + Axis scrollDirection = Axis.horizontal, SwiperPlugin pagination, SwiperPlugin control, List plugins, @@ -246,13 +248,13 @@ class Swiper extends StatefulWidget { ScrollPhysics physics, double containerHeight, double containerWidth, - double viewportFraction: 1.0, + double viewportFraction = 1.0, double itemHeight, double itemWidth, - bool outer: false, - double scale: 1.0, + bool outer = false, + double scale = 1.0, }) { - return new Swiper( + return Swiper( transformer: transformer, customLayoutOption: customLayoutOption, containerHeight: containerHeight, @@ -278,7 +280,7 @@ class Swiper extends StatefulWidget { loop: loop, plugins: plugins, physics: physics, - itemBuilder: (BuildContext context, int index) { + itemBuilder: (context, index) { return builder(context, list[index], index); }, itemCount: list.length); @@ -286,7 +288,7 @@ class Swiper extends StatefulWidget { @override State createState() { - return new _SwiperState(); + return _SwiperState(); } } @@ -298,9 +300,7 @@ abstract class _SwiperTimerMixin extends State { @override void initState() { _controller = widget.controller; - if (_controller == null) { - _controller = new SwiperController(); - } + _controller ??= SwiperController(); _controller.addListener(_onController); _handleAutoplay(); super.initState(); @@ -385,10 +385,10 @@ class _SwiperState extends _SwiperTimerMixin { TransformerPageController _pageController; Widget _wrapTap(BuildContext context, int index) { - return new GestureDetector( + return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - this.widget.onTap(index); + widget.onTap(index); }, child: widget.itemBuilder(context, index), ); @@ -398,7 +398,7 @@ class _SwiperState extends _SwiperTimerMixin { void initState() { _activeIndex = widget.index ?? 0; if (_isPageViewLayout()) { - _pageController = new TransformerPageController( + _pageController = TransformerPageController( initialPage: widget.index, loop: widget.loop, itemCount: widget.itemCount, @@ -431,7 +431,7 @@ class _SwiperState extends _SwiperTimerMixin { widget.itemCount != oldWidget.itemCount || widget.viewportFraction != oldWidget.viewportFraction || _getReverse(widget) != _getReverse(oldWidget))) { - _pageController = new TransformerPageController( + _pageController = TransformerPageController( initialPage: widget.index, loop: widget.loop, itemCount: widget.itemCount, @@ -470,7 +470,7 @@ class _SwiperState extends _SwiperTimerMixin { } if (widget.layout == SwiperLayout.STACK) { - return new _StackSwiper( + return _StackSwiper( loop: widget.loop, itemWidth: widget.itemWidth, itemHeight: widget.itemHeight, @@ -487,10 +487,10 @@ class _SwiperState extends _SwiperTimerMixin { PageTransformer transformer = widget.transformer; if (widget.scale != null || widget.fade != null) { transformer = - new ScaleAndFadeTransformer(scale: widget.scale, fade: widget.fade); + ScaleAndFadeTransformer(scale: widget.scale, fade: widget.fade); } - Widget child = new TransformerPageView( + Widget child = TransformerPageView( pageController: _pageController, loop: widget.loop, itemCount: widget.itemCount, @@ -498,7 +498,7 @@ class _SwiperState extends _SwiperTimerMixin { transformer: transformer, viewportFraction: widget.viewportFraction, index: _activeIndex, - duration: new Duration(milliseconds: widget.duration), + duration: Duration(milliseconds: widget.duration), scrollDirection: widget.scrollDirection, onPageChanged: _onIndexChanged, curve: widget.curve, @@ -506,9 +506,9 @@ class _SwiperState extends _SwiperTimerMixin { controller: _controller, ); if (widget.autoplayDisableOnInteraction && widget.autoplay) { - return new NotificationListener( + return NotificationListener( child: child, - onNotification: (ScrollNotification notification) { + onNotification: (dynamic notification) { if (notification is ScrollStartNotification) { if (notification.dragDetails != null) { //by human @@ -525,7 +525,7 @@ class _SwiperState extends _SwiperTimerMixin { return child; } else if (widget.layout == SwiperLayout.TINDER) { - return new _TinderSwiper( + return _TinderSwiper( loop: widget.loop, itemWidth: widget.itemWidth, itemHeight: widget.itemHeight, @@ -539,7 +539,7 @@ class _SwiperState extends _SwiperTimerMixin { scrollDirection: widget.scrollDirection, ); } else if (widget.layout == SwiperLayout.CUSTOM) { - return new _CustomLayoutSwiper( + return _CustomLayoutSwiper( loop: widget.loop, option: widget.customLayoutOption, itemWidth: widget.itemWidth, @@ -554,23 +554,21 @@ class _SwiperState extends _SwiperTimerMixin { scrollDirection: widget.scrollDirection, ); } else { - return new Container(); + return Container(); } } SwiperPluginConfig _ensureConfig(SwiperPluginConfig config) { - if (config == null) { - config = new SwiperPluginConfig( - outer: widget.outer, - itemCount: widget.itemCount, - layout: widget.layout, - indicatorLayout: widget.indicatorLayout, - pageController: _pageController, - activeIndex: _activeIndex, - scrollDirection: widget.scrollDirection, - controller: _controller, - loop: widget.loop); - } + config ??= SwiperPluginConfig( + outer: widget.outer, + itemCount: widget.itemCount, + layout: widget.layout, + indicatorLayout: widget.indicatorLayout, + pageController: _pageController, + activeIndex: _activeIndex, + scrollDirection: widget.scrollDirection, + controller: _controller, + loop: widget.loop); return config; } @@ -607,8 +605,8 @@ class _SwiperState extends _SwiperTimerMixin { config = _ensureConfig(config); if (widget.outer) { return _buildOuterPagination( - widget.pagination, - listForStack == null ? swiper : new Stack(children: listForStack), + widget.pagination as SwiperPagination, + listForStack == null ? swiper : Stack(children: listForStack), config); } else { listForStack = _ensureListForStack( @@ -617,7 +615,7 @@ class _SwiperState extends _SwiperTimerMixin { } if (listForStack != null) { - return new Stack( + return Stack( children: listForStack, ); } @@ -632,15 +630,15 @@ class _SwiperState extends _SwiperTimerMixin { if (widget.containerHeight != null || widget.containerWidth != null) { list.add(swiper); } else { - list.add(new Expanded(child: swiper)); + list.add(Expanded(child: swiper)); } - list.add(new Align( + list.add(Align( alignment: Alignment.center, child: pagination.build(context, config), )); - return new Column( + return Column( children: list, crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisSize: MainAxisSize.min, @@ -661,7 +659,7 @@ abstract class _SubSwiper extends StatefulWidget { final bool loop; final Axis scrollDirection; - _SubSwiper( + const _SubSwiper( {Key key, this.loop, this.itemHeight, @@ -672,13 +670,10 @@ abstract class _SubSwiper extends StatefulWidget { this.controller, this.index, this.itemCount, - this.scrollDirection: Axis.horizontal, + this.scrollDirection = Axis.horizontal, this.onIndexChanged}) : super(key: key); - @override - State createState(); - int getCorrectIndex(int indexNeedsFix) { if (itemCount == 0) return 0; int value = indexNeedsFix % itemCount; @@ -690,14 +685,14 @@ abstract class _SubSwiper extends StatefulWidget { } class _TinderSwiper extends _SubSwiper { - _TinderSwiper({ + const _TinderSwiper({ Key key, Curve curve, int duration, SwiperController controller, ValueChanged onIndexChanged, - double itemHeight, - double itemWidth, + @required double itemHeight, + @required double itemWidth, IndexedWidgetBuilder itemBuilder, int index, bool loop, @@ -720,12 +715,12 @@ class _TinderSwiper extends _SubSwiper { @override State createState() { - return new _TinderState(); + return _TinderState(); } } class _StackSwiper extends _SubSwiper { - _StackSwiper({ + const _StackSwiper({ Key key, Curve curve, int duration, @@ -754,7 +749,7 @@ class _StackSwiper extends _SubSwiper { @override State createState() { - return new _StackViewState(); + return _StackViewState(); } } @@ -829,17 +824,17 @@ class _TinderState extends _CustomLayoutStateBase<_TinderSwiper> { ? Alignment.bottomCenter : Alignment.centerLeft; - return new Opacity( + return Opacity( opacity: o, - child: new Transform.rotate( + child: Transform.rotate( angle: a / 180.0, - child: new Transform.translate( - key: new ValueKey(_currentIndex + i), - offset: new Offset(f, fy), - child: new Transform.scale( + child: Transform.translate( + key: ValueKey(_currentIndex + i), + offset: Offset(f, fy), + child: Transform.scale( scale: s, alignment: alignment, - child: new SizedBox( + child: SizedBox( width: widget.itemWidth ?? double.infinity, height: widget.itemHeight ?? double.infinity, child: widget.itemBuilder(context, realIndex), @@ -898,22 +893,22 @@ class _StackViewState extends _CustomLayoutStateBase<_StackSwiper> { double o = _getValue(opacity, animationValue, i); Offset offset = widget.scrollDirection == Axis.horizontal - ? new Offset(f, 0.0) - : new Offset(0.0, f); + ? Offset(f, 0.0) + : Offset(0.0, f); Alignment alignment = widget.scrollDirection == Axis.horizontal ? Alignment.centerLeft : Alignment.topCenter; - return new Opacity( + return Opacity( opacity: o, - child: new Transform.translate( - key: new ValueKey(_currentIndex + i), + child: Transform.translate( + key: ValueKey(_currentIndex + i), offset: offset, - child: new Transform.scale( + child: Transform.scale( scale: s, alignment: alignment, - child: new SizedBox( + child: SizedBox( width: widget.itemWidth ?? double.infinity, height: widget.itemHeight ?? double.infinity, child: widget.itemBuilder(context, realIndex), @@ -928,11 +923,12 @@ class ScaleAndFadeTransformer extends PageTransformer { final double _scale; final double _fade; - ScaleAndFadeTransformer({double fade: 0.3, double scale: 0.8}) + ScaleAndFadeTransformer({double fade = 0.3, double scale = 0.8}) : _fade = fade, _scale = scale; @override + // ignore: avoid_renaming_method_parameters Widget transform(Widget item, TransformInfo info) { double position = info.position; Widget child = item; @@ -940,7 +936,7 @@ class ScaleAndFadeTransformer extends PageTransformer { double scaleFactor = (1 - position.abs()) * (1 - _scale); double scale = _scale + scaleFactor; - child = new Transform.scale( + child = Transform.scale( scale: scale, child: item, ); @@ -949,7 +945,7 @@ class ScaleAndFadeTransformer extends PageTransformer { if (_fade != null) { double fadeFactor = (1 - position.abs()) * (1 - _fade); double opacity = _fade + fadeFactor; - child = new Opacity( + child = Opacity( opacity: opacity, child: child, ); @@ -981,17 +977,17 @@ class SwiperControl extends SwiperPlugin { final Key key; const SwiperControl( - {this.iconPrevious: Icons.arrow_back_ios, - this.iconNext: Icons.arrow_forward_ios, + {this.iconPrevious = Icons.arrow_back_ios, + this.iconNext = Icons.arrow_forward_ios, this.color, this.disableColor, this.key, - this.size: 30.0, - this.padding: const EdgeInsets.all(5.0)}); + this.size = 30.0, + this.padding = const EdgeInsets.all(5.0)}); Widget buildButton(SwiperPluginConfig config, Color color, IconData iconDaga, int quarterTurns, bool previous) { - return new GestureDetector( + return GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { if (previous) { @@ -1052,7 +1048,7 @@ class SwiperControl extends SwiperPlugin { ); } - return new Container( + return SizedBox( height: double.infinity, child: child, width: double.infinity, @@ -1081,7 +1077,9 @@ class SwiperController extends IndexController { // this value is PageViewController.pos double pos; + // ignore: overridden_fields, annotate_overrides int index; + // ignore: overridden_fields, annotate_overrides bool animation; bool autoplay; @@ -1089,13 +1087,13 @@ class SwiperController extends IndexController { void startAutoplay() { event = SwiperController.START_AUTOPLAY; - this.autoplay = true; + autoplay = true; notifyListeners(); } void stopAutoplay() { event = SwiperController.STOP_AUTOPLAY; - this.autoplay = false; + autoplay = false; notifyListeners(); } } @@ -1117,10 +1115,10 @@ class FractionPaginationBuilder extends SwiperPlugin { const FractionPaginationBuilder( {this.color, - this.fontSize: 20.0, + this.fontSize = 20.0, this.key, this.activeColor, - this.activeFontSize: 35.0}); + this.activeFontSize = 35.0}); @override Widget build(BuildContext context, SwiperPluginConfig config) { @@ -1129,34 +1127,34 @@ class FractionPaginationBuilder extends SwiperPlugin { Color color = this.color ?? themeData.scaffoldBackgroundColor; if (Axis.vertical == config.scrollDirection) { - return new Column( + return Column( key: key, mainAxisSize: MainAxisSize.min, children: [ - new Text( + Text( "${config.activeIndex + 1}", style: TextStyle(color: activeColor, fontSize: activeFontSize), ), - new Text( + Text( "/", style: TextStyle(color: color, fontSize: fontSize), ), - new Text( + Text( "${config.itemCount}", style: TextStyle(color: color, fontSize: fontSize), ) ], ); } else { - return new Row( + return Row( key: key, mainAxisSize: MainAxisSize.min, children: [ - new Text( + Text( "${config.activeIndex + 1}", style: TextStyle(color: activeColor, fontSize: activeFontSize), ), - new Text( + Text( " / ${config.itemCount}", style: TextStyle(color: color, fontSize: fontSize), ) @@ -1188,9 +1186,9 @@ class RectSwiperPaginationBuilder extends SwiperPlugin { {this.activeColor, this.color, this.key, - this.size: const Size(10.0, 2.0), - this.activeSize: const Size(10.0, 2.0), - this.space: 3.0}); + this.size = const Size(10.0, 2.0), + this.activeSize = const Size(10.0, 2.0), + this.space = 3.0}); @override Widget build(BuildContext context, SwiperPluginConfig config) { @@ -1201,6 +1199,7 @@ class RectSwiperPaginationBuilder extends SwiperPlugin { List list = []; if (config.itemCount > 20) { + // ignore: avoid_print print( "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation"); } @@ -1210,7 +1209,7 @@ class RectSwiperPaginationBuilder extends SwiperPlugin { for (int i = 0; i < itemCount; ++i) { bool active = i == activeIndex; - Size size = active ? this.activeSize : this.size; + Size size = active ? activeSize : this.size; list.add(SizedBox( width: size.width, height: size.height, @@ -1223,13 +1222,13 @@ class RectSwiperPaginationBuilder extends SwiperPlugin { } if (config.scrollDirection == Axis.vertical) { - return new Column( + return Column( key: key, mainAxisSize: MainAxisSize.min, children: list, ); } else { - return new Row( + return Row( key: key, mainAxisSize: MainAxisSize.min, children: list, @@ -1260,13 +1259,14 @@ class DotSwiperPaginationBuilder extends SwiperPlugin { {this.activeColor, this.color, this.key, - this.size: 10.0, - this.activeSize: 10.0, - this.space: 3.0}); + this.size = 10.0, + this.activeSize = 10.0, + this.space = 3.0}); @override Widget build(BuildContext context, SwiperPluginConfig config) { if (config.itemCount > 20) { + // ignore: avoid_print print( "The itemCount is too big, we suggest use FractionPaginationBuilder instead of DotSwiperPaginationBuilder in this sitituation"); } @@ -1281,7 +1281,7 @@ class DotSwiperPaginationBuilder extends SwiperPlugin { if (config.indicatorLayout != PageIndicatorLayout.NONE && config.layout == SwiperLayout.DEFAULT) { - return new PageIndicator( + return PageIndicator( count: config.itemCount, controller: config.pageController, layout: config.indicatorLayout, @@ -1313,13 +1313,13 @@ class DotSwiperPaginationBuilder extends SwiperPlugin { } if (config.scrollDirection == Axis.vertical) { - return new Column( + return Column( key: key, mainAxisSize: MainAxisSize.min, children: list, ); } else { - return new Row( + return Row( key: key, mainAxisSize: MainAxisSize.min, children: list, @@ -1328,7 +1328,7 @@ class DotSwiperPaginationBuilder extends SwiperPlugin { } } -typedef Widget SwiperPaginationBuilder( +typedef SwiperPaginationBuilder = Widget Function( BuildContext context, SwiperPluginConfig config); class SwiperCustomPagination extends SwiperPlugin { @@ -1344,12 +1344,12 @@ class SwiperCustomPagination extends SwiperPlugin { class SwiperPagination extends SwiperPlugin { /// dot style pagination - static const SwiperPlugin dots = const DotSwiperPaginationBuilder(); + static const SwiperPlugin dots = DotSwiperPaginationBuilder(); /// fraction style pagination - static const SwiperPlugin fraction = const FractionPaginationBuilder(); + static const SwiperPlugin fraction = FractionPaginationBuilder(); - static const SwiperPlugin rect = const RectSwiperPaginationBuilder(); + static const SwiperPlugin rect = RectSwiperPaginationBuilder(); /// Alignment.bottomCenter by default when scrollDirection== Axis.horizontal /// Alignment.centerRight by default when scrollDirection== Axis.vertical @@ -1366,9 +1366,10 @@ class SwiperPagination extends SwiperPlugin { const SwiperPagination( {this.alignment, this.key, - this.margin: const EdgeInsets.all(10.0), - this.builder: SwiperPagination.dots}); + this.margin = const EdgeInsets.all(10.0), + this.builder = SwiperPagination.dots}); + @override Widget build(BuildContext context, SwiperPluginConfig config) { Alignment alignment = this.alignment ?? (config.scrollDirection == Axis.horizontal @@ -1376,10 +1377,10 @@ class SwiperPagination extends SwiperPlugin { : Alignment.centerRight); Widget child = Container( margin: margin, - child: this.builder.build(context, config), + child: builder.build(context, config), ); if (!config.outer) { - child = new Align( + child = Align( key: key, alignment: alignment, child: child, @@ -1413,8 +1414,8 @@ class SwiperPluginConfig { this.itemCount, this.indicatorLayout, this.outer, - this.scrollDirection, - this.controller, + @required this.scrollDirection, + @required this.controller, this.pageController, this.layout, this.loop}) @@ -1446,7 +1447,7 @@ abstract class _CustomLayoutStateBase extends State @override void initState() { if (widget.itemWidth == null) { - throw new Exception( + throw Exception( "==============\n\nwidget.itemWith must not be null when use stack layout.\n========\n"); } @@ -1456,8 +1457,8 @@ abstract class _CustomLayoutStateBase extends State } void _createAnimationController() { - _animationController = new AnimationController(vsync: this, value: 0.5); - Tween tween = new Tween(begin: 0.0, end: 1.0); + _animationController = AnimationController(vsync: this, value: 0.5); + Tween tween = Tween(begin: 0.0, end: 1.0); _animation = tween.animate(_animationController); } @@ -1467,7 +1468,7 @@ abstract class _CustomLayoutStateBase extends State super.didChangeDependencies(); } - void _getSize(_) { + void _getSize(dynamic _) { afterRender(); } @@ -1514,7 +1515,7 @@ abstract class _CustomLayoutStateBase extends State Widget _buildItem(int i, int realIndex, double animationValue); Widget _buildContainer(List list) { - return new Stack( + return Stack( children: list, ); } @@ -1534,13 +1535,13 @@ abstract class _CustomLayoutStateBase extends State list.add(_buildItem(i, realIndex, animationValue)); } - return new GestureDetector( + return GestureDetector( behavior: HitTestBehavior.opaque, onPanStart: _onPanStart, onPanEnd: _onPanEnd, onPanUpdate: _onPanUpdate, - child: new ClipRect( - child: new Center( + child: ClipRect( + child: Center( child: _buildContainer(list), ), ), @@ -1550,9 +1551,9 @@ abstract class _CustomLayoutStateBase extends State @override Widget build(BuildContext context) { if (_animationCount == null) { - return new Container(); + return Container(); } - return new AnimatedBuilder( + return AnimatedBuilder( animation: _animationController, builder: _buildAnimation); } @@ -1561,23 +1562,25 @@ abstract class _CustomLayoutStateBase extends State bool _lockScroll = false; - void _move(double position, {int nextIndex}) async { + Future _move(double position, {int nextIndex}) async { if (_lockScroll) return; try { _lockScroll = true; await _animationController.animateTo(position, - duration: new Duration(milliseconds: widget.duration), + duration: Duration(milliseconds: widget.duration), curve: widget.curve); if (nextIndex != null) { widget.onIndexChanged(widget.getCorrectIndex(nextIndex)); } } catch (e) { + // ignore: avoid_print print(e); } finally { if (nextIndex != null) { try { _animationController.value = 0.5; } catch (e) { + // ignore: avoid_print print(e); } @@ -1616,7 +1619,7 @@ abstract class _CustomLayoutStateBase extends State _move(0.0, nextIndex: nextIndex); break; case IndexController.MOVE: - throw new Exception( + throw Exception( "Custom layout does not support SwiperControllerEvent.MOVE_INDEX yet!"); case SwiperController.STOP_AUTOPLAY: case SwiperController.START_AUTOPLAY: @@ -1711,7 +1714,7 @@ Offset _getOffsetValue(List values, double animationValue, int index) { dy = dy - (dy - values[index - 1].dy) * (0.5 - animationValue) * 2.0; } } - return new Offset(dx, dy); + return Offset(dx, dy); } abstract class TransformBuilder { @@ -1722,21 +1725,24 @@ abstract class TransformBuilder { class ScaleTransformBuilder extends TransformBuilder { final Alignment alignment; - ScaleTransformBuilder({List values, this.alignment: Alignment.center}) + ScaleTransformBuilder( + {List values, this.alignment = Alignment.center}) : super(values: values); + @override Widget build(int i, double animationValue, Widget widget) { double s = _getValue(values, animationValue, i); - return new Transform.scale(scale: s, child: widget); + return Transform.scale(scale: s, child: widget); } } class OpacityTransformBuilder extends TransformBuilder { OpacityTransformBuilder({List values}) : super(values: values); + @override Widget build(int i, double animationValue, Widget widget) { double v = _getValue(values, animationValue, i); - return new Opacity( + return Opacity( opacity: v, child: widget, ); @@ -1746,9 +1752,10 @@ class OpacityTransformBuilder extends TransformBuilder { class RotateTransformBuilder extends TransformBuilder { RotateTransformBuilder({List values}) : super(values: values); + @override Widget build(int i, double animationValue, Widget widget) { double v = _getValue(values, animationValue, i); - return new Transform.rotate( + return Transform.rotate( angle: v, child: widget, ); @@ -1761,7 +1768,7 @@ class TranslateTransformBuilder extends TransformBuilder { @override Widget build(int i, double animationValue, Widget widget) { Offset s = _getOffsetValue(values, animationValue, i); - return new Transform.translate( + return Transform.translate( offset: s, child: widget, ); @@ -1773,27 +1780,26 @@ class CustomLayoutOption { final int startIndex; final int stateCount; - CustomLayoutOption({this.stateCount, this.startIndex}) + CustomLayoutOption({this.stateCount, @required this.startIndex}) : assert(startIndex != null, stateCount != null); CustomLayoutOption addOpacity(List values) { - builders.add(new OpacityTransformBuilder(values: values)); + builders.add(OpacityTransformBuilder(values: values)); return this; } CustomLayoutOption addTranslate(List values) { - builders.add(new TranslateTransformBuilder(values: values)); + builders.add(TranslateTransformBuilder(values: values)); return this; } CustomLayoutOption addScale(List values, Alignment alignment) { - builders - .add(new ScaleTransformBuilder(values: values, alignment: alignment)); + builders.add(ScaleTransformBuilder(values: values, alignment: alignment)); return this; } CustomLayoutOption addRotate(List values) { - builders.add(new RotateTransformBuilder(values: values)); + builders.add(RotateTransformBuilder(values: values)); return this; } } @@ -1801,8 +1807,8 @@ class CustomLayoutOption { class _CustomLayoutSwiper extends _SubSwiper { final CustomLayoutOption option; - _CustomLayoutSwiper( - {this.option, + const _CustomLayoutSwiper( + {@required this.option, double itemWidth, bool loop, double itemHeight, @@ -1832,7 +1838,7 @@ class _CustomLayoutSwiper extends _SubSwiper { @override State createState() { - return new _CustomLayoutState(); + return _CustomLayoutState(); } } @@ -1855,7 +1861,7 @@ class _CustomLayoutState extends _CustomLayoutStateBase<_CustomLayoutSwiper> { Widget _buildItem(int index, int realIndex, double animationValue) { List builders = widget.option.builders; - Widget child = new SizedBox( + Widget child = SizedBox( width: widget.itemWidth ?? double.infinity, height: widget.itemHeight ?? double.infinity, child: widget.itemBuilder(context, realIndex)); diff --git a/web/filipino_cuisine/lib/main.dart b/web/filipino_cuisine/lib/main.dart index a7899e273..cf51835eb 100644 --- a/web/filipino_cuisine/lib/main.dart +++ b/web/filipino_cuisine/lib/main.dart @@ -1,7 +1,6 @@ +import 'dart:convert'; import 'package:flutter/material.dart'; - import 'package:http/http.dart' as http; -import 'dart:convert'; import 'cook.dart'; import 'flutter_swiper.dart'; @@ -9,101 +8,107 @@ import 'flutter_swiper.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { - Widget build(ct) { + @override + Widget build(context) { return MaterialApp( theme: ThemeData( brightness: Brightness.light, accentColor: Colors.red, - iconTheme: IconThemeData(color: Colors.red)), + iconTheme: const IconThemeData(color: Colors.red)), title: "Filipino Cuisine", home: Home()); } } class Home extends StatefulWidget { + @override HState createState() => HState(); } class HState extends State { - Map fd; - Map fi; + Map fd; + Map fi; + @override void initState() { super.initState(); getData(); } - getData() async { - http.Response r = - await http.get('/data.json'); - fd = json.decode(r.body); - setState(() => fi = fd['0']); + Future getData() async { + http.Response r = await http.get('/data.json'); + fd = json.decode(r.body) as Map; + setState(() => fi = fd['0'] as Map); } - Widget build(ct) { - if (fd == null) + @override + Widget build(context) { + if (fd == null) { return Container( - color: Colors.white, - child: Center( - child: CircularProgressIndicator(), - )); - var t = Theme.of(ct).textTheme; + color: Colors.white, + child: const Center( + child: CircularProgressIndicator(), + ), + ); + } + var t = Theme.of(context).textTheme; return Scaffold( body: Column( children: [ Expanded( flex: 5, child: Swiper( - onIndexChanged: (n) => setState(() => fi = fd['$n']), + onIndexChanged: (n) => + setState(() => fi = fd['$n'] as Map), itemCount: fd.keys.where((key) => int.tryParse(key) != null).length, itemBuilder: (cx, i) { return Container( - margin: EdgeInsets.only(top: 40, bottom: 24), + margin: const EdgeInsets.only(top: 40, bottom: 24), child: ClipRRect( borderRadius: BorderRadius.circular(20), child: Hero( tag: fd['$i']['fn'], - child: Image.asset(fd['$i']['pf'], + child: Image.asset(fd['$i']['pf'] as String, fit: BoxFit.cover)), )); }, viewportFraction: .85, scale: .9)), - Text(fi['fn'], + Text(fi['fn'] as String, style: t.headline2.copyWith(fontFamily: 'ark', color: Colors.black)), Container( - child: Text(fi['cn'], + child: Text(fi['cn'] as String, style: t.subtitle1.apply(color: Colors.red, fontFamily: 'opb')), - margin: EdgeInsets.only(top: 10, bottom: 30), + margin: const EdgeInsets.only(top: 10, bottom: 30), ), Container( - child: Text(fi['dc'], + child: Text(fi['dc'] as String, textAlign: TextAlign.center, style: t.subtitle1.copyWith(fontFamily: 'opr')), - margin: EdgeInsets.only(left: 10, right: 10)), + margin: const EdgeInsets.only(left: 10, right: 10)), Expanded( flex: 2, child: ListView.builder( scrollDirection: Axis.horizontal, - itemCount: fi['ig'].length, + itemCount: fi['ig'].length as int, itemBuilder: (cx, i) { return Row(children: [ Container( - margin: EdgeInsets.only(left: 10), + margin: const EdgeInsets.only(left: 10), height: 60, - child: Image.asset(fi['ig'][i]['p'], + child: Image.asset(fi['ig'][i]['p'] as String, fit: BoxFit.contain)), Container( - margin: EdgeInsets.only(left: 5, right: 10), + margin: const EdgeInsets.only(left: 5, right: 10), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(fi['ig'][i]['n'], + Text(fi['ig'][i]['n'] as String, style: t.subtitle2 .copyWith(fontFamily: 'opb')), - Text(fi['ig'][i]['c'], + Text(fi['ig'][i]['c'] as String, style: t.caption.copyWith(fontFamily: 'opr')) ])) @@ -113,23 +118,29 @@ class HState extends State { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked, floatingActionButton: FloatingActionButton( - child: Icon(Icons.restaurant_menu), - onPressed: () => Navigator.push( - ct, + child: const Icon(Icons.restaurant_menu), + onPressed: () => Navigator.push( + context, MaterialPageRoute( - builder: (cx) => Cook(fi['in'], fi['pf'], fi['fn']))), + builder: (cx) => Cook( + fi['in'] as List, + fi['pf'] as String, + fi['fn'] as String, + ))), ), bottomNavigationBar: BottomAppBar( - shape: CircularNotchedRectangle(), + shape: const CircularNotchedRectangle(), notchMargin: 4.0, child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ IconButton( - icon: - Icon(fi['fv'] ? Icons.favorite : Icons.favorite_border), - onPressed: () => setState(() => fi['fv'] = !fi['fv'])), - IconButton(icon: Icon(Icons.share), onPressed: () {}) + icon: Icon(fi['fv'] as bool + ? Icons.favorite + : Icons.favorite_border), + onPressed: () => + setState(() => fi['fv'] = !(fi['fv'] as bool))), + IconButton(icon: const Icon(Icons.share), onPressed: () {}) ])), ); } diff --git a/web/filipino_cuisine/lib/transformer_page_view.dart b/web/filipino_cuisine/lib/transformer_page_view.dart index 3b586a849..4ce370a77 100644 --- a/web/filipino_cuisine/lib/transformer_page_view.dart +++ b/web/filipino_cuisine/lib/transformer_page_view.dart @@ -7,37 +7,40 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; class IndexController extends ChangeNotifier { + // ignore: constant_identifier_names static const int NEXT = 1; + // ignore: constant_identifier_names static const int PREVIOUS = -1; + // ignore: constant_identifier_names static const int MOVE = 0; - Completer _completer; + Completer _completer; int index; bool animation; int event; - Future move(int index, {bool animation: true}) { + Future move(int index, {bool animation = true}) { this.animation = animation ?? true; this.index = index; - this.event = MOVE; - _completer = new Completer(); + event = MOVE; + _completer = Completer(); notifyListeners(); return _completer.future; } - Future next({bool animation: true}) { - this.event = NEXT; + Future next({bool animation = true}) { + event = NEXT; this.animation = animation ?? true; - _completer = new Completer(); + _completer = Completer(); notifyListeners(); return _completer.future; } - Future previous({bool animation: true}) { - this.event = PREVIOUS; + Future previous({bool animation = true}) { + event = PREVIOUS; this.animation = animation ?? true; - _completer = new Completer(); + _completer = Completer(); notifyListeners(); return _completer.future; } @@ -49,7 +52,7 @@ class IndexController extends ChangeNotifier { } } -typedef void PaintCallback(Canvas canvas, Size siz); +typedef PaintCallback = void Function(Canvas canvas, Size siz); class ColorPainter extends CustomPainter { final Paint _paint; @@ -62,8 +65,7 @@ class ColorPainter extends CustomPainter { void paint(Canvas canvas, Size size) { int index = info.fromIndex; _paint.color = colors[index]; - canvas.drawRect( - new Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); + canvas.drawRect(Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); if (info.done) { return; } @@ -85,9 +87,9 @@ class ColorPainter extends CustomPainter { } alpha = (0xff * opacity).toInt(); - _paint.color = new Color((alpha << 24) | color); + _paint.color = Color((alpha << 24) | color); canvas.drawRect( - new Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); + Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); } } else { if (index > 0) { @@ -103,9 +105,9 @@ class ColorPainter extends CustomPainter { } alpha = (0xff * opacity).toInt(); - _paint.color = new Color((alpha << 24) | color); + _paint.color = Color((alpha << 24) | color); canvas.drawRect( - new Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); + Rect.fromLTWH(0.0, 0.0, size.width, size.height), _paint); } } } @@ -117,12 +119,12 @@ class ColorPainter extends CustomPainter { } class _ParallaxColorState extends State { - Paint paint = new Paint(); + Paint paint = Paint(); @override Widget build(BuildContext context) { - return new CustomPaint( - painter: new ColorPainter(paint, widget.info, widget.colors), + return CustomPaint( + painter: ColorPainter(paint, widget.info, widget.colors), child: widget.child, ); } @@ -135,7 +137,7 @@ class ParallaxColor extends StatefulWidget { final TransformInfo info; - ParallaxColor({ + const ParallaxColor({ @required this.colors, @required this.info, @required this.child, @@ -143,7 +145,7 @@ class ParallaxColor extends StatefulWidget { @override State createState() { - return new _ParallaxColorState(); + return _ParallaxColorState(); } } @@ -153,20 +155,20 @@ class ParallaxContainer extends StatelessWidget { final double translationFactor; final double opacityFactor; - ParallaxContainer( + const ParallaxContainer( {@required this.child, @required this.position, - this.translationFactor: 100.0, - this.opacityFactor: 1.0}) + this.translationFactor = 100.0, + this.opacityFactor = 1.0}) : assert(position != null), assert(translationFactor != null); @override Widget build(BuildContext context) { return Opacity( - opacity: (1 - position.abs()).clamp(0.0, 1.0) * opacityFactor, - child: new Transform.translate( - offset: new Offset(position * translationFactor, 0.0), + opacity: (1 - position.abs()).clamp(0.0, 1.0) * opacityFactor as double, + child: Transform.translate( + offset: Offset(position * translationFactor, 0.0), child: child, ), ); @@ -177,7 +179,7 @@ class ParallaxImage extends StatelessWidget { final Image image; final double imageFactor; - ParallaxImage.asset(String name, {double position, this.imageFactor: 0.3}) + ParallaxImage.asset(String name, {double position, this.imageFactor = 0.3}) : assert(imageFactor != null), image = Image.asset(name, fit: BoxFit.cover, @@ -262,18 +264,19 @@ abstract class PageTransformer { /// final bool reverse; - PageTransformer({this.reverse: false}); + PageTransformer({this.reverse = false}); /// Return a transformed widget, based on child and TransformInfo Widget transform(Widget child, TransformInfo info); } -typedef Widget PageTransformerBuilderCallback(Widget child, TransformInfo info); +typedef PageTransformerBuilderCallback = Widget Function( + Widget child, TransformInfo info); class PageTransformerBuilder extends PageTransformer { final PageTransformerBuilderCallback builder; - PageTransformerBuilder({bool reverse: false, @required this.builder}) + PageTransformerBuilder({bool reverse = false, @required this.builder}) : assert(builder != null), super(reverse: reverse); @@ -292,16 +295,16 @@ class TransformerPageController extends PageController { int initialPage = 0, bool keepPage = true, double viewportFraction = 1.0, - this.loop: false, + this.loop = false, this.itemCount, - this.reverse: false, + this.reverse = false, }) : super( initialPage: TransformerPageController._getRealIndexFromRenderIndex( initialPage ?? 0, loop, itemCount, reverse), keepPage: keepPage, viewportFraction: viewportFraction); - int getRenderIndexFromRealIndex(num index) { + int getRenderIndexFromRealIndex(int index) { return _getRenderIndexFromRealIndex(index, loop, itemCount, reverse); } @@ -310,8 +313,8 @@ class TransformerPageController extends PageController { return loop ? itemCount + kMaxValue : itemCount; } - static _getRenderIndexFromRealIndex( - num index, bool loop, int itemCount, bool reverse) { + static int _getRenderIndexFromRealIndex( + int index, bool loop, int itemCount, bool reverse) { if (itemCount == 0) return 0; int renderIndex; if (loop) { @@ -341,7 +344,7 @@ class TransformerPageController extends PageController { return page; } - static _getRenderPageFromRealPage( + static double _getRenderPageFromRealPage( double page, bool loop, int itemCount, bool reverse) { double renderPage; if (loop) { @@ -360,18 +363,19 @@ class TransformerPageController extends PageController { return renderPage; } + @override double get page { return loop ? _getRenderPageFromRealPage(realPage, loop, itemCount, reverse) : realPage; } - int getRealIndexFromRenderIndex(num index) { + int getRealIndexFromRenderIndex(int index) { return _getRealIndexFromRenderIndex(index, loop, itemCount, reverse); } static int _getRealIndexFromRenderIndex( - num index, bool loop, int itemCount, bool reverse) { + int index, bool loop, int itemCount, bool reverse) { int result = reverse ? (itemCount - index - 1) : index; if (loop) { result += kMiddleValue; @@ -439,13 +443,13 @@ class TransformerPageView extends StatefulWidget { /// /// [itemBuilder] will be called only with indices greater than or equal to /// zero and less than [itemCount]. - TransformerPageView({ + const TransformerPageView({ Key key, this.index, Duration duration, - this.curve: Curves.ease, - this.viewportFraction: 1.0, - this.loop: false, + this.curve = Curves.ease, + this.viewportFraction = 1.0, + this.loop = false, this.scrollDirection = Axis.horizontal, this.physics, this.pageSnapping = true, @@ -457,17 +461,17 @@ class TransformerPageView extends StatefulWidget { @required this.itemCount, }) : assert(itemCount != null), assert(itemCount == 0 || itemBuilder != null || transformer != null), - this.duration = - duration ?? new Duration(milliseconds: kDefaultTransactionDuration), + duration = duration ?? + const Duration(milliseconds: kDefaultTransactionDuration), super(key: key); factory TransformerPageView.children( {Key key, int index, Duration duration, - Curve curve: Curves.ease, - double viewportFraction: 1.0, - bool loop: false, + Curve curve = Curves.ease, + double viewportFraction = 1.0, + bool loop = false, Axis scrollDirection = Axis.horizontal, ScrollPhysics physics, bool pageSnapping = true, @@ -477,9 +481,9 @@ class TransformerPageView extends StatefulWidget { @required List children, TransformerPageController pageController}) { assert(children != null); - return new TransformerPageView( + return TransformerPageView( itemCount: children.length, - itemBuilder: (BuildContext context, int index) { + itemBuilder: (context, index) { return children[index]; }, pageController: pageController, @@ -499,7 +503,7 @@ class TransformerPageView extends StatefulWidget { @override State createState() { - return new _TransformerPageViewState(); + return _TransformerPageViewState(); } static int getRealIndexFromRenderIndex( @@ -517,7 +521,7 @@ class TransformerPageView extends StatefulWidget { int itemCount, bool loop, double viewportFraction}) { - return new PageController( + return PageController( initialPage: getRealIndexFromRenderIndex( reverse: reverse, index: index, itemCount: itemCount, loop: loop), viewportFraction: viewportFraction); @@ -544,19 +548,17 @@ class _TransformerPageViewState extends State { } Widget _buildItem(BuildContext context, int index) { - return new AnimatedBuilder( + return AnimatedBuilder( animation: _pageController, - builder: (BuildContext c, Widget w) { + builder: (c, w) { int renderIndex = _pageController.getRenderIndexFromRealIndex(index); Widget child; if (widget.itemBuilder != null) { child = widget.itemBuilder(context, renderIndex); } - if (child == null) { - child = new Container(); - } + child ??= Container(); if (_size == null) { - return child ?? new Container(); + return child ?? Container(); } double position; @@ -570,11 +572,11 @@ class _TransformerPageViewState extends State { } position *= widget.viewportFraction; - TransformInfo info = new TransformInfo( + TransformInfo info = TransformInfo( index: renderIndex, width: _size.width, height: _size.height, - position: position.clamp(-1.0, 1.0), + position: position.clamp(-1.0, 1.0) as double, activeIndex: _pageController.getRenderIndexFromRealIndex(_activeIndex), fromIndex: _fromIndex, @@ -600,7 +602,7 @@ class _TransformerPageViewState extends State { Widget build(BuildContext context) { IndexedWidgetBuilder builder = _transformer == null ? _buildItemNormal : _buildItem; - Widget child = new PageView.builder( + Widget child = PageView.builder( itemBuilder: builder, itemCount: _pageController.getRealItemCount(), onPageChanged: _onIndexChanged, @@ -613,7 +615,8 @@ class _TransformerPageViewState extends State { if (_transformer == null) { return child; } - return new NotificationListener( + return NotificationListener( + // ignore: avoid_types_on_closure_parameters onNotification: (ScrollNotification notification) { if (notification is ScrollStartNotification) { _calcCurrentPixels(); @@ -637,7 +640,7 @@ class _TransformerPageViewState extends State { } } - void _onGetSize(_) { + void _onGetSize(dynamic _) { Size size; if (context == null) { onGetSize(size); @@ -667,14 +670,12 @@ class _TransformerPageViewState extends State { _transformer = widget.transformer; // int index = widget.index ?? 0; _pageController = widget.pageController; - if (_pageController == null) { - _pageController = new TransformerPageController( - initialPage: widget.index, - itemCount: widget.itemCount, - loop: widget.loop, - reverse: - widget.transformer == null ? false : widget.transformer.reverse); - } + _pageController ??= TransformerPageController( + initialPage: widget.index, + itemCount: widget.itemCount, + loop: widget.loop, + reverse: + widget.transformer == null ? false : widget.transformer.reverse); // int initPage = _getRealIndexFromRenderIndex(index); // _pageController = new PageController(initialPage: initPage,viewportFraction: widget.viewportFraction); _fromIndex = _activeIndex = _pageController.initialPage; @@ -696,7 +697,7 @@ class _TransformerPageViewState extends State { _pageController = widget.pageController; } else { created = true; - _pageController = new TransformerPageController( + _pageController = TransformerPageController( initialPage: widget.index, itemCount: widget.itemCount, loop: widget.loop, @@ -714,8 +715,9 @@ class _TransformerPageViewState extends State { duration: widget.duration, curve: widget.curve); } } - if (_transformer != null) + if (_transformer != null) { WidgetsBinding.instance.addPostFrameCallback(_onGetSize); + } if (_controller != getNotifier()) { if (_controller != null) { @@ -731,8 +733,9 @@ class _TransformerPageViewState extends State { @override void didChangeDependencies() { - if (_transformer != null) + if (_transformer != null) { WidgetsBinding.instance.addPostFrameCallback(_onGetSize); + } super.didChangeDependencies(); } @@ -800,6 +803,7 @@ class _TransformerPageViewState extends State { ChangeNotifier _controller; + @override void dispose() { super.dispose(); if (_controller != null) { diff --git a/web/filipino_cuisine/pubspec.lock b/web/filipino_cuisine/pubspec.lock index e0259c16e..ba07e52c3 100644 --- a/web/filipino_cuisine/pubspec.lock +++ b/web/filipino_cuisine/pubspec.lock @@ -7,7 +7,7 @@ packages: name: characters url: "https://pub.dartlang.org" source: hosted - version: "1.1.0-nullsafety.5" + version: "1.1.0" charcode: dependency: transitive description: @@ -21,12 +21,19 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0-nullsafety.5" + version: "1.15.0" flutter: dependency: "direct main" description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.3" flutter_page_indicator: dependency: transitive description: @@ -55,13 +62,20 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "3.1.4" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.1" meta: dependency: transitive description: name: meta url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.6" + version: "1.3.0" path: dependency: transitive description: @@ -70,7 +84,7 @@ packages: source: hosted version: "1.7.0" pedantic: - dependency: "direct dev" + dependency: transitive description: name: pedantic url: "https://pub.dartlang.org" @@ -115,14 +129,14 @@ packages: name: typed_data url: "https://pub.dartlang.org" source: hosted - version: "1.3.0-nullsafety.5" + version: "1.3.0" vector_math: dependency: transitive description: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.0-nullsafety.5" + version: "2.1.0" sdks: - dart: ">=2.12.0-0 <3.0.0" + dart: ">=2.12.0 <3.0.0" flutter: ">=0.1.4" diff --git a/web/filipino_cuisine/pubspec.yaml b/web/filipino_cuisine/pubspec.yaml index 714e03445..70538afd5 100644 --- a/web/filipino_cuisine/pubspec.yaml +++ b/web/filipino_cuisine/pubspec.yaml @@ -10,8 +10,7 @@ dependencies: http: ^0.12.0 dev_dependencies: - pedantic: ^1.9.0 - + flutter_lints: ^1.0.0 flutter_icons: android: "launcher_icon" @@ -64,4 +63,4 @@ flutter: - asset: fonts/OpenSans-Bold.ttf - family: ark fonts: - - asset: fonts/Arkipelago.otf \ No newline at end of file + - asset: fonts/Arkipelago.otf diff --git a/web/samples_index/analysis_options.yaml b/web/samples_index/analysis_options.yaml index a686c1b45..a0c881db6 100644 --- a/web/samples_index/analysis_options.yaml +++ b/web/samples_index/analysis_options.yaml @@ -1,14 +1,22 @@ -# Defines a default set of lint rules enforced for -# projects at Google. For details and rationale, -# see https://github.com/dart-lang/pedantic#enabled-lints. -include: package:pedantic/analysis_options.yaml - -# For lint rules and documentation, see http://dart-lang.github.io/linter/lints. -# Uncomment to specify additional rules. -# linter: -# rules: -# - camel_case_types +include: package:flutter_lints/flutter.yaml analyzer: -# exclude: -# - path/to/excluded/files/** + exclude: + - lib/src/data.g.dart + strong-mode: + implicit-casts: false + implicit-dynamic: false + +linter: + rules: + avoid_types_on_closure_parameters: true + avoid_void_async: true + cancel_subscriptions: true + close_sinks: true + directives_ordering: true + 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/web/samples_index/lib/cookbook.dart b/web/samples_index/lib/cookbook.dart index b323855fa..c42c1dff1 100644 --- a/web/samples_index/lib/cookbook.dart +++ b/web/samples_index/lib/cookbook.dart @@ -15,7 +15,7 @@ class CookbookScraper { WebDriver _driver; Future init() async { - _driver = await createDriver(desired: {}); + _driver = await createDriver(desired: {}); } Future dispose() async { diff --git a/web/samples_index/lib/samples_index.dart b/web/samples_index/lib/samples_index.dart index 3910df941..6fd6be892 100644 --- a/web/samples_index/lib/samples_index.dart +++ b/web/samples_index/lib/samples_index.dart @@ -4,9 +4,9 @@ import 'dart:convert'; import 'dart:io'; +import 'package:checked_yaml/checked_yaml.dart'; import 'src/data.dart'; -import 'package:checked_yaml/checked_yaml.dart'; export 'src/data.dart'; @@ -17,6 +17,7 @@ Future> getSamples() async { var cookbookContents = await cookbookFile.readAsString(); var index = checkedYamlDecode(contents, (m) => Index.fromJson(m), sourceUrl: yamlFile.uri); - var cookbookIndex = Index.fromJson(json.decode(cookbookContents)); + var cookbookIndex = + Index.fromJson(json.decode(cookbookContents) as Map); return index.samples..addAll(cookbookIndex.samples); } diff --git a/web/samples_index/lib/src/carousel.dart b/web/samples_index/lib/src/carousel.dart index 58ec08531..cb94a4729 100644 --- a/web/samples_index/lib/src/carousel.dart +++ b/web/samples_index/lib/src/carousel.dart @@ -45,13 +45,14 @@ class Carousel { // Move to the first slide after init // This is responsible for creating a smooth animation - Future.delayed(Duration(milliseconds: 500)).then((value) => _slideRight()); + Future.delayed(const Duration(milliseconds: 500)) + .then((value) => _slideRight()); } void _hideSlides() { - slides.forEach((s) { + for (final s in slides) { s.classes.add('next-hidden'); - }); + } } void _initBullets() { @@ -95,7 +96,7 @@ class Carousel { void _touchEndListener(TouchEvent e) { if (touched) { - int dx = e.changedTouches.first.client.x - x0; + int dx = (e.changedTouches.first.client.x - x0) as int; // dx==0 case is ignored if (dx > 0 && currentSlideIndex > 0) { @@ -167,11 +168,11 @@ class Carousel { nextSlide = slides[0]; } - slides.forEach((e) { + for (final e in slides) { _removeSlideClasses([e]); if (e.classes.contains('prev-hidden')) e.classes.add('next-hidden'); if (e.classes.contains('prev')) e.classes.add('prev-hidden'); - }); + } _removeSlideClasses([prevSlide, currentSlide, nextSlide]); @@ -203,11 +204,11 @@ class Carousel { prevSlide = slides[lastSlideIndex]; } - slides.forEach((e) { + for (final e in slides) { _removeSlideClasses([e]); if (e.classes.contains('next')) e.classes.add('next-hidden'); if (e.classes.contains('next-hidden')) e.classes.add('prev-hidden'); - }); + } _removeSlideClasses([prevSlide, currentSlide, nextSlide]); @@ -218,7 +219,7 @@ class Carousel { _updateBullets(); } - void _goToIndexSlide(index) { + void _goToIndexSlide(int index) { final sliding = (currentSlideIndex < index) ? () => _slideRight() : () => _slideLeft(); while (currentSlideIndex != index) { @@ -227,10 +228,10 @@ class Carousel { } void _removeSlideClasses(List slides) { - slides.forEach((s) { + for (final s in slides) { s.classes .removeAll(['prev-hidden', 'prev', 'active', 'next', 'next-hidden']); - }); + } } void _initArrowKeyControl() { diff --git a/web/samples_index/lib/src/templates.dart b/web/samples_index/lib/src/templates.dart index 7e778b591..b9ef3d257 100644 --- a/web/samples_index/lib/src/templates.dart +++ b/web/samples_index/lib/src/templates.dart @@ -7,9 +7,9 @@ import 'data.dart'; import 'util.dart' as util; String _escapeAttribute(String s) => - HtmlEscape(HtmlEscapeMode.attribute).convert(s); + const HtmlEscape(HtmlEscapeMode.attribute).convert(s); String _escapeElement(String s) => - HtmlEscape(HtmlEscapeMode.element).convert(s); + const HtmlEscape(HtmlEscapeMode.element).convert(s); String description(Sample sample) => ''' diff --git a/web/samples_index/pubspec.yaml b/web/samples_index/pubspec.yaml index 0a52487df..2185f65a2 100644 --- a/web/samples_index/pubspec.yaml +++ b/web/samples_index/pubspec.yaml @@ -4,7 +4,7 @@ homepage: https://github.com/flutter/samples_index author: Flutter Team version: 0.0.1 environment: - sdk: '>=2.5.0 <3.0.0' + sdk: ">=2.5.0 <3.0.0" dependencies: json_annotation: ^3.0.0 path: ^1.6.0 @@ -16,7 +16,7 @@ dependencies: html: ^0.14.0 dev_dependencies: grinder: ^0.8.3 - pedantic: ^1.9.0 + flutter_lints: ^1.0.0 test: ^1.6.0 json_serializable: ^3.2.0 build: ^1.2.0 diff --git a/web/samples_index/test/samples_index_test.dart b/web/samples_index/test/samples_index_test.dart index d06144c94..2df5f26c2 100644 --- a/web/samples_index/test/samples_index_test.dart +++ b/web/samples_index/test/samples_index_test.dart @@ -54,7 +54,7 @@ void main() { var sample = index.samples.first; expect( sample.searchAttributes.split(' '), - containsAll([ + containsAll(const [ 'kittens', 'tag:beginner', 'tag:kittens', diff --git a/web/samples_index/tool/grind.dart b/web/samples_index/tool/grind.dart index 450c62538..4456d0c5d 100644 --- a/web/samples_index/tool/grind.dart +++ b/web/samples_index/tool/grind.dart @@ -2,8 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file -import 'dart:io'; import 'dart:convert'; +import 'dart:io'; import 'package:grinder/grinder.dart'; import 'package:path/path.dart' as path; @@ -12,10 +12,11 @@ import 'package:samples_index/src/templates.dart' as templates; import 'package:samples_index/cookbook.dart'; import 'package:image/image.dart' as image; -void main(args) => grind(args); +Future main(List args) => grind(args); @Task('Run tests in the VM') -void testCli() async => await TestRunner().testAsync(platformSelector: 'vm'); +Future testCli() async => + await TestRunner().testAsync(platformSelector: 'vm'); @Task() void analyze() { @@ -25,13 +26,13 @@ void analyze() { @Task('deploy') @Depends(analyze, testCli, generate, buildRelease) void deploy() { - print('All tasks completed. '); - print(''); + log('All tasks completed. '); + log(''); } @Task('Run build_runner to public/ directory') @Depends(createThumbnails) -Future buildRelease() async { +Future buildRelease() async { var app = PubApp.local('build_runner'); await app.runAsync( 'build --release --output web:public --delete-conflicting-outputs' @@ -41,9 +42,9 @@ Future buildRelease() async { @DefaultTask('Build the project.') @Depends(clean) -Future generate() async { +Future generate() async { var samples = await getSamples(); - print('Generating index for ${samples.length} samples...'); + log('Generating index for ${samples.length} samples...'); var outputFile = File('web/index.html'); await outputFile.create(recursive: true); await outputFile.writeAsString(templates.index(samples)); @@ -55,12 +56,12 @@ Future generate() async { }); futures.add(future); } - await Future.wait(futures); - print('Generated index for ${samples.length} samples.'); + await Future.wait(futures); + log('Generated index for ${samples.length} samples.'); } @Task('Scrape the cookbook for images and descriptions') -Future scrapeCookbook() async { +Future scrapeCookbook() async { var driver = await Process.start( 'chromedriver', ['--port=4444', '--url-base=wd/hub', '--verbose']); await driver.stdout.pipe(stdout); @@ -68,7 +69,7 @@ Future scrapeCookbook() async { var scraper = CookbookScraper(); await scraper.init(); var links = await scraper.fetchCookbookLinks(); - print('Scraping ${links.length} cookbook articles'); + log('Scraping ${links.length} cookbook articles'); var allSamples = []; for (var link in links) { allSamples.add(await scraper.getMetadata(link)); @@ -76,23 +77,23 @@ Future scrapeCookbook() async { } var file = File('lib/src/cookbook.json'); await file.create(); - var encoder = JsonEncoder.withIndent('\t'); + var encoder = const JsonEncoder.withIndent('\t'); await file.writeAsString(encoder.convert(Index(allSamples))); await scraper.dispose(); var killed = driver.kill(); if (!killed) { - print('failed to kill chromedriver process'); + log('failed to kill chromedriver process'); } } @Task('creates thumbnail images in web/images') -Future createThumbnails() async { +Future createThumbnails() async { await _createThumbnails(Directory('web/images')); await _createThumbnails(Directory('web/images/cookbook')); } // Creates a thumbnail image for each png file -Future _createThumbnails(Directory directory) async { +Future _createThumbnails(Directory directory) async { var files = await directory.list().toList(); var filesToWrite = {}; @@ -112,16 +113,16 @@ Future _createThumbnails(Directory directory) async { filesToWrite.add(thumbnailFile.writeAsBytes(image.encodePng(resized))); } - await Future.wait(filesToWrite); + await Future.wait(filesToWrite); } @Task('remove generated HTML files') -Future clean() async { +Future clean() async { var tasks = []; await for (var file in Directory('web').list(recursive: true)) { if (path.extension(file.path) == '.html') { tasks.add(file.delete()); } } - await Future.wait(tasks); + await Future.wait(tasks); } diff --git a/web/samples_index/web/main.dart b/web/samples_index/web/main.dart index 39c885d44..90ef493e1 100644 --- a/web/samples_index/web/main.dart +++ b/web/samples_index/web/main.dart @@ -37,13 +37,13 @@ void main() { })); // Filter cards on each keypress - searchBar.listen('keydown', (Event e) async { + searchBar.listen('keydown', (e) async { await Future(() {}); handleSearch(); }); // Update the URL only when the user is done typing in the search bar - searchBar.listen('change', (Event e) { + searchBar.listen('change', (e) { queryParams[searchKey] = searchBar.value; updateHash(); }); @@ -58,7 +58,7 @@ void main() { // Initialize chips chipSet = MDCChipSet(querySelector('.mdc-chip-set')); - chipSet.listen('MDCChip:selection', (Event e) { + chipSet.listen('MDCChip:selection', (e) { // Get the query parameters for this chip var selectedChipIndex = chipSet.chips.indexWhere((chip) => chip.selected); var chipParams = paramsForChip(selectedChipIndex);