Enable avoid_unnecessary_containers lint (#77294)

This commit is contained in:
Michael Goderbauer
2021-03-04 15:29:03 -08:00
committed by GitHub
parent c5d1600843
commit ed755fba5e
66 changed files with 689 additions and 849 deletions

View File

@@ -551,9 +551,7 @@ class ItemGalleryBox extends StatelessWidget {
}).toList(),
),
),
Container(
child: const TabPageSelector(),
),
const TabPageSelector(),
],
),
),

View File

@@ -53,12 +53,10 @@ class TextFieldPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
child: Container(
child: TextField(
maxLines: null,
controller: TextEditingController(text: textLotsOfText),
key: const Key('fullscreen-textfield'),
),
child: TextField(
maxLines: null,
controller: TextEditingController(text: textLotsOfText),
key: const Key('fullscreen-textfield'),
),
);
}

View File

@@ -23,15 +23,13 @@ class ModalBottomSheetDemo extends StatelessWidget {
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
return Container(
child: Padding(
padding: const EdgeInsets.all(32.0),
child: Text('This is the modal bottom sheet. Slide down to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0,
),
return Padding(
padding: const EdgeInsets.all(32.0),
child: Text('This is the modal bottom sheet. Slide down to dismiss.',
textAlign: TextAlign.center,
style: TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0,
),
),
);

View File

@@ -541,11 +541,9 @@ class ExtraProductsNumber extends StatelessWidget {
final int numOverflowProducts = _calculateOverflow(model);
// Maximum of 99 so padding doesn't get messy.
final int displayedOverflowProducts = numOverflowProducts <= 99 ? numOverflowProducts : 99;
return Container(
child: Text(
'+$displayedOverflowProducts',
style: Theme.of(context).primaryTextTheme.button,
),
return Text(
'+$displayedOverflowProducts',
style: Theme.of(context).primaryTextTheme.button,
);
}

View File

@@ -41,63 +41,61 @@ class _ShoppingCartPageState extends State<ShoppingCartPage> {
return Scaffold(
backgroundColor: kShrinePink50,
body: SafeArea(
child: Container(
child: ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget? child, AppStateModel model) {
return Stack(
children: <Widget>[
ListView(
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
width: _leftColumnWidth,
child: IconButton(
icon: const Icon(Icons.keyboard_arrow_down),
onPressed: () => ExpandingBottomSheet.of(context)!.close(),
),
child: ScopedModelDescendant<AppStateModel>(
builder: (BuildContext context, Widget? child, AppStateModel model) {
return Stack(
children: <Widget>[
ListView(
children: <Widget>[
Row(
children: <Widget>[
SizedBox(
width: _leftColumnWidth,
child: IconButton(
icon: const Icon(Icons.keyboard_arrow_down),
onPressed: () => ExpandingBottomSheet.of(context)!.close(),
),
Text(
'CART',
style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
),
const SizedBox(width: 16.0),
Text('${model.totalCartQuantity} ITEMS'),
],
),
const SizedBox(height: 16.0),
Column(
children: _createShoppingCartRows(model),
),
ShoppingCartSummary(model: model),
const SizedBox(height: 100.0),
],
),
Positioned(
bottom: 16.0,
left: 16.0,
right: 16.0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: kShrinePink100,
shape: const BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Text('CLEAR CART'),
),
onPressed: () {
model.clearCart();
ExpandingBottomSheet.of(context)!.close();
},
Text(
'CART',
style: localTheme.textTheme.subtitle1!.copyWith(fontWeight: FontWeight.w600),
),
const SizedBox(width: 16.0),
Text('${model.totalCartQuantity} ITEMS'),
],
),
const SizedBox(height: 16.0),
Column(
children: _createShoppingCartRows(model),
),
ShoppingCartSummary(model: model),
const SizedBox(height: 100.0),
],
),
Positioned(
bottom: 16.0,
left: 16.0,
right: 16.0,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
primary: kShrinePink100,
shape: const BeveledRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(7.0)),
),
),
child: const Padding(
padding: EdgeInsets.symmetric(vertical: 12.0),
child: Text('CLEAR CART'),
),
onPressed: () {
model.clearCart();
ExpandingBottomSheet.of(context)!.close();
},
),
],
);
},
),
),
],
);
},
),
),
);