mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Analysis options, fixes and format (#107)
This commit is contained in:
30
platform_design/analysis_options.yaml
Normal file
30
platform_design/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
|
||||||
@@ -62,7 +62,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
|||||||
// In Material, this app uses the hamburger menu paradigm and flatly lists
|
// In Material, this app uses the hamburger menu paradigm and flatly lists
|
||||||
// all 4 possible tabs. This drawer is injected into the songs tab which is
|
// all 4 possible tabs. This drawer is injected into the songs tab which is
|
||||||
// actually building the scaffold around the drawer.
|
// actually building the scaffold around the drawer.
|
||||||
Widget _buildAndroidHomePage(context) {
|
Widget _buildAndroidHomePage(BuildContext context) {
|
||||||
return SongsTab(
|
return SongsTab(
|
||||||
key: songsTabKey,
|
key: songsTabKey,
|
||||||
androidDrawer: _AndroidDrawer(),
|
androidDrawer: _AndroidDrawer(),
|
||||||
@@ -77,7 +77,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
|||||||
// large number of items, a tab bar cannot. To illustrate one way of adjusting
|
// large number of items, a tab bar cannot. To illustrate one way of adjusting
|
||||||
// for this, the app folds its fourth tab (the settings page) into the
|
// for this, the app folds its fourth tab (the settings page) into the
|
||||||
// third tab. This is a common pattern on iOS.
|
// third tab. This is a common pattern on iOS.
|
||||||
Widget _buildIosHomePage(context) {
|
Widget _buildIosHomePage(BuildContext context) {
|
||||||
return CupertinoTabScaffold(
|
return CupertinoTabScaffold(
|
||||||
tabBar: CupertinoTabBar(
|
tabBar: CupertinoTabBar(
|
||||||
items: [
|
items: [
|
||||||
@@ -153,7 +153,7 @@ class _AndroidDrawer extends StatelessWidget {
|
|||||||
title: Text(NewsTab.title),
|
title: Text(NewsTab.title),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.push(
|
Navigator.push<void>(
|
||||||
context, MaterialPageRoute(builder: (context) => NewsTab()));
|
context, MaterialPageRoute(builder: (context) => NewsTab()));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -162,7 +162,7 @@ class _AndroidDrawer extends StatelessWidget {
|
|||||||
title: Text(ProfileTab.title),
|
title: Text(ProfileTab.title),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.push(context,
|
Navigator.push<void>(context,
|
||||||
MaterialPageRoute(builder: (context) => ProfileTab()));
|
MaterialPageRoute(builder: (context) => ProfileTab()));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
@@ -176,7 +176,7 @@ class _AndroidDrawer extends StatelessWidget {
|
|||||||
title: Text(SettingsTab.title),
|
title: Text(SettingsTab.title),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
Navigator.push(context,
|
Navigator.push<void>(context,
|
||||||
MaterialPageRoute(builder: (context) => SettingsTab()));
|
MaterialPageRoute(builder: (context) => SettingsTab()));
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class _NewsTabState extends State<NewsTab> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _listBuilder(context, index) {
|
Widget _listBuilder(BuildContext context, int index) {
|
||||||
if (index >= _itemsLength) return null;
|
if (index >= _itemsLength) return null;
|
||||||
|
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
@@ -90,7 +90,7 @@ class _NewsTabState extends State<NewsTab> {
|
|||||||
// Non-shared code below because this tab uses different scaffolds.
|
// Non-shared code below because this tab uses different scaffolds.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(NewsTab.title),
|
title: Text(NewsTab.title),
|
||||||
@@ -104,7 +104,7 @@ class _NewsTabState extends State<NewsTab> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(),
|
navigationBar: CupertinoNavigationBar(),
|
||||||
child: Container(
|
child: Container(
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class ProfileTab extends StatelessWidget {
|
|||||||
static const androidIcon = Icon(Icons.person);
|
static const androidIcon = Icon(Icons.person);
|
||||||
static const iosIcon = Icon(CupertinoIcons.profile_circled);
|
static const iosIcon = Icon(CupertinoIcons.profile_circled);
|
||||||
|
|
||||||
Widget _buildBody(context) {
|
Widget _buildBody(BuildContext context) {
|
||||||
return SafeArea(
|
return SafeArea(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(24.0),
|
padding: const EdgeInsets.all(24.0),
|
||||||
@@ -63,7 +63,7 @@ class ProfileTab extends StatelessWidget {
|
|||||||
// the profile tab as a button in the nav bar.
|
// the profile tab as a button in the nav bar.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(title),
|
title: Text(title),
|
||||||
@@ -72,7 +72,7 @@ class ProfileTab extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
trailing: CupertinoButton(
|
trailing: CupertinoButton(
|
||||||
@@ -81,7 +81,7 @@ class ProfileTab extends StatelessWidget {
|
|||||||
onPressed: () {
|
onPressed: () {
|
||||||
// This pushes the settings page as a full page modal dialog on top
|
// This pushes the settings page as a full page modal dialog on top
|
||||||
// of the tab bar and everything.
|
// of the tab bar and everything.
|
||||||
Navigator.of(context, rootNavigator: true).push(
|
Navigator.of(context, rootNavigator: true).push<void>(
|
||||||
CupertinoPageRoute(
|
CupertinoPageRoute(
|
||||||
title: SettingsTab.title,
|
title: SettingsTab.title,
|
||||||
fullscreenDialog: true,
|
fullscreenDialog: true,
|
||||||
@@ -172,13 +172,13 @@ class LogOutButton extends StatelessWidget {
|
|||||||
// app.
|
// app.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return RaisedButton(
|
return RaisedButton(
|
||||||
child: Text('LOG OUT', style: TextStyle(color: Colors.red)),
|
child: Text('LOG OUT', style: TextStyle(color: Colors.red)),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// You should do something with the result of the dialog prompt in a
|
// You should do something with the result of the dialog prompt in a
|
||||||
// real app but this is just a demo.
|
// real app but this is just a demo.
|
||||||
showDialog(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return AlertDialog(
|
return AlertDialog(
|
||||||
@@ -201,14 +201,14 @@ class LogOutButton extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CupertinoButton(
|
return CupertinoButton(
|
||||||
color: CupertinoColors.destructiveRed,
|
color: CupertinoColors.destructiveRed,
|
||||||
child: Text('Log out'),
|
child: Text('Log out'),
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
// You should do something with the result of the action sheet prompt
|
// You should do something with the result of the action sheet prompt
|
||||||
// in a real app but this is just a demo.
|
// in a real app but this is just a demo.
|
||||||
showCupertinoModalPopup(
|
showCupertinoModalPopup<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return CupertinoActionSheet(
|
return CupertinoActionSheet(
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
|||||||
// Non-shared code below because this tab uses different scaffolds.
|
// Non-shared code below because this tab uses different scaffolds.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(SettingsTab.title),
|
title: Text(SettingsTab.title),
|
||||||
@@ -92,7 +92,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(),
|
navigationBar: CupertinoNavigationBar(),
|
||||||
child: _buildList(),
|
child: _buildList(),
|
||||||
|
|||||||
@@ -77,14 +77,14 @@ class SongDetailTab extends StatelessWidget {
|
|||||||
// Non-shared code below because we're using different scaffolds.
|
// Non-shared code below because we're using different scaffolds.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
|
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text(song)),
|
appBar: AppBar(title: Text(song)),
|
||||||
body: _buildBody(),
|
body: _buildBody(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CupertinoPageScaffold(
|
return CupertinoPageScaffold(
|
||||||
navigationBar: CupertinoNavigationBar(
|
navigationBar: CupertinoNavigationBar(
|
||||||
middle: Text(song),
|
middle: Text(song),
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class _SongsTabState extends State<SongsTab> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _listBuilder(context, index) {
|
Widget _listBuilder(BuildContext context, int index) {
|
||||||
if (index >= _itemsLength) return null;
|
if (index >= _itemsLength) return null;
|
||||||
|
|
||||||
// Show a slightly different color palette. Show poppy-ier colors on iOS
|
// Show a slightly different color palette. Show poppy-ier colors on iOS
|
||||||
@@ -64,7 +64,7 @@ class _SongsTabState extends State<SongsTab> {
|
|||||||
song: songNames[index],
|
song: songNames[index],
|
||||||
color: color,
|
color: color,
|
||||||
heroAnimation: AlwaysStoppedAnimation(0),
|
heroAnimation: AlwaysStoppedAnimation(0),
|
||||||
onPressed: () => Navigator.of(context).push(
|
onPressed: () => Navigator.of(context).push<void>(
|
||||||
MaterialPageRoute(
|
MaterialPageRoute(
|
||||||
builder: (context) => SongDetailTab(
|
builder: (context) => SongDetailTab(
|
||||||
id: index,
|
id: index,
|
||||||
@@ -106,7 +106,7 @@ class _SongsTabState extends State<SongsTab> {
|
|||||||
// And these are all design time choices that doesn't have a single 'right'
|
// And these are all design time choices that doesn't have a single 'right'
|
||||||
// answer.
|
// answer.
|
||||||
// ===========================================================================
|
// ===========================================================================
|
||||||
Widget _buildAndroid(context) {
|
Widget _buildAndroid(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(SongsTab.title),
|
title: Text(SongsTab.title),
|
||||||
@@ -133,7 +133,7 @@ class _SongsTabState extends State<SongsTab> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildIos(context) {
|
Widget _buildIos(BuildContext context) {
|
||||||
return CustomScrollView(
|
return CustomScrollView(
|
||||||
slivers: [
|
slivers: [
|
||||||
CupertinoSliverNavigationBar(
|
CupertinoSliverNavigationBar(
|
||||||
|
|||||||
@@ -26,9 +26,9 @@ const _myListOfRandomColors = [
|
|||||||
|
|
||||||
final _random = Random();
|
final _random = Random();
|
||||||
|
|
||||||
Iterable wordPairIterator = generateWordPair();
|
final wordPairIterator = generateWordPair();
|
||||||
Iterable<WordPair> generateWordPair() sync* {
|
Iterable<WordPair> generateWordPair() sync* {
|
||||||
bool filterWord(word) => unsafe.contains(word);
|
bool filterWord(String word) => unsafe.contains(word);
|
||||||
String pickRandom(List<String> list) => list[_random.nextInt(list.length)];
|
String pickRandom(List<String> list) => list[_random.nextInt(list.length)];
|
||||||
|
|
||||||
String prefix;
|
String prefix;
|
||||||
@@ -50,7 +50,7 @@ Iterable<WordPair> generateWordPair() sync* {
|
|||||||
String generateRandomHeadline() {
|
String generateRandomHeadline() {
|
||||||
final artist = capitalizePair(wordPairIterator.first);
|
final artist = capitalizePair(wordPairIterator.first);
|
||||||
|
|
||||||
switch (_random.nextInt(9)) {
|
switch (_random.nextInt(10)) {
|
||||||
case 0:
|
case 0:
|
||||||
return '$artist says ${nouns[_random.nextInt(nouns.length)]}';
|
return '$artist says ${nouns[_random.nextInt(nouns.length)]}';
|
||||||
case 1:
|
case 1:
|
||||||
@@ -67,9 +67,9 @@ String generateRandomHeadline() {
|
|||||||
return '$artist says their music is inspired by ${wordPairIterator.first.join(' ')}';
|
return '$artist says their music is inspired by ${wordPairIterator.first.join(' ')}';
|
||||||
case 7:
|
case 7:
|
||||||
return '$artist says the world needs more ${nouns[_random.nextInt(nouns.length)]}';
|
return '$artist says the world needs more ${nouns[_random.nextInt(nouns.length)]}';
|
||||||
case 7:
|
|
||||||
return '$artist calls their band ${adjectives[_random.nextInt(adjectives.length)]}';
|
|
||||||
case 8:
|
case 8:
|
||||||
|
return '$artist calls their band ${adjectives[_random.nextInt(adjectives.length)]}';
|
||||||
|
case 9:
|
||||||
return '$artist finally ready to talk about ${nouns[_random.nextInt(nouns.length)]}';
|
return '$artist finally ready to talk about ${nouns[_random.nextInt(nouns.length)]}';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +78,7 @@ String generateRandomHeadline() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<MaterialColor> getRandomColors(int amount) {
|
List<MaterialColor> getRandomColors(int amount) {
|
||||||
return List<MaterialColor>.generate(amount, (int index) {
|
return List<MaterialColor>.generate(amount, (index) {
|
||||||
return _myListOfRandomColors[_random.nextInt(_myListOfRandomColors.length)];
|
return _myListOfRandomColors[_random.nextInt(_myListOfRandomColors.length)];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class PressableCard extends StatefulWidget {
|
|||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() => new _PressableCardState();
|
State<StatefulWidget> createState() => _PressableCardState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _PressableCardState extends State<PressableCard>
|
class _PressableCardState extends State<PressableCard>
|
||||||
@@ -280,7 +280,7 @@ class SongPlaceholderTile extends StatelessWidget {
|
|||||||
void showChoices(BuildContext context, List<String> choices) {
|
void showChoices(BuildContext context, List<String> choices) {
|
||||||
switch (defaultTargetPlatform) {
|
switch (defaultTargetPlatform) {
|
||||||
case TargetPlatform.android:
|
case TargetPlatform.android:
|
||||||
showDialog(
|
showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
int selectedRadio = 1;
|
int selectedRadio = 1;
|
||||||
@@ -295,7 +295,8 @@ void showChoices(BuildContext context, List<String> choices) {
|
|||||||
title: Text(choices[index]),
|
title: Text(choices[index]),
|
||||||
value: index,
|
value: index,
|
||||||
groupValue: selectedRadio,
|
groupValue: selectedRadio,
|
||||||
onChanged: (value) {
|
// ignore: avoid_types_on_closure_parameters
|
||||||
|
onChanged: (int value) {
|
||||||
setState(() => selectedRadio = value);
|
setState(() => selectedRadio = value);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -318,7 +319,7 @@ void showChoices(BuildContext context, List<String> choices) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
case TargetPlatform.iOS:
|
case TargetPlatform.iOS:
|
||||||
showCupertinoModalPopup(
|
showCupertinoModalPopup<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return SizedBox(
|
return SizedBox(
|
||||||
|
|||||||
@@ -82,7 +82,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"
|
||||||
@@ -157,5 +157,5 @@ 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"
|
||||||
flutter: ">=1.5.2"
|
flutter: ">=1.5.2"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ description: A project showcasing a Flutter app following different platform IA
|
|||||||
version: 1.0.0+1
|
version: 1.0.0+1
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.1.0 <3.0.0"
|
sdk: ">=2.3.0-dev <3.0.0"
|
||||||
flutter: ">=1.5.2"
|
flutter: ">=1.5.2"
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -17,6 +17,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