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>(
|
return MaterialPageRoute<void>(
|
||||||
settings: settings,
|
settings: settings,
|
||||||
builder: (BuildContext context) => LoginPage(),
|
builder: (context) => LoginPage(),
|
||||||
fullscreenDialog: true,
|
fullscreenDialog: true,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class _FrontLayer extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _BackdropTitle extends AnimatedWidget {
|
class _BackdropTitle extends AnimatedWidget {
|
||||||
final Function onPress;
|
final VoidCallback onPress;
|
||||||
final Widget frontTitle;
|
final Widget frontTitle;
|
||||||
final Widget backTitle;
|
final Widget backTitle;
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ class _BackdropTitle extends AnimatedWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final Animation<double> animation = CurvedAnimation(
|
final Animation<double> animation = CurvedAnimation(
|
||||||
parent: this.listenable,
|
parent: this.listenable as Animation<double>,
|
||||||
curve: Interval(0.0, 0.78),
|
curve: Interval(0.0, 0.78),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -212,7 +212,7 @@ class _BackdropState extends State<Backdrop>
|
|||||||
Curve secondCurve; // Curve for second TweenSequenceItem
|
Curve secondCurve; // Curve for second TweenSequenceItem
|
||||||
double firstWeight; // Weight of first TweenSequenceItem
|
double firstWeight; // Weight of first TweenSequenceItem
|
||||||
double secondWeight; // Weight of second TweenSequenceItem
|
double secondWeight; // Weight of second TweenSequenceItem
|
||||||
Animation animation; // Animation on which TweenSequence runs
|
Animation<double> animation; // Animation on which TweenSequence runs
|
||||||
|
|
||||||
if (_frontLayerVisible) {
|
if (_frontLayerVisible) {
|
||||||
firstCurve = _kAccelerateCurve;
|
firstCurve = _kAccelerateCurve;
|
||||||
@@ -305,18 +305,18 @@ class _BackdropState extends State<Backdrop>
|
|||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.search, semanticLabel: 'login'),
|
icon: const Icon(Icons.search, semanticLabel: 'login'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push<void>(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
|
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: const Icon(Icons.tune, semanticLabel: 'login'),
|
icon: const Icon(Icons.tune, semanticLabel: 'login'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
Navigator.push(
|
Navigator.push<void>(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (BuildContext context) => LoginPage()),
|
MaterialPageRoute(builder: (context) => LoginPage()),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -75,9 +75,8 @@ class CategoryMenuPage extends StatelessWidget {
|
|||||||
padding: EdgeInsets.only(top: 40.0),
|
padding: EdgeInsets.only(top: 40.0),
|
||||||
color: kShrinePink100,
|
color: kShrinePink100,
|
||||||
child: ListView(
|
child: ListView(
|
||||||
children: _categories
|
children: _categories.map((c) => _buildCategory(c, context)).toList(),
|
||||||
.map((Category c) => _buildCategory(c, context))
|
),
|
||||||
.toList()),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,8 +51,9 @@ class ExpandingBottomSheet extends StatefulWidget {
|
|||||||
{bool isNullOk = false}) {
|
{bool isNullOk = false}) {
|
||||||
assert(isNullOk != null);
|
assert(isNullOk != null);
|
||||||
assert(context != null);
|
assert(context != null);
|
||||||
final _ExpandingBottomSheetState result = context
|
final _ExpandingBottomSheetState result = context.ancestorStateOfType(
|
||||||
.ancestorStateOfType(const TypeMatcher<_ExpandingBottomSheetState>());
|
const TypeMatcher<_ExpandingBottomSheetState>())
|
||||||
|
as _ExpandingBottomSheetState;
|
||||||
if (isNullOk || result != null) {
|
if (isNullOk || result != null) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,7 @@ Animation<T> _getEmphasizedEasingAnimation<T>(
|
|||||||
@required T peak,
|
@required T peak,
|
||||||
@required T end,
|
@required T end,
|
||||||
@required bool isForward,
|
@required bool isForward,
|
||||||
@required Animation parent}) {
|
@required Animation<double> parent}) {
|
||||||
Curve firstCurve;
|
Curve firstCurve;
|
||||||
Curve secondCurve;
|
Curve secondCurve;
|
||||||
double firstWeight;
|
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
|
// _ListModel manipulates an internal list and an AnimatedList
|
||||||
class _ListModel {
|
class _ListModel {
|
||||||
_ListModel(
|
_ListModel(
|
||||||
@@ -627,7 +631,7 @@ class _ListModel {
|
|||||||
_items = List<int>.from(initialItems ?? <int>[]);
|
_items = List<int>.from(initialItems ?? <int>[]);
|
||||||
|
|
||||||
final GlobalKey<AnimatedListState> listKey;
|
final GlobalKey<AnimatedListState> listKey;
|
||||||
final dynamic removedItemBuilder;
|
final RemovedItemBuilder removedItemBuilder;
|
||||||
final List<int> _items;
|
final List<int> _items;
|
||||||
|
|
||||||
AnimatedListState get _animatedList => listKey.currentState;
|
AnimatedListState get _animatedList => listKey.currentState;
|
||||||
@@ -651,8 +655,7 @@ class _ListModel {
|
|||||||
void _removeAt(int index) {
|
void _removeAt(int index) {
|
||||||
final int removedItem = _items.removeAt(index);
|
final int removedItem = _items.removeAt(index);
|
||||||
if (removedItem != null) {
|
if (removedItem != null) {
|
||||||
_animatedList.removeItem(index,
|
_animatedList.removeItem(index, (context, animation) {
|
||||||
(BuildContext context, Animation<double> animation) {
|
|
||||||
return removedItemBuilder(removedItem, context, animation);
|
return removedItemBuilder(removedItem, context, animation);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class ProductPage extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return ScopedModelDescendant<AppStateModel>(
|
return ScopedModelDescendant<AppStateModel>(
|
||||||
builder: (BuildContext context, Widget child, AppStateModel model) {
|
builder: (context, child, model) {
|
||||||
return AsymmetricView(
|
return AsymmetricView(
|
||||||
products: model.getProducts(),
|
products: model.getProducts(),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ class ProductsRepository {
|
|||||||
if (category == Category.all) {
|
if (category == Category.all) {
|
||||||
return allProducts;
|
return allProducts;
|
||||||
} else {
|
} 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
|
/// some kinda awkward math so we use _evenCasesIndex and _oddCasesIndex as
|
||||||
/// helpers for creating the index of the product list that will correspond
|
/// helpers for creating the index of the product list that will correspond
|
||||||
/// to the index of the list of columns.
|
/// 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;
|
double width = .59 * MediaQuery.of(context).size.width;
|
||||||
Widget column;
|
Widget column;
|
||||||
if (index % 2 == 0) {
|
if (index % 2 == 0) {
|
||||||
|
|||||||
@@ -28,13 +28,14 @@ class TwoProductCardColumn extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return LayoutBuilder(
|
return LayoutBuilder(
|
||||||
builder: (BuildContext context, BoxConstraints constraints) {
|
builder: (context, constraints) {
|
||||||
const spacerHeight = 44.0;
|
const spacerHeight = 44.0;
|
||||||
|
|
||||||
double heightOfCards = (constraints.biggest.height - spacerHeight) / 2.0;
|
double heightOfCards =
|
||||||
|
(constraints.biggest.height - spacerHeight) / 2.0;
|
||||||
double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight;
|
double heightOfImages = heightOfCards - ProductCard.kTextBoxHeight;
|
||||||
double imageAspectRatio =
|
double imageAspectRatio = (heightOfImages >= 0.0 &&
|
||||||
(heightOfImages >= 0.0 && constraints.biggest.width > heightOfImages)
|
constraints.biggest.width > heightOfImages)
|
||||||
? constraints.biggest.width / heightOfImages
|
? constraints.biggest.width / heightOfImages
|
||||||
: 33 / 49;
|
: 33 / 49;
|
||||||
|
|
||||||
@@ -61,7 +62,8 @@ class TwoProductCardColumn extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "1.6.2"
|
version: "1.6.2"
|
||||||
pedantic:
|
pedantic:
|
||||||
dependency: transitive
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: pedantic
|
name: pedantic
|
||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
@@ -164,4 +164,4 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "2.0.8"
|
version: "2.0.8"
|
||||||
sdks:
|
sdks:
|
||||||
dart: ">=2.2.0 <3.0.0"
|
dart: ">=2.3.0-dev <3.0.0"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
name: Shrine
|
name: Shrine
|
||||||
description: Take your design up a notch and learn to use our advanced component backdrop menu.
|
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:
|
dependencies:
|
||||||
flutter:
|
flutter:
|
||||||
@@ -13,6 +15,7 @@ dependencies:
|
|||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
pedantic: ^1.5.0
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
|||||||
Reference in New Issue
Block a user