1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-12 15:58:32 +00:00

Upgrading samples to flutter_lints, part 1 of n (#804)

This commit is contained in:
Brett Morgan
2021-06-05 12:24:28 +10:00
committed by GitHub
parent 14921d0c06
commit 936d1fdaae
230 changed files with 2361 additions and 2444 deletions

View File

@@ -10,13 +10,14 @@ import '../app.dart';
import '../widgets/category_chart.dart';
class DashboardPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
var appState = Provider.of<AppState>(context);
return FutureBuilder<List<Category>>(
future: appState.api.categories.list(),
builder: (context, futureSnapshot) {
if (!futureSnapshot.hasData) {
return Center(
return const Center(
child: CircularProgressIndicator(),
);
}
@@ -25,7 +26,7 @@ class DashboardPage extends StatelessWidget {
stream: appState.api.categories.subscribe(),
builder: (context, snapshot) {
if (snapshot.data == null) {
return Center(
return const Center(
child: CircularProgressIndicator(),
);
}
@@ -40,14 +41,14 @@ class DashboardPage extends StatelessWidget {
class Dashboard extends StatelessWidget {
final List<Category> categories;
Dashboard(this.categories);
const Dashboard(this.categories);
@override
Widget build(BuildContext context) {
var api = Provider.of<AppState>(context).api;
return Scrollbar(
child: GridView(
gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent(
childAspectRatio: 2,
maxCrossAxisExtent: 500,
),

View File

@@ -29,7 +29,7 @@ class _EntriesPageState extends State<EntriesPage> {
onSelected: (category) => setState(() => _selected = category)),
Expanded(
child: _selected == null
? Center(child: CircularProgressIndicator())
? const Center(child: CircularProgressIndicator())
: EntriesList(
category: _selected,
api: appState.api.entries,
@@ -89,7 +89,7 @@ class _EntriesListState extends State<EntriesList> {
}
Widget _buildLoadingIndicator() {
return Center(child: CircularProgressIndicator());
return const Center(child: CircularProgressIndicator());
}
}
@@ -97,7 +97,7 @@ class EntryTile extends StatelessWidget {
final Category category;
final Entry entry;
EntryTile({
const EntryTile({
this.category,
this.entry,
});
@@ -111,7 +111,7 @@ class EntryTile extends StatelessWidget {
mainAxisSize: MainAxisSize.min,
children: [
TextButton(
child: Text('Edit'),
child: const Text('Edit'),
onPressed: () {
showDialog<void>(
context: context,
@@ -122,19 +122,19 @@ class EntryTile extends StatelessWidget {
},
),
TextButton(
child: Text('Delete'),
child: const Text('Delete'),
onPressed: () async {
var shouldDelete = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text('Delete entry?'),
title: const Text('Delete entry?'),
actions: [
TextButton(
child: Text('Cancel'),
child: const Text('Cancel'),
onPressed: () => Navigator.of(context).pop(false),
),
TextButton(
child: Text('Delete'),
child: const Text('Delete'),
onPressed: () => Navigator.of(context).pop(true),
),
],
@@ -147,7 +147,7 @@ class EntryTile extends StatelessWidget {
.delete(category.id, entry.id);
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
const SnackBar(
content: Text('Entry deleted'),
),
);

View File

@@ -12,7 +12,7 @@ import 'entries.dart';
class HomePage extends StatefulWidget {
final VoidCallback onSignOut;
HomePage({
const HomePage({
@required this.onSignOut,
});
@@ -26,19 +26,19 @@ class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return AdaptiveScaffold(
title: Text('Dashboard App'),
title: const Text('Dashboard App'),
actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextButton(
style: TextButton.styleFrom(primary: Colors.white),
onPressed: () => _handleSignOut(),
child: Text('Sign Out'),
child: const Text('Sign Out'),
),
)
],
currentIndex: _pageIndex,
destinations: [
destinations: const [
AdaptiveScaffoldDestination(title: 'Home', icon: Icons.home),
AdaptiveScaffoldDestination(title: 'Entries', icon: Icons.list),
AdaptiveScaffoldDestination(title: 'Settings', icon: Icons.settings),
@@ -61,7 +61,7 @@ class _HomePageState extends State<HomePage> {
FloatingActionButton _buildFab(BuildContext context) {
return FloatingActionButton(
child: Icon(Icons.add),
child: const Icon(Icons.add),
onPressed: () => _handleFabPressed(),
);
}
@@ -88,16 +88,16 @@ class _HomePageState extends State<HomePage> {
var shouldSignOut = await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text('Are you sure you want to sign out?'),
title: const Text('Are you sure you want to sign out?'),
actions: [
TextButton(
child: Text('No'),
child: const Text('No'),
onPressed: () {
Navigator.of(context).pop(false);
},
),
TextButton(
child: Text('Yes'),
child: const Text('Yes'),
onPressed: () {
Navigator.of(context).pop(true);
},
@@ -122,6 +122,6 @@ class _HomePageState extends State<HomePage> {
return EntriesPage();
}
return Center(child: Text('Settings page'));
return const Center(child: Text('Settings page'));
}
}

View File

@@ -10,7 +10,7 @@ class SignInPage extends StatelessWidget {
final Auth auth;
final ValueChanged<User> onSuccess;
SignInPage({
const SignInPage({
@required this.auth,
@required this.onSuccess,
});
@@ -29,7 +29,7 @@ class SignInButton extends StatefulWidget {
final Auth auth;
final ValueChanged<User> onSuccess;
SignInButton({
const SignInButton({
@required this.auth,
@required this.onSuccess,
});
@@ -78,7 +78,7 @@ class _SignInButtonState extends State<SignInButton> {
var alreadySignedIn = snapshot.data;
if (snapshot.connectionState != ConnectionState.done ||
alreadySignedIn == true) {
return CircularProgressIndicator();
return const CircularProgressIndicator();
}
// If sign in failed, show toast and the login button
@@ -87,7 +87,7 @@ class _SignInButtonState extends State<SignInButton> {
}
return ElevatedButton(
child: Text('Sign In with Google'),
child: const Text('Sign In with Google'),
onPressed: () => _signIn(),
);
},
@@ -96,7 +96,7 @@ class _SignInButtonState extends State<SignInButton> {
void _showError() {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
const SnackBar(
content: Text('Unable to sign in.'),
),
);