mirror of
https://github.com/flutter/samples.git
synced 2025-11-08 13:58:47 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
include: package:pedantic/analysis_options.1.9.0.yaml
|
||||
include: package:flutter_lints/flutter.yaml
|
||||
|
||||
analyzer:
|
||||
strong-mode:
|
||||
@@ -7,25 +7,14 @@ analyzer:
|
||||
|
||||
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
|
||||
- directives_ordering
|
||||
- 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
|
||||
avoid_types_on_closure_parameters: true
|
||||
avoid_void_async: true
|
||||
cancel_subscriptions: true
|
||||
close_sinks: true
|
||||
directives_ordering: true
|
||||
package_api_docs: true
|
||||
package_prefixed_library_names: true
|
||||
test_types_in_equals: true
|
||||
throw_in_finally: true
|
||||
unnecessary_statements: true
|
||||
use_key_in_widget_constructors: false
|
||||
|
||||
@@ -9,11 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
|
||||
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
|
||||
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
|
||||
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
|
||||
@@ -26,8 +22,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */,
|
||||
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */,
|
||||
);
|
||||
name = "Embed Frameworks";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@@ -38,13 +32,11 @@
|
||||
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
|
||||
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
|
||||
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
|
||||
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = "<group>"; };
|
||||
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
|
||||
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
@@ -57,8 +49,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
|
||||
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -68,9 +58,7 @@
|
||||
9740EEB11CF90186004384FC /* Flutter */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3B80C3931E831B6300D905FE /* App.framework */,
|
||||
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
|
||||
9740EEBA1CF902C7004384FC /* Flutter.framework */,
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */,
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */,
|
||||
9740EEB31CF90195004384FC /* Generated.xcconfig */,
|
||||
@@ -201,7 +189,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin";
|
||||
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
|
||||
};
|
||||
9740EEB61CF901F6004384FC /* Run Script */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@@ -253,7 +241,6 @@
|
||||
/* Begin XCBuildConfiguration section */
|
||||
249021D3217E4FDB00AE95B9 /* Profile */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -330,7 +317,6 @@
|
||||
};
|
||||
97C147031CF9000F007C117D /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
@@ -386,7 +372,6 @@
|
||||
};
|
||||
97C147041CF9000F007C117D /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Runner.xcodeproj">
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
|
||||
@@ -30,7 +30,7 @@ class MyAdaptingApp extends StatelessWidget {
|
||||
// Instead of letting Cupertino widgets auto-adapt to the Material
|
||||
// theme (which is green), this app will use a different theme
|
||||
// for Cupertino (which is blue by default).
|
||||
data: CupertinoThemeData(),
|
||||
data: const CupertinoThemeData(),
|
||||
child: Material(child: child),
|
||||
);
|
||||
},
|
||||
@@ -82,7 +82,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
||||
Widget _buildIosHomePage(BuildContext context) {
|
||||
return CupertinoTabScaffold(
|
||||
tabBar: CupertinoTabBar(
|
||||
items: [
|
||||
items: const [
|
||||
BottomNavigationBarItem(
|
||||
label: SongsTab.title,
|
||||
icon: SongsTab.iosIcon,
|
||||
@@ -116,7 +116,7 @@ class _PlatformAdaptingHomePageState extends State<PlatformAdaptingHomePage> {
|
||||
);
|
||||
default:
|
||||
assert(false, 'Unexpected tab');
|
||||
return SizedBox.shrink();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
);
|
||||
@@ -139,7 +139,7 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
DrawerHeader(
|
||||
decoration: BoxDecoration(color: Colors.green),
|
||||
decoration: const BoxDecoration(color: Colors.green),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(bottom: 20),
|
||||
child: Icon(
|
||||
@@ -151,14 +151,14 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
),
|
||||
ListTile(
|
||||
leading: SongsTab.androidIcon,
|
||||
title: Text(SongsTab.title),
|
||||
title: const Text(SongsTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
leading: NewsTab.androidIcon,
|
||||
title: Text(NewsTab.title),
|
||||
title: const Text(NewsTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push<void>(
|
||||
@@ -167,7 +167,7 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
),
|
||||
ListTile(
|
||||
leading: ProfileTab.androidIcon,
|
||||
title: Text(ProfileTab.title),
|
||||
title: const Text(ProfileTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push<void>(context,
|
||||
@@ -175,13 +175,13 @@ class _AndroidDrawer extends StatelessWidget {
|
||||
},
|
||||
),
|
||||
// Long drawer contents are often segmented.
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
const Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Divider(),
|
||||
),
|
||||
ListTile(
|
||||
leading: SettingsTab.androidIcon,
|
||||
title: Text(SettingsTab.title),
|
||||
title: const Text(SettingsTab.title),
|
||||
onTap: () {
|
||||
Navigator.pop(context);
|
||||
Navigator.push<void>(context,
|
||||
|
||||
@@ -41,7 +41,7 @@ class _NewsTabState extends State<NewsTab> {
|
||||
bottom: false,
|
||||
child: Card(
|
||||
elevation: 1.5,
|
||||
margin: EdgeInsets.fromLTRB(6, 12, 6, 0),
|
||||
margin: const EdgeInsets.fromLTRB(6, 12, 6, 0),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(4),
|
||||
),
|
||||
@@ -58,22 +58,22 @@ class _NewsTabState extends State<NewsTab> {
|
||||
backgroundColor: colors[index],
|
||||
child: Text(
|
||||
titles[index].substring(0, 1),
|
||||
style: TextStyle(color: Colors.white),
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(left: 16)),
|
||||
const Padding(padding: EdgeInsets.only(left: 16)),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
titles[index],
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
),
|
||||
Padding(padding: EdgeInsets.only(top: 8)),
|
||||
const Padding(padding: EdgeInsets.only(top: 8)),
|
||||
Text(
|
||||
contents[index],
|
||||
),
|
||||
@@ -95,20 +95,18 @@ class _NewsTabState extends State<NewsTab> {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(NewsTab.title),
|
||||
title: const Text(NewsTab.title),
|
||||
),
|
||||
body: Container(
|
||||
child: ListView.builder(
|
||||
itemCount: _itemsLength,
|
||||
itemBuilder: _listBuilder,
|
||||
),
|
||||
body: ListView.builder(
|
||||
itemCount: _itemsLength,
|
||||
itemBuilder: _listBuilder,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(),
|
||||
navigationBar: const CupertinoNavigationBar(),
|
||||
child: ListView.builder(
|
||||
itemCount: _itemsLength,
|
||||
itemBuilder: _listBuilder,
|
||||
|
||||
@@ -19,7 +19,7 @@ class ProfileTab extends StatelessWidget {
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
const Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
child: Center(
|
||||
child: Text(
|
||||
@@ -31,7 +31,7 @@ class ProfileTab extends StatelessWidget {
|
||||
),
|
||||
),
|
||||
),
|
||||
PreferenceCard(
|
||||
const PreferenceCard(
|
||||
header: 'MY INTENSITY PREFERENCE',
|
||||
content: '🔥',
|
||||
preferenceChoices: [
|
||||
@@ -42,7 +42,7 @@ class ProfileTab extends StatelessWidget {
|
||||
'My neighbor hates me',
|
||||
],
|
||||
),
|
||||
PreferenceCard(
|
||||
const PreferenceCard(
|
||||
header: 'CURRENT MOOD',
|
||||
content: '🤘🏾🚀',
|
||||
preferenceChoices: [
|
||||
@@ -70,7 +70,7 @@ class ProfileTab extends StatelessWidget {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(title),
|
||||
title: const Text(title),
|
||||
),
|
||||
body: _buildBody(context),
|
||||
);
|
||||
@@ -123,18 +123,18 @@ class PreferenceCard extends StatelessWidget {
|
||||
Widget build(context) {
|
||||
return PressableCard(
|
||||
color: Colors.green,
|
||||
flattenAnimation: AlwaysStoppedAnimation(0),
|
||||
flattenAnimation: const AlwaysStoppedAnimation(0),
|
||||
child: Stack(
|
||||
children: [
|
||||
Container(
|
||||
SizedBox(
|
||||
height: 120,
|
||||
width: 250,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 40),
|
||||
padding: const EdgeInsets.only(top: 40),
|
||||
child: Center(
|
||||
child: Text(
|
||||
content,
|
||||
style: TextStyle(fontSize: 48),
|
||||
style: const TextStyle(fontSize: 48),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -146,11 +146,11 @@ class PreferenceCard extends StatelessWidget {
|
||||
child: Container(
|
||||
color: Colors.black12,
|
||||
height: 40,
|
||||
padding: EdgeInsets.only(left: 12),
|
||||
padding: const EdgeInsets.only(left: 12),
|
||||
alignment: Alignment.centerLeft,
|
||||
child: Text(
|
||||
header,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
@@ -182,7 +182,7 @@ class LogOutButton extends StatelessWidget {
|
||||
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return ElevatedButton(
|
||||
child: Text('LOG OUT', style: TextStyle(color: Colors.red)),
|
||||
child: const 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.
|
||||
@@ -190,7 +190,7 @@ class LogOutButton extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
title: Text('Log out?'),
|
||||
title: const Text('Log out?'),
|
||||
content: _logoutMessage,
|
||||
actions: [
|
||||
TextButton(
|
||||
@@ -212,7 +212,7 @@ class LogOutButton extends StatelessWidget {
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoButton(
|
||||
color: CupertinoColors.destructiveRed,
|
||||
child: Text('Log out'),
|
||||
child: const 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.
|
||||
@@ -220,7 +220,7 @@ class LogOutButton extends StatelessWidget {
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoActionSheet(
|
||||
title: Text('Log out?'),
|
||||
title: const Text('Log out?'),
|
||||
message: _logoutMessage,
|
||||
actions: [
|
||||
CupertinoActionSheetAction(
|
||||
|
||||
@@ -28,9 +28,9 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
Widget _buildList() {
|
||||
return ListView(
|
||||
children: [
|
||||
Padding(padding: EdgeInsets.only(top: 24)),
|
||||
const Padding(padding: EdgeInsets.only(top: 24)),
|
||||
ListTile(
|
||||
title: Text('Send me marketing emails'),
|
||||
title: const Text('Send me marketing emails'),
|
||||
// The Material switch has a platform adaptive constructor.
|
||||
trailing: Switch.adaptive(
|
||||
value: switch1,
|
||||
@@ -38,42 +38,42 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Enable notifications'),
|
||||
title: const Text('Enable notifications'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch2,
|
||||
onChanged: (value) => setState(() => switch2 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Remind me to rate this app'),
|
||||
title: const Text('Remind me to rate this app'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch3,
|
||||
onChanged: (value) => setState(() => switch3 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Background song refresh'),
|
||||
title: const Text('Background song refresh'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch4,
|
||||
onChanged: (value) => setState(() => switch4 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Recommend me songs based on my location'),
|
||||
title: const Text('Recommend me songs based on my location'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch5,
|
||||
onChanged: (value) => setState(() => switch5 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Auto-transition playback to cast devices'),
|
||||
title: const Text('Auto-transition playback to cast devices'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch6,
|
||||
onChanged: (value) => setState(() => switch6 = value),
|
||||
),
|
||||
),
|
||||
ListTile(
|
||||
title: Text('Find friends from my contact list'),
|
||||
title: const Text('Find friends from my contact list'),
|
||||
trailing: Switch.adaptive(
|
||||
value: switch7,
|
||||
onChanged: (value) => setState(() => switch7 = value),
|
||||
@@ -90,7 +90,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(SettingsTab.title),
|
||||
title: const Text(SettingsTab.title),
|
||||
),
|
||||
body: _buildList(),
|
||||
);
|
||||
@@ -98,7 +98,7 @@ class _SettingsTabState extends State<SettingsTab> {
|
||||
|
||||
Widget _buildIos(BuildContext context) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: CupertinoNavigationBar(),
|
||||
navigationBar: const CupertinoNavigationBar(),
|
||||
child: _buildList(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class SongDetailTab extends StatelessWidget {
|
||||
child: HeroAnimatingSongCard(
|
||||
song: song,
|
||||
color: color,
|
||||
heroAnimation: AlwaysStoppedAnimation(1),
|
||||
heroAnimation: const AlwaysStoppedAnimation(1),
|
||||
),
|
||||
// This app uses a flightShuttleBuilder to specify the exact widget
|
||||
// to build while the hero transition is mid-flight.
|
||||
@@ -50,7 +50,7 @@ class SongDetailTab extends StatelessWidget {
|
||||
);
|
||||
},
|
||||
),
|
||||
Divider(
|
||||
const Divider(
|
||||
height: 0,
|
||||
color: Colors.grey,
|
||||
),
|
||||
@@ -59,9 +59,8 @@ class SongDetailTab extends StatelessWidget {
|
||||
itemCount: 10,
|
||||
itemBuilder: (context, index) {
|
||||
if (index == 0) {
|
||||
return Padding(
|
||||
padding:
|
||||
const EdgeInsets.only(left: 15, top: 16, bottom: 8),
|
||||
return const Padding(
|
||||
padding: EdgeInsets.only(left: 15, top: 16, bottom: 8),
|
||||
child: Text(
|
||||
'You might also like:',
|
||||
style: TextStyle(
|
||||
|
||||
@@ -67,7 +67,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
child: HeroAnimatingSongCard(
|
||||
song: songNames[index],
|
||||
color: color,
|
||||
heroAnimation: AlwaysStoppedAnimation(0),
|
||||
heroAnimation: const AlwaysStoppedAnimation(0),
|
||||
onPressed: () => Navigator.of(context).push<void>(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => SongDetailTab(
|
||||
@@ -113,15 +113,15 @@ class _SongsTabState extends State<SongsTab> {
|
||||
Widget _buildAndroid(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(SongsTab.title),
|
||||
title: const Text(SongsTab.title),
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.refresh),
|
||||
icon: const Icon(Icons.refresh),
|
||||
onPressed: () async =>
|
||||
await _androidRefreshKey.currentState!.show(),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(Icons.shuffle),
|
||||
icon: const Icon(Icons.shuffle),
|
||||
onPressed: _togglePlatform,
|
||||
),
|
||||
],
|
||||
@@ -131,7 +131,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
key: _androidRefreshKey,
|
||||
onRefresh: _refreshData,
|
||||
child: ListView.builder(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
itemCount: _itemsLength,
|
||||
itemBuilder: _listBuilder,
|
||||
),
|
||||
@@ -145,7 +145,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
CupertinoSliverNavigationBar(
|
||||
trailing: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
child: Icon(CupertinoIcons.shuffle),
|
||||
child: const Icon(CupertinoIcons.shuffle),
|
||||
onPressed: _togglePlatform,
|
||||
),
|
||||
),
|
||||
@@ -155,7 +155,7 @@ class _SongsTabState extends State<SongsTab> {
|
||||
SliverSafeArea(
|
||||
top: false,
|
||||
sliver: SliverPadding(
|
||||
padding: EdgeInsets.symmetric(vertical: 12),
|
||||
padding: const EdgeInsets.symmetric(vertical: 12),
|
||||
sliver: SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
_listBuilder,
|
||||
|
||||
@@ -26,7 +26,7 @@ class PlatformWidget extends StatelessWidget {
|
||||
return iosBuilder(context);
|
||||
default:
|
||||
assert(false, 'Unexpected platform $defaultTargetPlatform');
|
||||
return SizedBox.shrink();
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -107,8 +107,9 @@ class _PressableCardState extends State<PressableCard>
|
||||
// in your own app.
|
||||
scale: 1 - elevationAnimation.value * 0.03,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 16, horizontal: 16) *
|
||||
flatten,
|
||||
padding:
|
||||
const EdgeInsets.symmetric(vertical: 16, horizontal: 16) *
|
||||
flatten,
|
||||
child: PhysicalModel(
|
||||
elevation:
|
||||
((1 - elevationAnimation.value) * 10 + 10) * flatten,
|
||||
@@ -134,7 +135,7 @@ class _PressableCardState extends State<PressableCard>
|
||||
/// This is an example of a custom widget that an app developer might create for
|
||||
/// use on both iOS and Android as part of their brand's unique design.
|
||||
class HeroAnimatingSongCard extends StatelessWidget {
|
||||
HeroAnimatingSongCard({
|
||||
const HeroAnimatingSongCard({
|
||||
required this.song,
|
||||
required this.color,
|
||||
required this.heroAnimation,
|
||||
@@ -177,10 +178,10 @@ class HeroAnimatingSongCard extends StatelessWidget {
|
||||
height: 80,
|
||||
color: Colors.black12,
|
||||
alignment: Alignment.centerLeft,
|
||||
padding: EdgeInsets.symmetric(horizontal: 12),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
||||
child: Text(
|
||||
song,
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 21,
|
||||
fontWeight: FontWeight.w500,
|
||||
),
|
||||
@@ -189,12 +190,12 @@ class HeroAnimatingSongCard extends StatelessWidget {
|
||||
),
|
||||
// The play button grows in the hero animation.
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsets.only(bottom: 45) * (1 - heroAnimation.value),
|
||||
padding: const EdgeInsets.only(bottom: 45) *
|
||||
(1 - heroAnimation.value),
|
||||
child: Container(
|
||||
height: playButtonSize,
|
||||
width: playButtonSize,
|
||||
decoration: BoxDecoration(
|
||||
decoration: const BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
color: Colors.black12,
|
||||
),
|
||||
@@ -222,14 +223,14 @@ class SongPlaceholderTile extends StatelessWidget {
|
||||
return SizedBox(
|
||||
height: 95,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 8),
|
||||
child: Row(
|
||||
children: [
|
||||
Container(
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
width: 130,
|
||||
),
|
||||
Padding(
|
||||
const Padding(
|
||||
padding: EdgeInsets.only(left: 12),
|
||||
),
|
||||
Expanded(
|
||||
@@ -238,27 +239,27 @@ class SongPlaceholderTile extends StatelessWidget {
|
||||
children: [
|
||||
Container(
|
||||
height: 9,
|
||||
margin: EdgeInsets.only(right: 60),
|
||||
margin: const EdgeInsets.only(right: 60),
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
),
|
||||
Container(
|
||||
height: 9,
|
||||
margin: EdgeInsets.only(right: 20, top: 8),
|
||||
margin: const EdgeInsets.only(right: 20, top: 8),
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
),
|
||||
Container(
|
||||
height: 9,
|
||||
margin: EdgeInsets.only(right: 40, top: 8),
|
||||
margin: const EdgeInsets.only(right: 40, top: 8),
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
),
|
||||
Container(
|
||||
height: 9,
|
||||
margin: EdgeInsets.only(right: 80, top: 8),
|
||||
margin: const EdgeInsets.only(right: 80, top: 8),
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
),
|
||||
Container(
|
||||
height: 9,
|
||||
margin: EdgeInsets.only(right: 50, top: 8),
|
||||
margin: const EdgeInsets.only(right: 50, top: 8),
|
||||
color: Theme.of(context).textTheme.bodyText2!.color,
|
||||
),
|
||||
],
|
||||
@@ -289,7 +290,7 @@ void showChoices(BuildContext context, List<String> choices) {
|
||||
builder: (context) {
|
||||
int? selectedRadio = 1;
|
||||
return AlertDialog(
|
||||
contentPadding: EdgeInsets.only(top: 12),
|
||||
contentPadding: const EdgeInsets.only(top: 12),
|
||||
content: StatefulBuilder(
|
||||
builder: (context, setState) {
|
||||
return Column(
|
||||
@@ -309,11 +310,11 @@ void showChoices(BuildContext context, List<String> choices) {
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
child: Text('OK'),
|
||||
child: const Text('OK'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
TextButton(
|
||||
child: Text('CANCEL'),
|
||||
child: const Text('CANCEL'),
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
),
|
||||
],
|
||||
@@ -337,7 +338,7 @@ void showChoices(BuildContext context, List<String> choices) {
|
||||
return Center(
|
||||
child: Text(
|
||||
choices[index],
|
||||
style: TextStyle(
|
||||
style: const TextStyle(
|
||||
fontSize: 21,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -56,7 +56,7 @@ packages:
|
||||
name: english_words
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "4.0.0-nullsafety.0"
|
||||
version: "4.0.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -69,6 +69,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.3"
|
||||
flutter_lorem:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@@ -81,6 +88,13 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -102,13 +116,6 @@ packages:
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.8.0"
|
||||
pedantic:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
|
||||
@@ -3,10 +3,10 @@ description: A project showcasing a Flutter app following different platform IA
|
||||
version: 1.0.0+1
|
||||
|
||||
environment:
|
||||
sdk: '>=2.12.0-0 <3.0.0'
|
||||
sdk: ">=2.12.0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
english_words: ^4.0.0-nullsafety.0
|
||||
english_words: ^4.0.0
|
||||
flutter_lorem: ^2.0.0
|
||||
flutter:
|
||||
sdk: flutter
|
||||
@@ -16,7 +16,7 @@ dependencies:
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
pedantic: ^1.10.0
|
||||
flutter_lints: ^1.0.0
|
||||
|
||||
flutter:
|
||||
uses-material-design: true
|
||||
|
||||
Reference in New Issue
Block a user