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
|
||||
// all 4 possible tabs. This drawer is injected into the songs tab which is
|
||||
// actually building the scaffold around the drawer.
|
||||
Widget _buildAndroidHomePage(context) {
|
||||
Widget _buildAndroidHomePage(BuildContext context) {
|
||||
return SongsTab(
|
||||
key: songsTabKey,
|
||||
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
|
||||
// for this, the app folds its fourth tab (the settings page) into the
|
||||
// third tab. This is a common pattern on iOS.
|
||||
Widget _buildIosHomePage(context) {
|
||||
Widget _buildIosHomePage(BuildContext context) {
|
||||
return CupertinoTabScaffold(
|
||||
tabBar: CupertinoTabBar(
|
||||
items: [
|
||||
@@ -153,7 +153,7 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
title: Text(NewsTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(
|
||||
Navigator.push<void>(
|
||||
context, MaterialPageRoute(builder: (context) => NewsTab()));
|
||||
},
|
||||
),
|
||||
@@ -162,7 +162,7 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
title: Text(ProfileTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context,
|
||||
Navigator.push<void>(context,
|
||||
MaterialPageRoute(builder: (context) => ProfileTab()));
|
||||
},
|
||||
),
|
||||
@@ -176,7 +176,7 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
title: Text(SettingsTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push(context,
|
||||
Navigator.push<void>(context,
|
||||
MaterialPageRoute(builder: (context) => SettingsTab()));
|
||||
},
|
||||
),
|
||||
|
||||
@@ -31,7 +31,7 @@ class _NewsTabState extends State<NewsTab> {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
Widget _listBuilder(context, index) {
|
||||
Widget _listBuilder(BuildContext context, int index) {
|
||||
if (index >= _itemsLength) return null;
|
||||
|
||||
return SafeArea(
|
||||
@@ -90,7 +90,7 @@ class _NewsTabState extends State<NewsTab> {
|
||||
// Non-shared code below because this tab uses different scaffolds.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(NewsTab.title),
|
||||
@@ -104,7 +104,7 @@ class _NewsTabState extends State<NewsTab> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(),
|
||||
child: Container(
|
||||
|
||||
@@ -9,7 +9,7 @@ class ProfileTab extends StatelessWidget {
|
||||
static const androidIcon = Icon(Icons.person);
|
||||
static const iosIcon = Icon(CupertinoIcons.profile_circled);
|
||||
|
||||
Widget _buildBody(context) {
|
||||
Widget _buildBody(BuildContext context) {
|
||||
return SafeArea(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
@@ -63,7 +63,7 @@ class ProfileTab extends StatelessWidget {
|
||||
// the profile tab as a button in the nav bar.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
@@ -72,7 +72,7 @@ class ProfileTab extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
trailing: CupertinoButton(
|
||||
@@ -81,7 +81,7 @@ class ProfileTab extends StatelessWidget {
|
||||
onPressed: () {
|
||||
// This pushes the settings page as a full page modal dialog on top
|
||||
// of the tab bar and everything.
|
||||
Navigator.of(context, rootNavigator: true).push(
|
||||
Navigator.of(context, rootNavigator: true).push<void>(
|
||||
CupertinoPageRoute(
|
||||
title: SettingsTab.title,
|
||||
fullscreenDialog: true,
|
||||
@@ -172,13 +172,13 @@ class LogOutButton extends StatelessWidget {
|
||||
// app.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return RaisedButton(
|
||||
child: Text('LOG OUT', style: TextStyle(color: Colors.red)),
|
||||
onPressed: () {
|
||||
// You should do something with the result of the dialog prompt in a
|
||||
// real app but this is just a demo.
|
||||
showDialog(
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
@@ -201,14 +201,14 @@ class LogOutButton extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
color: CupertinoColors.destructiveRed,
|
||||
child: Text('Log out'),
|
||||
onPressed: () {
|
||||
// You should do something with the result of the action sheet prompt
|
||||
// in a real app but this is just a demo.
|
||||
showCupertinoModalPopup(
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoActionSheet(
|
||||
|
||||
@@ -83,7 +83,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
// Non-shared code below because this tab uses different scaffolds.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(SettingsTab.title),
|
||||
@@ -92,7 +92,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(),
|
||||
child: _buildList(),
|
||||
|
||||
@@ -77,14 +77,14 @@ class SongDetailTab extends StatelessWidget {
|
||||
// Non-shared code below because we're using different scaffolds.
|
||||
// ===========================================================================
|
||||
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(title: Text(song)),
|
||||
body: _buildBody(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(
|
||||
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;
|
||||
|
||||
// Show a slightly different color palette. Show poppy-ier colors on iOS
|
||||
@@ -64,7 +64,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
song: songNames[index],
|
||||
color: color,
|
||||
heroAnimation: AlwaysStoppedAnimation(0),
|
||||
onPressed: () => Navigator.of(context).push(
|
||||
onPressed: () => Navigator.of(context).push<void>(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SongDetailTab(
|
||||
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'
|
||||
// answer.
|
||||
// ===========================================================================
|
||||
Widget _buildAndroid(context) {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(SongsTab.title),
|
||||
@@ -133,7 +133,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(context) {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CustomScrollView(
|
||||
slivers: [
|
||||
CupertinoSliverNavigationBar(
|
||||
|
||||
@@ -26,9 +26,9 @@ const _myListOfRandomColors = [
|
||||
|
||||
final _random = Random();
|
||||
|
||||
Iterable wordPairIterator = generateWordPair();
|
||||
final wordPairIterator = generateWordPair();
|
||||
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 prefix;
|
||||
@@ -50,7 +50,7 @@ Iterable<WordPair> generateWordPair() sync* {
|
||||
String generateRandomHeadline() {
|
||||
final artist = capitalizePair(wordPairIterator.first);
|
||||
|
||||
switch (_random.nextInt(9)) {
|
||||
switch (_random.nextInt(10)) {
|
||||
case 0:
|
||||
return '$artist says ${nouns[_random.nextInt(nouns.length)]}';
|
||||
case 1:
|
||||
@@ -67,9 +67,9 @@ String generateRandomHeadline() {
|
||||
return '$artist says their music is inspired by ${wordPairIterator.first.join(' ')}';
|
||||
case 7:
|
||||
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:
|
||||
return '$artist calls their band ${adjectives[_random.nextInt(adjectives.length)]}';
|
||||
case 9:
|
||||
return '$artist finally ready to talk about ${nouns[_random.nextInt(nouns.length)]}';
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ String generateRandomHeadline() {
|
||||
}
|
||||
|
||||
List<MaterialColor> getRandomColors(int amount) {
|
||||
return List<MaterialColor>.generate(amount, (int index) {
|
||||
return List<MaterialColor>.generate(amount, (index) {
|
||||
return _myListOfRandomColors[_random.nextInt(_myListOfRandomColors.length)];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ class PressableCard extends StatefulWidget {
|
||||
final Widget child;
|
||||
|
||||
@override
|
||||
State<StatefulWidget> createState() => new _PressableCardState();
|
||||
State<StatefulWidget> createState() => _PressableCardState();
|
||||
}
|
||||
|
||||
class _PressableCardState extends State<PressableCard>
|
||||
@@ -280,7 +280,7 @@ class SongPlaceholderTile extends StatelessWidget {
|
||||
void showChoices(BuildContext context, List<String> choices) {
|
||||
switch (defaultTargetPlatform) {
|
||||
case TargetPlatform.android:
|
||||
showDialog(
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
int selectedRadio = 1;
|
||||
@@ -295,7 +295,8 @@ void showChoices(BuildContext context, List<String> choices) {
|
||||
title: Text(choices[index]),
|
||||
value: index,
|
||||
groupValue: selectedRadio,
|
||||
onChanged: (value) {
|
||||
// ignore: avoid_types_on_closure_parameters
|
||||
onChanged: (int value) {
|
||||
setState(() => selectedRadio = value);
|
||||
},
|
||||
);
|
||||
@@ -318,7 +319,7 @@ void showChoices(BuildContext context, List<String> choices) {
|
||||
);
|
||||
return;
|
||||
case TargetPlatform.iOS:
|
||||
showCupertinoModalPopup(
|
||||
showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return SizedBox(
|
||||
|
||||
@@ -82,7 +82,7 @@ packages:
|
||||
source: hosted
|
||||
version: "1.6.2"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
@@ -157,5 +157,5 @@ packages:
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
sdks:
|
||||
dart: ">=2.2.0 <3.0.0"
|
||||
dart: ">=2.3.0-dev <3.0.0"
|
||||
flutter: ">=1.5.2"
|
||||
|
||||
@@ -3,7 +3,7 @@ description: A project showcasing a Flutter app following different platform IA
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: ">=2.1.0 <3.0.0"
|
||||
sdk: ">=2.3.0-dev <3.0.0"
|
||||
flutter: ">=1.5.2"
|
||||
|
||||
dependencies:
|
||||
@@ -17,6 +17,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.5.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Reference in New Issue
Block a user