diff --git a/shrine/analysis_options.yaml b/shrine/analysis_options.yaml new file mode 100644 index 000000000..f117e8a5f --- /dev/null +++ b/shrine/analysis_options.yaml @@ -0,0 +1,30 @@ +include: package:pedantic/analysis_options.yaml + +analyzer: + strong-mode: + implicit-casts: false + implicit-dynamic: false + +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 + - 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 diff --git a/shrine/lib/app.dart b/shrine/lib/app.dart index 846358158..97316f988 100644 --- a/shrine/lib/app.dart +++ b/shrine/lib/app.dart @@ -72,7 +72,7 @@ Route _getRoute(RouteSettings settings) { return MaterialPageRoute( settings: settings, - builder: (BuildContext context) => LoginPage(), + builder: (context) => LoginPage(), fullscreenDialog: true, ); } diff --git a/shrine/lib/backdrop.dart b/shrine/lib/backdrop.dart index 0511cd8a3..7f6f1e68d 100644 --- a/shrine/lib/backdrop.dart +++ b/shrine/lib/backdrop.dart @@ -60,7 +60,7 @@ class _FrontLayer extends StatelessWidget { } class _BackdropTitle extends AnimatedWidget { - final Function onPress; + final VoidCallback onPress; final Widget frontTitle; final Widget backTitle; @@ -77,7 +77,7 @@ class _BackdropTitle extends AnimatedWidget { @override Widget build(BuildContext context) { final Animation animation = CurvedAnimation( - parent: this.listenable, + parent: this.listenable as Animation, curve: Interval(0.0, 0.78), ); @@ -212,7 +212,7 @@ class _BackdropState extends State Curve secondCurve; // Curve for second TweenSequenceItem double firstWeight; // Weight of first TweenSequenceItem double secondWeight; // Weight of second TweenSequenceItem - Animation animation; // Animation on which TweenSequence runs + Animation animation; // Animation on which TweenSequence runs if (_frontLayerVisible) { firstCurve = _kAccelerateCurve; @@ -305,18 +305,18 @@ class _BackdropState extends State IconButton( icon: const Icon(Icons.search, semanticLabel: 'login'), onPressed: () { - Navigator.push( + Navigator.push( context, - MaterialPageRoute(builder: (BuildContext context) => LoginPage()), + MaterialPageRoute(builder: (context) => LoginPage()), ); }, ), IconButton( icon: const Icon(Icons.tune, semanticLabel: 'login'), onPressed: () { - Navigator.push( + Navigator.push( context, - MaterialPageRoute(builder: (BuildContext context) => LoginPage()), + MaterialPageRoute(builder: (context) => LoginPage()), ); }, ), diff --git a/shrine/lib/category_menu_page.dart b/shrine/lib/category_menu_page.dart index 00de4aaa7..b531f2833 100644 --- a/shrine/lib/category_menu_page.dart +++ b/shrine/lib/category_menu_page.dart @@ -75,9 +75,8 @@ class CategoryMenuPage extends StatelessWidget { padding: EdgeInsets.only(top: 40.0), color: kShrinePink100, child: ListView( - children: _categories - .map((Category c) => _buildCategory(c, context)) - .toList()), + children: _categories.map((c) => _buildCategory(c, context)).toList(), + ), ), ); } diff --git a/shrine/lib/expanding_bottom_sheet.dart b/shrine/lib/expanding_bottom_sheet.dart index 43849481f..ed656db04 100644 --- a/shrine/lib/expanding_bottom_sheet.dart +++ b/shrine/lib/expanding_bottom_sheet.dart @@ -51,8 +51,9 @@ class ExpandingBottomSheet extends StatefulWidget { {bool isNullOk = false}) { assert(isNullOk != null); assert(context != null); - final _ExpandingBottomSheetState result = context - .ancestorStateOfType(const TypeMatcher<_ExpandingBottomSheetState>()); + final _ExpandingBottomSheetState result = context.ancestorStateOfType( + const TypeMatcher<_ExpandingBottomSheetState>()) + as _ExpandingBottomSheetState; if (isNullOk || result != null) { return result; } @@ -71,7 +72,7 @@ Animation _getEmphasizedEasingAnimation( @required T peak, @required T end, @required bool isForward, - @required Animation parent}) { + @required Animation parent}) { Curve firstCurve; Curve secondCurve; double firstWeight; @@ -616,6 +617,9 @@ class ProductThumbnail extends StatelessWidget { } } +typedef RemovedItemBuilder = Widget Function( + int, BuildContext, Animation); + // _ListModel manipulates an internal list and an AnimatedList class _ListModel { _ListModel( @@ -627,7 +631,7 @@ class _ListModel { _items = List.from(initialItems ?? []); final GlobalKey listKey; - final dynamic removedItemBuilder; + final RemovedItemBuilder removedItemBuilder; final List _items; AnimatedListState get _animatedList => listKey.currentState; @@ -651,8 +655,7 @@ class _ListModel { void _removeAt(int index) { final int removedItem = _items.removeAt(index); if (removedItem != null) { - _animatedList.removeItem(index, - (BuildContext context, Animation animation) { + _animatedList.removeItem(index, (context, animation) { return removedItemBuilder(removedItem, context, animation); }); } diff --git a/shrine/lib/home.dart b/shrine/lib/home.dart index c251ba256..b73ca18ab 100644 --- a/shrine/lib/home.dart +++ b/shrine/lib/home.dart @@ -29,7 +29,7 @@ class ProductPage extends StatelessWidget { @override Widget build(BuildContext context) { return ScopedModelDescendant( - builder: (BuildContext context, Widget child, AppStateModel model) { + builder: (context, child, model) { return AsymmetricView( products: model.getProducts(), ); diff --git a/shrine/lib/model/products_repository.dart b/shrine/lib/model/products_repository.dart index d355bac9b..9f4a1cd27 100644 --- a/shrine/lib/model/products_repository.dart +++ b/shrine/lib/model/products_repository.dart @@ -287,7 +287,7 @@ class ProductsRepository { if (category == Category.all) { return allProducts; } else { - return allProducts.where((Product p) => p.category == category).toList(); + return allProducts.where((p) => p.category == category).toList(); } } } diff --git a/shrine/lib/supplemental/asymmetric_view.dart b/shrine/lib/supplemental/asymmetric_view.dart index 15c38fad0..abb46b9f0 100644 --- a/shrine/lib/supplemental/asymmetric_view.dart +++ b/shrine/lib/supplemental/asymmetric_view.dart @@ -35,7 +35,7 @@ class AsymmetricView extends StatelessWidget { /// some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as /// helpers for creating the index of the product list that will correspond /// to the index of the list of columns. - return List.generate(_listItemCount(products.length), (int index) { + return List.generate(_listItemCount(products.length), (index) { double width = .59 * MediaQuery.of(context).size.width; Widget column; if (index % 2 == 0) { diff --git a/shrine/lib/supplemental/product_columns.dart b/shrine/lib/supplemental/product_columns.dart index 15c307afc..12c9a064b 100644 --- a/shrine/lib/supplemental/product_columns.dart +++ b/shrine/lib/supplemental/product_columns.dart @@ -28,40 +28,42 @@ class TwoProductCardColumn extends StatelessWidget { @override Widget build(BuildContext context) { return LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - const spacerHeight = 44.0; + builder: (context, constraints) { + const spacerHeight = 44.0; - double heightOfCards = (constraints.biggest.height - spacerHeight) / 2.0; - double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight; - double imageAspectRatio = - (heightOfImages >= 0.0 && constraints.biggest.width > heightOfImages) - ? constraints.biggest.width / heightOfImages - : 33 / 49; + double heightOfCards = + (constraints.biggest.height - spacerHeight) / 2.0; + double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight; + double imageAspectRatio = (heightOfImages >= 0.0 && + constraints.biggest.width > heightOfImages) + ? constraints.biggest.width / heightOfImages + : 33 / 49; - return ListView( - children: [ - Padding( - padding: EdgeInsetsDirectional.only(start: 28.0), - child: top != null - ? ProductCard( - imageAspectRatio: imageAspectRatio, - product: top, - ) - : SizedBox( - height: heightOfCards > 0 ? heightOfCards : spacerHeight, - ), - ), - SizedBox(height: spacerHeight), - Padding( - padding: EdgeInsetsDirectional.only(end: 28.0), - child: ProductCard( - imageAspectRatio: imageAspectRatio, - product: bottom, + return ListView( + children: [ + Padding( + padding: EdgeInsetsDirectional.only(start: 28.0), + child: top != null + ? ProductCard( + imageAspectRatio: imageAspectRatio, + product: top, + ) + : SizedBox( + height: heightOfCards > 0 ? heightOfCards : spacerHeight, + ), ), - ), - ], - ); - }); + SizedBox(height: spacerHeight), + Padding( + padding: EdgeInsetsDirectional.only(end: 28.0), + child: ProductCard( + imageAspectRatio: imageAspectRatio, + product: bottom, + ), + ), + ], + ); + }, + ); } } diff --git a/shrine/pubspec.lock b/shrine/pubspec.lock index 4cced3260..174c9acbd 100644 --- a/shrine/pubspec.lock +++ b/shrine/pubspec.lock @@ -75,7 +75,7 @@ packages: source: hosted version: "1.6.2" pedantic: - dependency: transitive + dependency: "direct dev" description: name: pedantic url: "https://pub.dartlang.org" @@ -164,4 +164,4 @@ packages: source: hosted version: "2.0.8" sdks: - dart: ">=2.2.0 <3.0.0" + dart: ">=2.3.0-dev <3.0.0" diff --git a/shrine/pubspec.yaml b/shrine/pubspec.yaml index e567354bc..af53f6e98 100644 --- a/shrine/pubspec.yaml +++ b/shrine/pubspec.yaml @@ -1,5 +1,7 @@ name: Shrine description: Take your design up a notch and learn to use our advanced component backdrop menu. +environment: + sdk: ">=2.3.0-dev <3.0.0" dependencies: flutter: @@ -13,6 +15,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + pedantic: ^1.5.0 flutter: uses-material-design: true