mirror of
https://github.com/flutter/samples.git
synced 2026-03-22 04:17:50 +00:00
Samples maintenance (#435)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
include: package:pedantic/analysis_options.1.8.0.yaml
|
||||
include: package:pedantic/analysis_options.1.9.0.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
|
||||
@@ -7,7 +7,7 @@ import 'package:veggieseasons/data/veggie.dart';
|
||||
import 'package:veggieseasons/data/local_veggie_provider.dart';
|
||||
|
||||
class AppState extends Model {
|
||||
List<Veggie> _veggies;
|
||||
final List<Veggie> _veggies;
|
||||
|
||||
AppState() : _veggies = LocalVeggieProvider.veggies;
|
||||
|
||||
@@ -16,12 +16,12 @@ class AppState extends Model {
|
||||
Veggie getVeggie(int id) => _veggies.singleWhere((v) => v.id == id);
|
||||
|
||||
List<Veggie> get availableVeggies {
|
||||
Season currentSeason = _getSeasonForDate(DateTime.now());
|
||||
var currentSeason = _getSeasonForDate(DateTime.now());
|
||||
return _veggies.where((v) => v.seasons.contains(currentSeason)).toList();
|
||||
}
|
||||
|
||||
List<Veggie> get unavailableVeggies {
|
||||
Season currentSeason = _getSeasonForDate(DateTime.now());
|
||||
var currentSeason = _getSeasonForDate(DateTime.now());
|
||||
return _veggies.where((v) => !v.seasons.contains(currentSeason)).toList();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ class AppState extends Model {
|
||||
.toList();
|
||||
|
||||
void setFavorite(int id, bool isFavorite) {
|
||||
Veggie veggie = getVeggie(id);
|
||||
var veggie = getVeggie(id);
|
||||
veggie.isFavorite = isFavorite;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class Preferences extends Model {
|
||||
|
||||
int _desiredCalories = 2000;
|
||||
|
||||
Set<VeggieCategory> _preferredCategories = Set<VeggieCategory>();
|
||||
final Set<VeggieCategory> _preferredCategories = <VeggieCategory>{};
|
||||
|
||||
Future<int> get desiredCalories async {
|
||||
await _loading;
|
||||
|
||||
@@ -28,7 +28,7 @@ class ServingInfoChart extends StatelessWidget {
|
||||
builder: (context, snapshot) {
|
||||
final target = snapshot?.data ?? 2000;
|
||||
final percent = standardPercentage * 2000 ~/ target;
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
|
||||
return Text(
|
||||
'$percent% DV',
|
||||
@@ -41,7 +41,7 @@ class ServingInfoChart extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
return Column(
|
||||
children: [
|
||||
SizedBox(height: 16),
|
||||
@@ -141,8 +141,8 @@ class ServingInfoChart extends StatelessWidget {
|
||||
future: prefs.desiredCalories,
|
||||
builder: (context, snapshot) {
|
||||
return Text(
|
||||
'Percent daily values based on a diet of ' +
|
||||
'${snapshot?.data ?? '2,000'} calories.',
|
||||
'Percent daily values based on a diet of '
|
||||
'${snapshot?.data ?? '2,000'} calories.',
|
||||
style: Styles.detailsServingNoteText(themeData),
|
||||
);
|
||||
},
|
||||
@@ -161,11 +161,12 @@ class InfoView extends StatelessWidget {
|
||||
|
||||
const InfoView(this.id);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final appState = ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||
final prefs = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||
final veggie = appState.getVeggie(id);
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(24),
|
||||
|
||||
@@ -20,7 +20,7 @@ class ListScreen extends StatelessWidget {
|
||||
child: FutureBuilder<Set<VeggieCategory>>(
|
||||
future: prefs.preferredCategories,
|
||||
builder: (context, snapshot) {
|
||||
final data = snapshot.data ?? Set<VeggieCategory>();
|
||||
final data = snapshot.data ?? <VeggieCategory>{};
|
||||
return VeggieCard(veggie, inSeason, data.contains(veggie.category));
|
||||
}),
|
||||
);
|
||||
@@ -30,13 +30,13 @@ class ListScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return CupertinoTabView(
|
||||
builder: (context) {
|
||||
String dateString = DateFormat("MMMM y").format(DateTime.now());
|
||||
var dateString = DateFormat('MMMM y').format(DateTime.now());
|
||||
|
||||
final appState =
|
||||
ScopedModel.of<AppState>(context, rebuildOnChange: true);
|
||||
final prefs =
|
||||
ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
return SafeArea(
|
||||
bottom: false,
|
||||
child: ListView.builder(
|
||||
@@ -66,7 +66,7 @@ class ListScreen extends StatelessWidget {
|
||||
style: Styles.headlineText(themeData)),
|
||||
);
|
||||
} else {
|
||||
int relativeIndex =
|
||||
var relativeIndex =
|
||||
index - (appState.availableVeggies.length + 2);
|
||||
return _generateVeggieRow(
|
||||
appState.unavailableVeggies[relativeIndex], prefs,
|
||||
|
||||
@@ -17,7 +17,7 @@ class VeggieCategorySettingsScreen extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||
final currentPrefs = model.preferredCategories;
|
||||
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||
var brightness = CupertinoTheme.brightnessOf(context);
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
middle: Text('Preferred Categories'),
|
||||
@@ -80,7 +80,7 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final model = ScopedModel.of<Preferences>(context, rebuildOnChange: true);
|
||||
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||
var brightness = CupertinoTheme.brightnessOf(context);
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
previousPageTitle: 'Settings',
|
||||
@@ -93,7 +93,7 @@ class CalorieSettingsScreen extends StatelessWidget {
|
||||
builder: (context, snapshot) {
|
||||
final steps = <SettingsItem>[];
|
||||
|
||||
for (int cals = max; cals < min; cals += step) {
|
||||
for (var cals = max; cals < min; cals += step) {
|
||||
steps.add(
|
||||
SettingsItem(
|
||||
label: cals.toString(),
|
||||
|
||||
@@ -17,7 +17,7 @@ class SearchBar extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
|
||||
return DecoratedBox(
|
||||
decoration: BoxDecoration(
|
||||
|
||||
@@ -76,9 +76,9 @@ class SettingsGroup extends StatelessWidget {
|
||||
final Widget footer;
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||
var brightness = CupertinoTheme.brightnessOf(context);
|
||||
final dividedItems = <Widget>[items[0]];
|
||||
for (int i = 1; i < items.length; i++) {
|
||||
for (var i = 1; i < items.length; i++) {
|
||||
dividedItems.add(Container(
|
||||
color: Styles.settingsLineation(brightness),
|
||||
height: 0.3,
|
||||
|
||||
@@ -85,8 +85,8 @@ class SettingsItemState extends State<SettingsItem> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
Brightness brightness = CupertinoTheme.brightnessOf(context);
|
||||
var themeData = CupertinoTheme.of(context);
|
||||
var brightness = CupertinoTheme.brightnessOf(context);
|
||||
return AnimatedContainer(
|
||||
duration: const Duration(milliseconds: 200),
|
||||
color: Styles.settingsItemColor(brightness),
|
||||
|
||||
@@ -106,7 +106,7 @@ class _TriviaViewState extends State<TriviaView> {
|
||||
// Widget shown when the game is over. It includes the score and a button to
|
||||
// restart everything.
|
||||
Widget _buildFinishedView() {
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(32),
|
||||
|
||||
@@ -46,9 +46,9 @@ class VeggieHeadline extends StatelessWidget {
|
||||
const VeggieHeadline(this.veggie);
|
||||
|
||||
List<Widget> _buildSeasonDots(List<Season> seasons) {
|
||||
List<Widget> widgets = <Widget>[];
|
||||
var widgets = <Widget>[];
|
||||
|
||||
for (Season season in seasons) {
|
||||
for (var season in seasons) {
|
||||
widgets.add(SizedBox(width: 4));
|
||||
widgets.add(
|
||||
Container(
|
||||
@@ -67,7 +67,7 @@ class VeggieHeadline extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||
final themeData = CupertinoTheme.of(context);
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => Navigator.of(context).push<void>(CupertinoPageRoute(
|
||||
|
||||
@@ -36,13 +36,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -71,13 +64,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
@@ -141,7 +127,7 @@ packages:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.6.4"
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
@@ -155,7 +141,14 @@ packages:
|
||||
name: petitparser
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
version: "2.4.0"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.3"
|
||||
scoped_model:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -258,7 +251,7 @@ packages:
|
||||
name: xml
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "3.7.0"
|
||||
version: "3.6.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -267,5 +260,5 @@ packages:
|
||||
source: hosted
|
||||
version: "2.2.1"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
dart: ">=2.6.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||
|
||||
@@ -19,7 +19,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.8.0+1
|
||||
pedantic: ^1.9.0
|
||||
flutter_launcher_icons: ^0.7.5
|
||||
|
||||
flutter:
|
||||
|
||||
Reference in New Issue
Block a user