mirror of
https://github.com/flutter/samples.git
synced 2026-04-04 18:51:05 +00:00
Upgrading samples to flutter_lints, part 1 of n (#804)
This commit is contained in:
@@ -13,7 +13,7 @@ class CategoryDropdown extends StatefulWidget {
|
||||
final CategoryApi api;
|
||||
final ValueChanged<Category> onSelected;
|
||||
|
||||
CategoryDropdown({
|
||||
const CategoryDropdown({
|
||||
@required this.api,
|
||||
@required this.onSelected,
|
||||
});
|
||||
@@ -27,6 +27,7 @@ class _CategoryDropdownState extends State<CategoryDropdown> {
|
||||
Future<List<Category>> _future;
|
||||
Stream<List<Category>> _stream;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
@@ -69,7 +70,7 @@ class _CategoryDropdownState extends State<CategoryDropdown> {
|
||||
builder: (context, futureSnapshot) {
|
||||
// Show an empty dropdown while the data is loading.
|
||||
if (!futureSnapshot.hasData) {
|
||||
return DropdownButton<Category>(items: [], onChanged: null);
|
||||
return DropdownButton<Category>(items: const [], onChanged: null);
|
||||
}
|
||||
|
||||
return StreamBuilder<List<Category>>(
|
||||
|
||||
@@ -18,11 +18,12 @@ class CategoryChart extends StatelessWidget {
|
||||
final Category category;
|
||||
final DashboardApi api;
|
||||
|
||||
CategoryChart({
|
||||
const CategoryChart({
|
||||
@required this.category,
|
||||
@required this.api,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
children: [
|
||||
@@ -33,7 +34,7 @@ class CategoryChart extends StatelessWidget {
|
||||
children: [
|
||||
Text(category.name),
|
||||
IconButton(
|
||||
icon: Icon(Icons.settings),
|
||||
icon: const Icon(Icons.settings),
|
||||
onPressed: () {
|
||||
showDialog<EditCategoryDialog>(
|
||||
context: context,
|
||||
@@ -73,14 +74,14 @@ class CategoryChart extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildLoadingIndicator() {
|
||||
return Center(child: CircularProgressIndicator());
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
}
|
||||
|
||||
class _BarChart extends StatelessWidget {
|
||||
final List<Entry> entries;
|
||||
|
||||
_BarChart({this.entries});
|
||||
const _BarChart({this.entries});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
@@ -13,7 +13,7 @@ class NewCategoryForm extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _NewCategoryFormState extends State<NewCategoryForm> {
|
||||
Category _category = Category('');
|
||||
final Category _category = Category('');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -34,7 +34,7 @@ class EditCategoryForm extends StatefulWidget {
|
||||
final Category category;
|
||||
final ValueChanged<bool> onDone;
|
||||
|
||||
EditCategoryForm({
|
||||
const EditCategoryForm({
|
||||
@required this.category,
|
||||
@required this.onDone,
|
||||
});
|
||||
@@ -57,7 +57,7 @@ class _EditCategoryFormState extends State<EditCategoryForm> {
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: TextFormField(
|
||||
initialValue: widget.category.name,
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'Name',
|
||||
),
|
||||
onChanged: (newValue) {
|
||||
@@ -77,7 +77,7 @@ class _EditCategoryFormState extends State<EditCategoryForm> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: ElevatedButton(
|
||||
child: Text('Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
widget.onDone(false);
|
||||
},
|
||||
@@ -86,7 +86,7 @@ class _EditCategoryFormState extends State<EditCategoryForm> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: ElevatedButton(
|
||||
child: Text('OK'),
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
widget.onDone(true);
|
||||
|
||||
@@ -14,7 +14,7 @@ class NewCategoryDialog extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: Text('New Category'),
|
||||
title: const Text('New Category'),
|
||||
children: <Widget>[
|
||||
NewCategoryForm(),
|
||||
],
|
||||
@@ -25,7 +25,7 @@ class NewCategoryDialog extends StatelessWidget {
|
||||
class EditCategoryDialog extends StatelessWidget {
|
||||
final Category category;
|
||||
|
||||
EditCategoryDialog({
|
||||
const EditCategoryDialog({
|
||||
@required this.category,
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ class EditCategoryDialog extends StatelessWidget {
|
||||
var api = Provider.of<AppState>(context).api;
|
||||
|
||||
return SimpleDialog(
|
||||
title: Text('Edit Category'),
|
||||
title: const Text('Edit Category'),
|
||||
children: [
|
||||
EditCategoryForm(
|
||||
category: category,
|
||||
@@ -59,7 +59,7 @@ class _NewEntryDialogState extends State<NewEntryDialog> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SimpleDialog(
|
||||
title: Text('New Entry'),
|
||||
title: const Text('New Entry'),
|
||||
children: [
|
||||
NewEntryForm(),
|
||||
],
|
||||
@@ -71,7 +71,7 @@ class EditEntryDialog extends StatelessWidget {
|
||||
final Category category;
|
||||
final Entry entry;
|
||||
|
||||
EditEntryDialog({
|
||||
const EditEntryDialog({
|
||||
this.category,
|
||||
this.entry,
|
||||
});
|
||||
@@ -81,7 +81,7 @@ class EditEntryDialog extends StatelessWidget {
|
||||
var api = Provider.of<AppState>(context).api;
|
||||
|
||||
return SimpleDialog(
|
||||
title: Text('Edit Entry'),
|
||||
title: const Text('Edit Entry'),
|
||||
children: [
|
||||
EditEntryForm(
|
||||
entry: entry,
|
||||
|
||||
@@ -17,7 +17,7 @@ class NewEntryForm extends StatefulWidget {
|
||||
|
||||
class _NewEntryFormState extends State<NewEntryForm> {
|
||||
Category _selected;
|
||||
Entry _entry = Entry(0, DateTime.now());
|
||||
final Entry _entry = Entry(0, DateTime.now());
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -55,7 +55,7 @@ class EditEntryForm extends StatefulWidget {
|
||||
final Entry entry;
|
||||
final ValueChanged<bool> onDone;
|
||||
|
||||
EditEntryForm({
|
||||
const EditEntryForm({
|
||||
@required this.entry,
|
||||
@required this.onDone,
|
||||
});
|
||||
@@ -75,10 +75,10 @@ class _EditEntryFormState extends State<EditEntryForm> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: TextFormField(
|
||||
initialValue: widget.entry.value.toString(),
|
||||
decoration: InputDecoration(labelText: 'Value'),
|
||||
decoration: const InputDecoration(labelText: 'Value'),
|
||||
keyboardType: TextInputType.number,
|
||||
validator: (value) {
|
||||
try {
|
||||
@@ -98,18 +98,19 @@ class _EditEntryFormState extends State<EditEntryForm> {
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.all(8),
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(intl.DateFormat('MM/dd/yyyy').format(widget.entry.time)),
|
||||
ElevatedButton(
|
||||
child: Text('Edit'),
|
||||
child: const Text('Edit'),
|
||||
onPressed: () async {
|
||||
var result = await showDatePicker(
|
||||
context: context,
|
||||
initialDate: widget.entry.time,
|
||||
firstDate: DateTime.now().subtract(Duration(days: 365)),
|
||||
firstDate:
|
||||
DateTime.now().subtract(const Duration(days: 365)),
|
||||
lastDate: DateTime.now());
|
||||
if (result == null) {
|
||||
return;
|
||||
@@ -128,7 +129,7 @@ class _EditEntryFormState extends State<EditEntryForm> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: ElevatedButton(
|
||||
child: Text('Cancel'),
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () {
|
||||
widget.onDone(false);
|
||||
},
|
||||
@@ -137,7 +138,7 @@ class _EditEntryFormState extends State<EditEntryForm> {
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8.0, right: 8.0),
|
||||
child: ElevatedButton(
|
||||
child: Text('OK'),
|
||||
child: const Text('OK'),
|
||||
onPressed: () {
|
||||
if (_formKey.currentState.validate()) {
|
||||
widget.onDone(true);
|
||||
|
||||
@@ -35,7 +35,7 @@ class AdaptiveScaffold extends StatefulWidget {
|
||||
final ValueChanged<int> onNavigationIndexChange;
|
||||
final FloatingActionButton floatingActionButton;
|
||||
|
||||
AdaptiveScaffold({
|
||||
const AdaptiveScaffold({
|
||||
this.title,
|
||||
this.body,
|
||||
this.actions = const [],
|
||||
|
||||
Reference in New Issue
Block a user