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:
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
|
||||
final appTheme = ThemeData(
|
||||
primarySwatch: Colors.yellow,
|
||||
textTheme: TextTheme(
|
||||
textTheme: const TextTheme(
|
||||
headline1: TextStyle(
|
||||
fontFamily: 'Corben',
|
||||
fontWeight: FontWeight.w700,
|
||||
|
||||
@@ -24,7 +24,7 @@ class MyCart extends StatelessWidget {
|
||||
child: _CartList(),
|
||||
),
|
||||
),
|
||||
Divider(height: 4, color: Colors.black),
|
||||
const Divider(height: 4, color: Colors.black),
|
||||
_CartTotal()
|
||||
],
|
||||
),
|
||||
@@ -45,9 +45,9 @@ class _CartList extends StatelessWidget {
|
||||
return ListView.builder(
|
||||
itemCount: cart.items.length,
|
||||
itemBuilder: (context, index) => ListTile(
|
||||
leading: Icon(Icons.done),
|
||||
leading: const Icon(Icons.done),
|
||||
trailing: IconButton(
|
||||
icon: Icon(Icons.remove_circle_outline),
|
||||
icon: const Icon(Icons.remove_circle_outline),
|
||||
onPressed: () {
|
||||
cart.remove(cart.items[index]);
|
||||
},
|
||||
@@ -82,14 +82,14 @@ class _CartTotal extends StatelessWidget {
|
||||
Consumer<CartModel>(
|
||||
builder: (context, cart, child) =>
|
||||
Text('\$${cart.totalPrice}', style: hugeStyle)),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Buying not supported yet.')));
|
||||
const SnackBar(content: Text('Buying not supported yet.')));
|
||||
},
|
||||
style: TextButton.styleFrom(primary: Colors.white),
|
||||
child: Text('BUY'),
|
||||
child: const Text('BUY'),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -14,7 +14,7 @@ class MyCatalog extends StatelessWidget {
|
||||
body: CustomScrollView(
|
||||
slivers: [
|
||||
_MyAppBar(),
|
||||
SliverToBoxAdapter(child: SizedBox(height: 12)),
|
||||
const SliverToBoxAdapter(child: SizedBox(height: 12)),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) => _MyListItem(index)),
|
||||
@@ -62,7 +62,9 @@ class _AddButton extends StatelessWidget {
|
||||
return null; // Defer to the widget's default.
|
||||
}),
|
||||
),
|
||||
child: isInCart ? Icon(Icons.check, semanticLabel: 'ADDED') : Text('ADD'),
|
||||
child: isInCart
|
||||
? const Icon(Icons.check, semanticLabel: 'ADDED')
|
||||
: const Text('ADD'),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -75,7 +77,7 @@ class _MyAppBar extends StatelessWidget {
|
||||
floating: true,
|
||||
actions: [
|
||||
IconButton(
|
||||
icon: Icon(Icons.shopping_cart),
|
||||
icon: const Icon(Icons.shopping_cart),
|
||||
onPressed: () => Navigator.pushNamed(context, '/cart'),
|
||||
),
|
||||
],
|
||||
@@ -86,7 +88,7 @@ class _MyAppBar extends StatelessWidget {
|
||||
class _MyListItem extends StatelessWidget {
|
||||
final int index;
|
||||
|
||||
_MyListItem(this.index, {Key? key}) : super(key: key);
|
||||
const _MyListItem(this.index, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -109,11 +111,11 @@ class _MyListItem extends StatelessWidget {
|
||||
color: item.color,
|
||||
),
|
||||
),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
Expanded(
|
||||
child: Text(item.name, style: textTheme),
|
||||
),
|
||||
SizedBox(width: 24),
|
||||
const SizedBox(width: 24),
|
||||
_AddButton(item: item),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -10,7 +10,7 @@ class MyLogin extends StatelessWidget {
|
||||
return Scaffold(
|
||||
body: Center(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(80.0),
|
||||
padding: const EdgeInsets.all(80.0),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
@@ -19,21 +19,21 @@ class MyLogin extends StatelessWidget {
|
||||
style: Theme.of(context).textTheme.headline1,
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Username',
|
||||
),
|
||||
),
|
||||
TextFormField(
|
||||
decoration: InputDecoration(
|
||||
decoration: const InputDecoration(
|
||||
hintText: 'Password',
|
||||
),
|
||||
obscureText: true,
|
||||
),
|
||||
SizedBox(
|
||||
const SizedBox(
|
||||
height: 24,
|
||||
),
|
||||
ElevatedButton(
|
||||
child: Text('ENTER'),
|
||||
child: const Text('ENTER'),
|
||||
onPressed: () {
|
||||
Navigator.pushReplacementNamed(context, '/catalog');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user