Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting rid of containers #147432

Merged
merged 44 commits into from May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2df9506
get rid of containers!
nate-thegrate Mar 29, 2024
88ef5c7
fix analysis problems
nate-thegrate Mar 31, 2024
5b3fe23
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate Apr 23, 2024
2eb9b4d
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate Apr 23, 2024
f5868fb
more container refactoring!
nate-thegrate Apr 23, 2024
49c3c2d
Merge branch 'master' into no-more-containers
nate-thegrate Apr 26, 2024
5130eb8
revert `DecoratedBox` changes
nate-thegrate Apr 26, 2024
8c2e67e
update CupertinoListTile & relevant test
nate-thegrate Apr 26, 2024
8a0baa9
fix CupertinoContextMenu test
nate-thegrate Apr 26, 2024
532a819
revert data_table.dart for now
nate-thegrate Apr 26, 2024
9fd914f
update card_theme_test.dart
nate-thegrate Apr 26, 2024
50fcc9b
fix stepper_test.dart
nate-thegrate Apr 26, 2024
4087e62
improve drawer.dart and relevant test
nate-thegrate Apr 27, 2024
1943456
fix card_test.dart
nate-thegrate Apr 27, 2024
a97d690
update dropdown_menu.dart and relevant test
nate-thegrate Apr 27, 2024
feeeaa9
fix popup_menu_test
nate-thegrate Apr 27, 2024
90614d8
remove redundant import
nate-thegrate Apr 27, 2024
571da17
more semantics!
nate-thegrate Apr 27, 2024
b52f2ca
pushed to the wrong branch 😑
nate-thegrate Apr 27, 2024
7bed677
fix context_menu_test.dart
nate-thegrate Apr 27, 2024
79a76d5
list_section tweak
nate-thegrate Apr 27, 2024
2986d4d
reverting `CupertinoListTile` & `CupertinoListSection` for now
nate-thegrate Apr 27, 2024
8130456
Merge branch 'master' into no-more-containers
nate-thegrate Apr 27, 2024
99c2c1b
fix drawer_theme_test.dart
nate-thegrate Apr 27, 2024
5c8c311
fix navigation_drawer.dart and the relevant test
nate-thegrate Apr 27, 2024
101c33f
fix progress_indicator_test.dart
nate-thegrate Apr 27, 2024
d3bf5be
update autocomplete.dart & relevant test
nate-thegrate Apr 27, 2024
202fdfb
revert autocomplete changes for now
nate-thegrate Apr 27, 2024
defbf62
update popup_menu.dart & relevant test
nate-thegrate Apr 27, 2024
eba16f4
update "Material2 - PopupMenuItem default padding"
nate-thegrate Apr 27, 2024
4875fef
revert cupertino changes (since the PR is pretty huge)
nate-thegrate Apr 27, 2024
20197d8
factor out `LimitedBox` objects
nate-thegrate Apr 28, 2024
67eb7f5
re-implement `LimitedBox` for drawer, tabs, expansion_panel
nate-thegrate Apr 28, 2024
7314e0a
clean up constraints
nate-thegrate Apr 29, 2024
6c2ce6b
update tests
nate-thegrate Apr 29, 2024
5f55cf3
Merge branch 'master' into no-more-containers
nate-thegrate Apr 29, 2024
e7217f6
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 2, 2024
a152a4c
re-implement `cupertino/` stuff
nate-thegrate May 7, 2024
73bdeba
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
722f7dd
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
0dfb13d
keep cupertino & material `a-d`, revert others
nate-thegrate May 7, 2024
5a76fd4
improve date_picker.dart
nate-thegrate May 7, 2024
503d9f6
Merge github.com:flutter/flutter into no-more-containers
nate-thegrate May 7, 2024
5ac446b
Merge branch 'master' into no-more-containers
nate-thegrate May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 11 additions & 9 deletions packages/flutter/lib/src/material/about.dart
Expand Up @@ -590,7 +590,7 @@ class _PackagesViewState extends State<_PackagesView> {
child: Material(
color: Theme.of(context).cardColor,
elevation: 4.0,
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
child: _packagesList(context, selectedId, snapshot.data!, widget.isLateral),
),
Expand Down Expand Up @@ -887,7 +887,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
child: Material(
color: theme.cardColor,
elevation: 4.0,
child: Container(
child: ConstrainedBox(
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
child: Localizations.override(
locale: const Locale('en', 'US'),
Expand Down Expand Up @@ -1365,13 +1365,15 @@ class _MasterDetailScaffoldState extends State<_MasterDetailScaffold>
constraints: BoxConstraints.tightFor(width: masterViewWidth),
child: IconTheme(
data: Theme.of(context).primaryIconTheme,
child: Container(
alignment: AlignmentDirectional.centerEnd,
child: Padding(
padding: const EdgeInsets.all(8),
child: OverflowBar(
spacing: 8,
overflowAlignment: OverflowBarAlignment.end,
children: widget.actionBuilder!(context, _ActionLevel.view),
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: OverflowBar(
spacing: 8,
overflowAlignment: OverflowBarAlignment.end,
children: widget.actionBuilder!(context, _ActionLevel.view),
),
),
),
),
Expand Down Expand Up @@ -1405,7 +1407,7 @@ class _MasterDetailScaffoldState extends State<_MasterDetailScaffold>
child,
),
duration: const Duration(milliseconds: 500),
child: Container(
child: ConstrainedBox(
key: ValueKey<Object?>(value ?? widget.initialArguments),
constraints: const BoxConstraints.expand(),
child: _DetailView(
Expand Down
22 changes: 13 additions & 9 deletions packages/flutter/lib/src/material/banner.dart
Expand Up @@ -345,14 +345,18 @@ class _MaterialBannerState extends State<MaterialBanner> {
?? bannerTheme.leadingPadding
?? const EdgeInsetsDirectional.only(end: 16.0);

final Widget actionsBar = Container(
alignment: AlignmentDirectional.centerEnd,
final Widget actionsBar = ConstrainedBox(
constraints: const BoxConstraints(minHeight: 52.0),
padding: const EdgeInsets.symmetric(horizontal: 8),
child: OverflowBar(
overflowAlignment: widget.overflowAlignment,
spacing: 8,
children: widget.actions,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Align(
alignment: AlignmentDirectional.centerEnd,
child: OverflowBar(
overflowAlignment: widget.overflowAlignment,
spacing: 8,
children: widget.actions,
),
),
),
);

Expand All @@ -373,8 +377,8 @@ class _MaterialBannerState extends State<MaterialBanner> {
?? bannerTheme.contentTextStyle
?? defaults.contentTextStyle;

Widget materialBanner = Container(
margin: margin,
Widget materialBanner = Padding(
padding: margin,
child: Material(
elevation: elevation,
color: backgroundColor,
Expand Down
Expand Up @@ -784,7 +784,7 @@ class _Label extends StatelessWidget {
text = Align(
alignment: Alignment.bottomCenter,
heightFactor: 1.0,
child: Container(child: text),
child: text,
);

if (item.label != null) {
Expand Down
2 changes: 1 addition & 1 deletion packages/flutter/lib/src/material/button.dart
Expand Up @@ -391,7 +391,7 @@ class _RawMaterialButtonState extends State<RawMaterialButton> with MaterialStat
mouseCursor: effectiveMouseCursor,
child: IconTheme.merge(
data: IconThemeData(color: effectiveTextColor),
child: Container(
child: Padding(
padding: padding,
child: Center(
widthFactor: 1.0,
Expand Down
9 changes: 5 additions & 4 deletions packages/flutter/lib/src/material/button_bar.dart
Expand Up @@ -244,11 +244,12 @@ class ButtonBar extends StatelessWidget {
child: child,
);
case ButtonBarLayoutBehavior.constrained:
return Container(
padding: EdgeInsets.symmetric(horizontal: paddingUnit),
return ConstrainedBox(
constraints: const BoxConstraints(minHeight: 52.0),
alignment: Alignment.center,
child: child,
child: Padding(
padding: EdgeInsets.symmetric(horizontal: paddingUnit),
child: Center(child: child),
),
);
}
}
Expand Down
127 changes: 65 additions & 62 deletions packages/flutter/lib/src/material/calendar_date_picker.dart
Expand Up @@ -393,52 +393,54 @@ class _DatePickerModeToggleButtonState extends State<_DatePickerModeToggleButton
final TextTheme textTheme = Theme.of(context).textTheme;
final Color controlColor = colorScheme.onSurface.withOpacity(0.60);

return Container(
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
return SizedBox(
height: _subHeaderHeight,
child: Row(
children: <Widget>[
Flexible(
child: Semantics(
label: MaterialLocalizations.of(context).selectYearSemanticsLabel,
excludeSemantics: true,
button: true,
container: true,
child: SizedBox(
height: _subHeaderHeight,
child: InkWell(
onTap: widget.onTitlePressed,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: <Widget>[
Flexible(
child: Text(
widget.title,
overflow: TextOverflow.ellipsis,
style: textTheme.titleSmall?.copyWith(
color: controlColor,
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
child: Row(
children: <Widget>[
Flexible(
child: Semantics(
label: MaterialLocalizations.of(context).selectYearSemanticsLabel,
excludeSemantics: true,
button: true,
container: true,
child: SizedBox(
height: _subHeaderHeight,
child: InkWell(
onTap: widget.onTitlePressed,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: Row(
children: <Widget>[
Flexible(
child: Text(
widget.title,
overflow: TextOverflow.ellipsis,
style: textTheme.titleSmall?.copyWith(
color: controlColor,
),
),
),
),
RotationTransition(
turns: _controller,
child: Icon(
Icons.arrow_drop_down,
color: controlColor,
RotationTransition(
turns: _controller,
child: Icon(
Icons.arrow_drop_down,
color: controlColor,
),
),
),
],
],
),
),
),
),
),
),
),
if (widget.mode == DatePickerMode.day)
// Give space for the prev/next month buttons that are underneath this row
const SizedBox(width: _monthNavButtonsWidth),
],
if (widget.mode == DatePickerMode.day)
// Give space for the prev/next month buttons that are underneath this row
const SizedBox(width: _monthNavButtonsWidth),
],
),
),
);
}
Expand Down Expand Up @@ -755,25 +757,27 @@ class _MonthPickerState extends State<_MonthPicker> {
return Semantics(
child: Column(
children: <Widget>[
Container(
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
SizedBox(
height: _subHeaderHeight,
child: Row(
children: <Widget>[
const Spacer(),
IconButton(
icon: const Icon(Icons.chevron_left),
color: controlColor,
tooltip: _isDisplayingFirstMonth ? null : _localizations.previousMonthTooltip,
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
),
IconButton(
icon: const Icon(Icons.chevron_right),
color: controlColor,
tooltip: _isDisplayingLastMonth ? null : _localizations.nextMonthTooltip,
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
),
],
child: Padding(
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
child: Row(
children: <Widget>[
const Spacer(),
IconButton(
icon: const Icon(Icons.chevron_left),
color: controlColor,
tooltip: _isDisplayingFirstMonth ? null : _localizations.previousMonthTooltip,
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
),
IconButton(
icon: const Icon(Icons.chevron_right),
color: controlColor,
tooltip: _isDisplayingLastMonth ? null : _localizations.nextMonthTooltip,
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
),
],
),
),
),
Expanded(
Expand Down Expand Up @@ -954,7 +958,7 @@ class _DayPickerState extends State<_DayPicker> {
while (day < daysInMonth) {
day++;
if (day < 1) {
dayItems.add(Container());
dayItems.add(const LimitedBox(maxWidth: 0.0, maxHeight: 0.0, child: SizedBox.expand()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't we use SizedBox.shrink() here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the boxes are unconstrained, then yes! I'll switch it over and see if anything breaks :)

} else {
final DateTime dayToBuild = DateTime(year, month, day);
final bool isDisabled =
Expand Down Expand Up @@ -1291,12 +1295,11 @@ class _YearPickerState extends State<YearPicker> {
decoration: decoration,
height: decorationHeight,
width: decorationWidth,
child: Center(
child: Semantics(
selected: isSelected,
button: true,
child: Text(year.toString(), style: itemStyle),
),
alignment: Alignment.center,
child: Semantics(
selected: isSelected,
button: true,
child: Text(year.toString(), style: itemStyle),
),
),
);
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/lib/src/material/card.dart
Expand Up @@ -224,8 +224,8 @@ class Card extends StatelessWidget {

return Semantics(
container: semanticContainer,
child: Container(
margin: margin ?? cardTheme.margin ?? defaults.margin!,
child: Padding(
padding: margin ?? cardTheme.margin ?? defaults.margin!,
child: Material(
type: MaterialType.card,
color: color ?? cardTheme.color ?? defaults.color,
Expand Down