mirror of
https://github.com/flutter/samples.git
synced 2025-11-10 23:08:59 +00:00
Analysis options, fixes, and formatting (#110)
This commit is contained in:
30
shrine/analysis_options.yaml
Normal file
30
shrine/analysis_options.yaml
Normal file
@@ -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
|
||||
@@ -72,7 +72,7 @@ Route<dynamic> _getRoute(RouteSettings settings) {
|
||||
|
||||
return MaterialPageRoute<void>(
|
||||
settings: settings,
|
||||
builder: (BuildContext context) => LoginPage(),
|
||||
builder: (context) => LoginPage(),
|
||||
fullscreenDialog: true,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<double> animation = CurvedAnimation(
|
||||
parent: this.listenable,
|
||||
parent: this.listenable as Animation<double>,
|
||||
curve: Interval(0.0, 0.78),
|
||||
);
|
||||
|
||||
@@ -212,7 +212,7 @@ class _BackdropState extends State<Backdrop>
|
||||
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<double> animation; // Animation on which TweenSequence runs
|
||||
|
||||
if (_frontLayerVisible) {
|
||||
firstCurve = _kAccelerateCurve;
|
||||
@@ -305,18 +305,18 @@ class _BackdropState extends State<Backdrop>
|
||||
IconButton(
|
||||
icon: const Icon(Icons.search, semanticLabel: 'login'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
|
||||
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||
);
|
||||
},
|
||||
),
|
||||
IconButton(
|
||||
icon: const Icon(Icons.tune, semanticLabel: 'login'),
|
||||
onPressed: () {
|
||||
Navigator.push(
|
||||
Navigator.push<void>(
|
||||
context,
|
||||
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
|
||||
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
||||
@@ -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(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<T> _getEmphasizedEasingAnimation<T>(
|
||||
@required T peak,
|
||||
@required T end,
|
||||
@required bool isForward,
|
||||
@required Animation parent}) {
|
||||
@required Animation<double> parent}) {
|
||||
Curve firstCurve;
|
||||
Curve secondCurve;
|
||||
double firstWeight;
|
||||
@@ -616,6 +617,9 @@ class ProductThumbnail extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
typedef RemovedItemBuilder = Widget Function(
|
||||
int, BuildContext, Animation<double>);
|
||||
|
||||
// _ListModel manipulates an internal list and an AnimatedList
|
||||
class _ListModel {
|
||||
_ListModel(
|
||||
@@ -627,7 +631,7 @@ class _ListModel {
|
||||
_items = List<int>.from(initialItems ?? <int>[]);
|
||||
|
||||
final GlobalKey<AnimatedListState> listKey;
|
||||
final dynamic removedItemBuilder;
|
||||
final RemovedItemBuilder removedItemBuilder;
|
||||
final List<int> _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<double> animation) {
|
||||
_animatedList.removeItem(index, (context, animation) {
|
||||
return removedItemBuilder(removedItem, context, animation);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class ProductPage extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScopedModelDescendant<AppStateModel>(
|
||||
builder: (BuildContext context, Widget child, AppStateModel model) {
|
||||
builder: (context, child, model) {
|
||||
return AsymmetricView(
|
||||
products: model.getProducts(),
|
||||
);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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: <Widget>[
|
||||
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: <Widget>[
|
||||
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,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user