Getting rid of containers (#147432)
This pull request aims to make the Flutter framework more efficient, based on issue #147431.
This commit is contained in:
parent
77427f6608
commit
94a7151eb8
@ -120,33 +120,26 @@ class _CupertinoContextMenuActionState extends State<CupertinoContextMenuAction>
|
|||||||
),
|
),
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
button: true,
|
button: true,
|
||||||
child: Container(
|
child: ColoredBox(
|
||||||
decoration: BoxDecoration(
|
color: _isPressed
|
||||||
color: _isPressed
|
|
||||||
? CupertinoDynamicColor.resolve(_kBackgroundColorPressed, context)
|
? CupertinoDynamicColor.resolve(_kBackgroundColorPressed, context)
|
||||||
: CupertinoDynamicColor.resolve(_kBackgroundColor, context),
|
: CupertinoDynamicColor.resolve(_kBackgroundColor, context),
|
||||||
),
|
child: Padding(
|
||||||
padding: const EdgeInsets.only(
|
padding: const EdgeInsets.fromLTRB(15.5, 8.0, 17.5, 8.0),
|
||||||
top: 8,
|
child: DefaultTextStyle(
|
||||||
bottom: 8,
|
style: _textStyle,
|
||||||
left: 15.5,
|
child: Row(
|
||||||
right: 17.5,
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
),
|
children: <Widget>[
|
||||||
child: DefaultTextStyle(
|
Flexible(child: widget.child),
|
||||||
style: _textStyle,
|
if (widget.trailingIcon != null)
|
||||||
child: Row(
|
Icon(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
widget.trailingIcon,
|
||||||
children: <Widget>[
|
color: _textStyle.color,
|
||||||
Flexible(
|
size: 21.0,
|
||||||
child: widget.child,
|
),
|
||||||
),
|
],
|
||||||
if (widget.trailingIcon != null)
|
),
|
||||||
Icon(
|
|
||||||
widget.trailingIcon,
|
|
||||||
color: _textStyle.color,
|
|
||||||
size: 21.0,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -1050,10 +1050,11 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
|
|||||||
final List<Widget> pickers = <Widget>[];
|
final List<Widget> pickers = <Widget>[];
|
||||||
double totalColumnWidths = 4 * _kDatePickerPadSize;
|
double totalColumnWidths = 4 * _kDatePickerPadSize;
|
||||||
|
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (final (int i, double width) in columnWidths.indexed) {
|
||||||
|
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
|
||||||
double offAxisFraction = 0.0;
|
double offAxisFraction = 0.0;
|
||||||
Widget selectionOverlay = _centerSelectionOverlay;
|
Widget selectionOverlay = _centerSelectionOverlay;
|
||||||
if (i == 0) {
|
if (firstColumn) {
|
||||||
offAxisFraction = -_kMaximumOffAxisFraction * textDirectionFactor;
|
offAxisFraction = -_kMaximumOffAxisFraction * textDirectionFactor;
|
||||||
selectionOverlay = _startSelectionOverlay;
|
selectionOverlay = _startSelectionOverlay;
|
||||||
} else if (i >= 2 || columnWidths.length == 2) {
|
} else if (i >= 2 || columnWidths.length == 2) {
|
||||||
@ -1061,7 +1062,7 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
|
EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
|
||||||
if (i == columnWidths.length - 1) {
|
if (lastColumn) {
|
||||||
padding = padding.flipped;
|
padding = padding.flipped;
|
||||||
selectionOverlay = _endSelectionOverlay;
|
selectionOverlay = _endSelectionOverlay;
|
||||||
}
|
}
|
||||||
@ -1069,24 +1070,23 @@ class _CupertinoDatePickerDateTimeState extends State<CupertinoDatePicker> {
|
|||||||
padding = padding.flipped;
|
padding = padding.flipped;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
|
totalColumnWidths += width + (2 * _kDatePickerPadSize);
|
||||||
|
|
||||||
pickers.add(LayoutId(
|
pickers.add(LayoutId(
|
||||||
id: i,
|
id: i,
|
||||||
child: pickerBuilders[i](
|
child: pickerBuilders[i](
|
||||||
offAxisFraction,
|
offAxisFraction,
|
||||||
(BuildContext context, Widget? child) {
|
(BuildContext context, Widget? child) {
|
||||||
return Container(
|
late final Widget constrained = ConstrainedBox(
|
||||||
alignment: i == columnWidths.length - 1
|
constraints: BoxConstraints(maxWidth: width + _kDatePickerPadSize),
|
||||||
? alignCenterLeft
|
child: child,
|
||||||
: alignCenterRight,
|
);
|
||||||
|
|
||||||
|
return Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: Container(
|
child: Align(
|
||||||
alignment: i == columnWidths.length - 1 ? alignCenterLeft : alignCenterRight,
|
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
|
||||||
width: i == 0 || i == columnWidths.length - 1
|
child: firstColumn || lastColumn ? constrained : child,
|
||||||
? null
|
|
||||||
: columnWidths[i] + _kDatePickerPadSize,
|
|
||||||
child: child,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -1453,7 +1453,8 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
|
|||||||
final List<Widget> pickers = <Widget>[];
|
final List<Widget> pickers = <Widget>[];
|
||||||
double totalColumnWidths = 4 * _kDatePickerPadSize;
|
double totalColumnWidths = 4 * _kDatePickerPadSize;
|
||||||
|
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (final (int i, double width) in columnWidths.indexed) {
|
||||||
|
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
|
||||||
final double offAxisFraction = (i - 1) * 0.3 * textDirectionFactor;
|
final double offAxisFraction = (i - 1) * 0.3 * textDirectionFactor;
|
||||||
|
|
||||||
EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
|
EdgeInsets padding = const EdgeInsets.only(right: _kDatePickerPadSize);
|
||||||
@ -1462,28 +1463,30 @@ class _CupertinoDatePickerDateState extends State<CupertinoDatePicker> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget selectionOverlay = _centerSelectionOverlay;
|
Widget selectionOverlay = _centerSelectionOverlay;
|
||||||
if (i == 0) {
|
if (firstColumn) {
|
||||||
selectionOverlay = _startSelectionOverlay;
|
selectionOverlay = _startSelectionOverlay;
|
||||||
} else if (i == columnWidths.length - 1) {
|
} else if (i == columnWidths.length - 1) {
|
||||||
selectionOverlay = _endSelectionOverlay;
|
selectionOverlay = _endSelectionOverlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
|
totalColumnWidths += width + (2 * _kDatePickerPadSize);
|
||||||
|
|
||||||
pickers.add(LayoutId(
|
pickers.add(LayoutId(
|
||||||
id: i,
|
id: i,
|
||||||
child: pickerBuilders[i](
|
child: pickerBuilders[i](
|
||||||
offAxisFraction,
|
offAxisFraction,
|
||||||
(BuildContext context, Widget? child) {
|
(BuildContext context, Widget? child) {
|
||||||
return Container(
|
return Padding(
|
||||||
alignment: i == columnWidths.length - 1
|
padding: firstColumn ? EdgeInsets.zero : padding,
|
||||||
? alignCenterLeft
|
child: Align(
|
||||||
: alignCenterRight,
|
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
|
||||||
padding: i == 0 ? null : padding,
|
child: SizedBox(
|
||||||
child: Container(
|
width: width + _kDatePickerPadSize,
|
||||||
alignment: i == 0 ? alignCenterLeft : alignCenterRight,
|
child: Align(
|
||||||
width: columnWidths[i] + _kDatePickerPadSize,
|
alignment: firstColumn ? alignCenterLeft : alignCenterRight,
|
||||||
child: child,
|
child: child,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@ -1763,33 +1766,39 @@ class _CupertinoDatePickerMonthYearState extends State<CupertinoDatePicker> {
|
|||||||
final List<Widget> pickers = <Widget>[];
|
final List<Widget> pickers = <Widget>[];
|
||||||
double totalColumnWidths = 3 * _kDatePickerPadSize;
|
double totalColumnWidths = 3 * _kDatePickerPadSize;
|
||||||
|
|
||||||
for (int i = 0; i < columnWidths.length; i++) {
|
for (final (int i, double width) in columnWidths.indexed) {
|
||||||
final (bool first, bool last) = (i == 0, i == columnWidths.length - 1);
|
final (bool firstColumn, bool lastColumn) = (i == 0, i == columnWidths.length - 1);
|
||||||
final double offAxisFraction = textDirectionFactor * (first ? -0.3 : 0.5);
|
final double offAxisFraction = textDirectionFactor * (firstColumn ? -0.3 : 0.5);
|
||||||
|
|
||||||
totalColumnWidths += columnWidths[i] + (2 * _kDatePickerPadSize);
|
totalColumnWidths += width + (2 * _kDatePickerPadSize);
|
||||||
|
|
||||||
pickers.add(LayoutId(
|
pickers.add(LayoutId(
|
||||||
id: i,
|
id: i,
|
||||||
child: pickerBuilders[i](
|
child: pickerBuilders[i](
|
||||||
offAxisFraction,
|
offAxisFraction,
|
||||||
(BuildContext context, Widget? child) {
|
(BuildContext context, Widget? child) {
|
||||||
return Container(
|
final Widget contents = Align(
|
||||||
alignment: last ? alignCenterLeft : alignCenterRight,
|
alignment: lastColumn ? alignCenterLeft : alignCenterRight,
|
||||||
padding: switch (textDirectionFactor) {
|
child: SizedBox(
|
||||||
_ when first => null,
|
width: width + _kDatePickerPadSize,
|
||||||
-1 => const EdgeInsets.only(left: _kDatePickerPadSize),
|
child: Align(
|
||||||
_ => const EdgeInsets.only(right: _kDatePickerPadSize),
|
alignment: firstColumn ? alignCenterLeft : alignCenterRight,
|
||||||
},
|
child: child,
|
||||||
child: Container(
|
),
|
||||||
alignment: first ? alignCenterLeft : alignCenterRight,
|
|
||||||
width: columnWidths[i] + _kDatePickerPadSize,
|
|
||||||
child: child,
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
if (firstColumn) {
|
||||||
|
return contents;
|
||||||
|
}
|
||||||
|
|
||||||
|
const EdgeInsets padding = EdgeInsets.only(right: _kDatePickerPadSize);
|
||||||
|
return Padding(
|
||||||
|
padding: textDirectionFactor == -1 ? padding.flipped : padding,
|
||||||
|
child: contents,
|
||||||
|
);
|
||||||
},
|
},
|
||||||
switch (last) {
|
switch (lastColumn) {
|
||||||
_ when first => _startSelectionOverlay,
|
_ when firstColumn => _startSelectionOverlay,
|
||||||
false => _centerSelectionOverlay,
|
false => _centerSelectionOverlay,
|
||||||
true => _endSelectionOverlay,
|
true => _endSelectionOverlay,
|
||||||
},
|
},
|
||||||
@ -2127,22 +2136,24 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
child: Container(
|
child: Padding(
|
||||||
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
|
|
||||||
padding: padding.resolve(textDirection),
|
padding: padding.resolve(textDirection),
|
||||||
child: SizedBox(
|
child: Align(
|
||||||
height: numberLabelHeight,
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
|
||||||
child: Baseline(
|
child: SizedBox(
|
||||||
baseline: numberLabelBaseline,
|
height: numberLabelHeight,
|
||||||
baselineType: TextBaseline.alphabetic,
|
child: Baseline(
|
||||||
child: Text(
|
baseline: numberLabelBaseline,
|
||||||
text,
|
baselineType: TextBaseline.alphabetic,
|
||||||
style: const TextStyle(
|
child: Text(
|
||||||
fontSize: _kTimerPickerLabelFontSize,
|
text,
|
||||||
fontWeight: FontWeight.w600,
|
style: const TextStyle(
|
||||||
|
fontSize: _kTimerPickerLabelFontSize,
|
||||||
|
fontWeight: FontWeight.w600,
|
||||||
|
),
|
||||||
|
maxLines: 1,
|
||||||
|
softWrap: false,
|
||||||
),
|
),
|
||||||
maxLines: 1,
|
|
||||||
softWrap: false,
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -2153,14 +2164,20 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
// The picker has to be wider than its content, since the separators
|
// The picker has to be wider than its content, since the separators
|
||||||
// are part of the picker.
|
// are part of the picker.
|
||||||
Widget _buildPickerNumberLabel(String text, EdgeInsetsDirectional padding) {
|
Widget _buildPickerNumberLabel(String text, EdgeInsetsDirectional padding) {
|
||||||
return Container(
|
return SizedBox(
|
||||||
width: _kTimerPickerColumnIntrinsicWidth + padding.horizontal,
|
width: _kTimerPickerColumnIntrinsicWidth + padding.horizontal,
|
||||||
padding: padding.resolve(textDirection),
|
child: Padding(
|
||||||
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
|
padding: padding.resolve(textDirection),
|
||||||
child: Container(
|
child: Align(
|
||||||
width: numberLabelWidth,
|
alignment: AlignmentDirectional.centerStart.resolve(textDirection),
|
||||||
alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
|
child: SizedBox(
|
||||||
child: Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible),
|
width: numberLabelWidth,
|
||||||
|
child: Align(
|
||||||
|
alignment: AlignmentDirectional.centerEnd.resolve(textDirection),
|
||||||
|
child: Text(text, softWrap: false, maxLines: 1, overflow: TextOverflow.visible),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -2508,9 +2525,23 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
),
|
),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget contents = SizedBox(
|
||||||
|
width: totalWidth,
|
||||||
|
height: _kPickerHeight,
|
||||||
|
child: DefaultTextStyle(
|
||||||
|
style: _textStyleFrom(context),
|
||||||
|
child: Row(children: columns.map((Widget child) => Expanded(child: child)).toList(growable: false)),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
final Color? color = CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context);
|
||||||
|
if (color != null) {
|
||||||
|
contents = ColoredBox(color: color, child: contents);
|
||||||
|
}
|
||||||
|
|
||||||
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
final CupertinoThemeData themeData = CupertinoTheme.of(context);
|
||||||
// The native iOS picker's text scaling is fixed, so we will also fix it
|
|
||||||
// as well in our picker.
|
// Text scaling is fixed to match the native iOS date picker.
|
||||||
return MediaQuery.withNoTextScaling(
|
return MediaQuery.withNoTextScaling(
|
||||||
child: CupertinoTheme(
|
child: CupertinoTheme(
|
||||||
data: themeData.copyWith(
|
data: themeData.copyWith(
|
||||||
@ -2518,18 +2549,7 @@ class _CupertinoTimerPickerState extends State<CupertinoTimerPicker> {
|
|||||||
pickerTextStyle: _textStyleFrom(context, _kTimerPickerMagnification),
|
pickerTextStyle: _textStyleFrom(context, _kTimerPickerMagnification),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: Align(
|
child: Align(alignment: widget.alignment, child: contents),
|
||||||
alignment: widget.alignment,
|
|
||||||
child: Container(
|
|
||||||
color: CupertinoDynamicColor.maybeResolve(widget.backgroundColor, context),
|
|
||||||
width: totalWidth,
|
|
||||||
height: _kPickerHeight,
|
|
||||||
child: DefaultTextStyle(
|
|
||||||
style: _textStyleFrom(context),
|
|
||||||
child: Row(children: columns.map((Widget child) => Expanded(child: child)).toList(growable: false)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -309,8 +309,9 @@ class _CupertinoAlertDialogState extends State<CupertinoAlertDialog> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildActions() {
|
Widget _buildActions() {
|
||||||
Widget actionSection = Container(
|
Widget actionSection = const LimitedBox(
|
||||||
height: 0.0,
|
maxWidth: 0,
|
||||||
|
child: SizedBox(width: double.infinity, height: 0),
|
||||||
);
|
);
|
||||||
if (widget.actions.isNotEmpty) {
|
if (widget.actions.isNotEmpty) {
|
||||||
actionSection = _CupertinoAlertActionSection(
|
actionSection = _CupertinoAlertActionSection(
|
||||||
@ -348,22 +349,24 @@ class _CupertinoAlertDialogState extends State<CupertinoAlertDialog> {
|
|||||||
removeBottom: true,
|
removeBottom: true,
|
||||||
context: context,
|
context: context,
|
||||||
child: Center(
|
child: Center(
|
||||||
child: Container(
|
child: Padding(
|
||||||
margin: const EdgeInsets.symmetric(vertical: _kDialogEdgePadding),
|
padding: const EdgeInsets.symmetric(vertical: _kDialogEdgePadding),
|
||||||
width: isInAccessibilityMode
|
child: SizedBox(
|
||||||
? _kAccessibilityCupertinoDialogWidth
|
width: isInAccessibilityMode
|
||||||
: _kCupertinoDialogWidth,
|
? _kAccessibilityCupertinoDialogWidth
|
||||||
child: CupertinoPopupSurface(
|
: _kCupertinoDialogWidth,
|
||||||
isSurfacePainted: false,
|
child: CupertinoPopupSurface(
|
||||||
child: Semantics(
|
isSurfacePainted: false,
|
||||||
namesRoute: true,
|
child: Semantics(
|
||||||
scopesRoute: true,
|
namesRoute: true,
|
||||||
explicitChildNodes: true,
|
scopesRoute: true,
|
||||||
label: localizations.alertDialogLabel,
|
explicitChildNodes: true,
|
||||||
child: _CupertinoDialogRenderWidget(
|
label: localizations.alertDialogLabel,
|
||||||
contentSection: _buildContent(context),
|
child: _CupertinoDialogRenderWidget(
|
||||||
actionsSection: _buildActions(),
|
contentSection: _buildContent(context),
|
||||||
dividerColor: CupertinoColors.separator,
|
actionsSection: _buildActions(),
|
||||||
|
dividerColor: CupertinoColors.separator,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -424,14 +427,18 @@ class CupertinoPopupSurface extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Widget? contents = child;
|
||||||
|
if (isSurfacePainted) {
|
||||||
|
contents = ColoredBox(
|
||||||
|
color: CupertinoDynamicColor.resolve(_kDialogColor, context),
|
||||||
|
child: contents,
|
||||||
|
);
|
||||||
|
}
|
||||||
return ClipRRect(
|
return ClipRRect(
|
||||||
borderRadius: const BorderRadius.all(Radius.circular(_kCornerRadius)),
|
borderRadius: const BorderRadius.all(Radius.circular(_kCornerRadius)),
|
||||||
child: BackdropFilter(
|
child: BackdropFilter(
|
||||||
filter: ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount),
|
filter: ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount),
|
||||||
child: Container(
|
child: contents,
|
||||||
color: isSurfacePainted ? CupertinoDynamicColor.resolve(_kDialogColor, context) : null,
|
|
||||||
child: child,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -596,8 +603,9 @@ class _CupertinoActionSheetState extends State<CupertinoActionSheet> {
|
|||||||
|
|
||||||
Widget _buildActions() {
|
Widget _buildActions() {
|
||||||
if (widget.actions == null || widget.actions!.isEmpty) {
|
if (widget.actions == null || widget.actions!.isEmpty) {
|
||||||
return Container(
|
return const LimitedBox(
|
||||||
height: 0.0,
|
maxWidth: 0,
|
||||||
|
child: SizedBox(width: double.infinity, height: 0),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return _CupertinoAlertActionSection(
|
return _CupertinoAlertActionSection(
|
||||||
@ -655,16 +663,18 @@ class _CupertinoActionSheetState extends State<CupertinoActionSheet> {
|
|||||||
label: 'Alert',
|
label: 'Alert',
|
||||||
child: CupertinoUserInterfaceLevel(
|
child: CupertinoUserInterfaceLevel(
|
||||||
data: CupertinoUserInterfaceLevelData.elevated,
|
data: CupertinoUserInterfaceLevelData.elevated,
|
||||||
child: Container(
|
child: Padding(
|
||||||
width: actionSheetWidth - _kActionSheetEdgeHorizontalPadding * 2,
|
padding: const EdgeInsets.symmetric(
|
||||||
margin: const EdgeInsets.symmetric(
|
|
||||||
horizontal: _kActionSheetEdgeHorizontalPadding,
|
horizontal: _kActionSheetEdgeHorizontalPadding,
|
||||||
vertical: _kActionSheetEdgeVerticalPadding,
|
vertical: _kActionSheetEdgeVerticalPadding,
|
||||||
),
|
),
|
||||||
child: Column(
|
child: SizedBox(
|
||||||
mainAxisSize: MainAxisSize.min,
|
width: actionSheetWidth - _kActionSheetEdgeHorizontalPadding * 2,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
child: Column(
|
||||||
children: children,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
|
children: children,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -731,8 +741,7 @@ class CupertinoActionSheetAction extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
button: true,
|
button: true,
|
||||||
child: Container(
|
child: Padding(
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
vertical: 16.0,
|
vertical: 16.0,
|
||||||
horizontal: 10.0,
|
horizontal: 10.0,
|
||||||
@ -740,7 +749,7 @@ class CupertinoActionSheetAction extends StatelessWidget {
|
|||||||
child: DefaultTextStyle(
|
child: DefaultTextStyle(
|
||||||
style: style,
|
style: style,
|
||||||
textAlign: TextAlign.center,
|
textAlign: TextAlign.center,
|
||||||
child: child,
|
child: Center(child: child),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1752,10 +1761,9 @@ class CupertinoDialogAction extends StatelessWidget {
|
|||||||
constraints: const BoxConstraints(
|
constraints: const BoxConstraints(
|
||||||
minHeight: _kDialogMinButtonHeight,
|
minHeight: _kDialogMinButtonHeight,
|
||||||
),
|
),
|
||||||
child: Container(
|
child: Padding(
|
||||||
alignment: Alignment.center,
|
|
||||||
padding: EdgeInsets.all(padding),
|
padding: EdgeInsets.all(padding),
|
||||||
child: sizedContent,
|
child: Center(child: sizedContent),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -558,7 +558,7 @@ class _CupertinoSliverRefreshControlState extends State<CupertinoSliverRefreshCo
|
|||||||
widget.refreshIndicatorExtent,
|
widget.refreshIndicatorExtent,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return Container();
|
return const LimitedBox(maxWidth: 0.0, maxHeight: 0.0, child: SizedBox.expand());
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -590,8 +590,8 @@ class _PackagesViewState extends State<_PackagesView> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
color: Theme.of(context).cardColor,
|
color: Theme.of(context).cardColor,
|
||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
child: Container(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
|
constraints: const BoxConstraints(maxWidth: 600.0),
|
||||||
child: _packagesList(context, selectedId, snapshot.data!, widget.isLateral),
|
child: _packagesList(context, selectedId, snapshot.data!, widget.isLateral),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -887,8 +887,8 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
|
|||||||
child: Material(
|
child: Material(
|
||||||
color: theme.cardColor,
|
color: theme.cardColor,
|
||||||
elevation: 4.0,
|
elevation: 4.0,
|
||||||
child: Container(
|
child: ConstrainedBox(
|
||||||
constraints: BoxConstraints.loose(const Size.fromWidth(600.0)),
|
constraints: const BoxConstraints(maxWidth: 600.0),
|
||||||
child: Localizations.override(
|
child: Localizations.override(
|
||||||
locale: const Locale('en', 'US'),
|
locale: const Locale('en', 'US'),
|
||||||
context: context,
|
context: context,
|
||||||
@ -1361,17 +1361,19 @@ class _MasterDetailScaffoldState extends State<_MasterDetailScaffold>
|
|||||||
preferredSize: const Size.fromHeight(kToolbarHeight),
|
preferredSize: const Size.fromHeight(kToolbarHeight),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
ConstrainedBox(
|
SizedBox(
|
||||||
constraints: BoxConstraints.tightFor(width: masterViewWidth),
|
width: masterViewWidth,
|
||||||
child: IconTheme(
|
child: IconTheme(
|
||||||
data: Theme.of(context).primaryIconTheme,
|
data: Theme.of(context).primaryIconTheme,
|
||||||
child: Container(
|
child: Padding(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: OverflowBar(
|
child: Align(
|
||||||
spacing: 8,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
overflowAlignment: OverflowBarAlignment.end,
|
child: OverflowBar(
|
||||||
children: widget.actionBuilder!(context, _ActionLevel.view),
|
spacing: 8,
|
||||||
|
overflowAlignment: OverflowBarAlignment.end,
|
||||||
|
children: widget.actionBuilder!(context, _ActionLevel.view),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1405,9 +1407,8 @@ class _MasterDetailScaffoldState extends State<_MasterDetailScaffold>
|
|||||||
child,
|
child,
|
||||||
),
|
),
|
||||||
duration: const Duration(milliseconds: 500),
|
duration: const Duration(milliseconds: 500),
|
||||||
child: Container(
|
child: SizedBox.expand(
|
||||||
key: ValueKey<Object?>(value ?? widget.initialArguments),
|
key: ValueKey<Object?>(value ?? widget.initialArguments),
|
||||||
constraints: const BoxConstraints.expand(),
|
|
||||||
child: _DetailView(
|
child: _DetailView(
|
||||||
builder: widget.detailPageBuilder,
|
builder: widget.detailPageBuilder,
|
||||||
arguments: value ?? widget.initialArguments,
|
arguments: value ?? widget.initialArguments,
|
||||||
|
@ -345,14 +345,18 @@ class _MaterialBannerState extends State<MaterialBanner> {
|
|||||||
?? bannerTheme.leadingPadding
|
?? bannerTheme.leadingPadding
|
||||||
?? const EdgeInsetsDirectional.only(end: 16.0);
|
?? const EdgeInsetsDirectional.only(end: 16.0);
|
||||||
|
|
||||||
final Widget actionsBar = Container(
|
final Widget actionsBar = ConstrainedBox(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
constraints: const BoxConstraints(minHeight: 52.0),
|
constraints: const BoxConstraints(minHeight: 52.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
child: Padding(
|
||||||
child: OverflowBar(
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
overflowAlignment: widget.overflowAlignment,
|
child: Align(
|
||||||
spacing: 8,
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
children: widget.actions,
|
child: OverflowBar(
|
||||||
|
overflowAlignment: widget.overflowAlignment,
|
||||||
|
spacing: 8,
|
||||||
|
children: widget.actions,
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -373,8 +377,8 @@ class _MaterialBannerState extends State<MaterialBanner> {
|
|||||||
?? bannerTheme.contentTextStyle
|
?? bannerTheme.contentTextStyle
|
||||||
?? defaults.contentTextStyle;
|
?? defaults.contentTextStyle;
|
||||||
|
|
||||||
Widget materialBanner = Container(
|
Widget materialBanner = Padding(
|
||||||
margin: margin,
|
padding: margin,
|
||||||
child: Material(
|
child: Material(
|
||||||
elevation: elevation,
|
elevation: elevation,
|
||||||
color: backgroundColor,
|
color: backgroundColor,
|
||||||
|
@ -784,7 +784,7 @@ class _Label extends StatelessWidget {
|
|||||||
text = Align(
|
text = Align(
|
||||||
alignment: Alignment.bottomCenter,
|
alignment: Alignment.bottomCenter,
|
||||||
heightFactor: 1.0,
|
heightFactor: 1.0,
|
||||||
child: Container(child: text),
|
child: text,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (item.label != null) {
|
if (item.label != null) {
|
||||||
|
@ -391,7 +391,7 @@ class _RawMaterialButtonState extends State<RawMaterialButton> with MaterialStat
|
|||||||
mouseCursor: effectiveMouseCursor,
|
mouseCursor: effectiveMouseCursor,
|
||||||
child: IconTheme.merge(
|
child: IconTheme.merge(
|
||||||
data: IconThemeData(color: effectiveTextColor),
|
data: IconThemeData(color: effectiveTextColor),
|
||||||
child: Container(
|
child: Padding(
|
||||||
padding: padding,
|
padding: padding,
|
||||||
child: Center(
|
child: Center(
|
||||||
widthFactor: 1.0,
|
widthFactor: 1.0,
|
||||||
|
@ -244,11 +244,12 @@ class ButtonBar extends StatelessWidget {
|
|||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
case ButtonBarLayoutBehavior.constrained:
|
case ButtonBarLayoutBehavior.constrained:
|
||||||
return Container(
|
return ConstrainedBox(
|
||||||
padding: EdgeInsets.symmetric(horizontal: paddingUnit),
|
|
||||||
constraints: const BoxConstraints(minHeight: 52.0),
|
constraints: const BoxConstraints(minHeight: 52.0),
|
||||||
alignment: Alignment.center,
|
child: Padding(
|
||||||
child: child,
|
padding: EdgeInsets.symmetric(horizontal: paddingUnit),
|
||||||
|
child: Center(child: child),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,52 +393,54 @@ class _DatePickerModeToggleButtonState extends State<_DatePickerModeToggleButton
|
|||||||
final TextTheme textTheme = Theme.of(context).textTheme;
|
final TextTheme textTheme = Theme.of(context).textTheme;
|
||||||
final Color controlColor = colorScheme.onSurface.withOpacity(0.60);
|
final Color controlColor = colorScheme.onSurface.withOpacity(0.60);
|
||||||
|
|
||||||
return Container(
|
return SizedBox(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
|
||||||
height: _subHeaderHeight,
|
height: _subHeaderHeight,
|
||||||
child: Row(
|
child: Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
||||||
Flexible(
|
child: Row(
|
||||||
child: Semantics(
|
children: <Widget>[
|
||||||
label: MaterialLocalizations.of(context).selectYearSemanticsLabel,
|
Flexible(
|
||||||
excludeSemantics: true,
|
child: Semantics(
|
||||||
button: true,
|
label: MaterialLocalizations.of(context).selectYearSemanticsLabel,
|
||||||
container: true,
|
excludeSemantics: true,
|
||||||
child: SizedBox(
|
button: true,
|
||||||
height: _subHeaderHeight,
|
container: true,
|
||||||
child: InkWell(
|
child: SizedBox(
|
||||||
onTap: widget.onTitlePressed,
|
height: _subHeaderHeight,
|
||||||
child: Padding(
|
child: InkWell(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
onTap: widget.onTitlePressed,
|
||||||
child: Row(
|
child: Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
Flexible(
|
child: Row(
|
||||||
child: Text(
|
children: <Widget>[
|
||||||
widget.title,
|
Flexible(
|
||||||
overflow: TextOverflow.ellipsis,
|
child: Text(
|
||||||
style: textTheme.titleSmall?.copyWith(
|
widget.title,
|
||||||
|
overflow: TextOverflow.ellipsis,
|
||||||
|
style: textTheme.titleSmall?.copyWith(
|
||||||
|
color: controlColor,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
RotationTransition(
|
||||||
|
turns: _controller,
|
||||||
|
child: Icon(
|
||||||
|
Icons.arrow_drop_down,
|
||||||
color: controlColor,
|
color: controlColor,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
RotationTransition(
|
),
|
||||||
turns: _controller,
|
|
||||||
child: Icon(
|
|
||||||
Icons.arrow_drop_down,
|
|
||||||
color: controlColor,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (widget.mode == DatePickerMode.day)
|
||||||
if (widget.mode == DatePickerMode.day)
|
// Give space for the prev/next month buttons that are underneath this row
|
||||||
// Give space for the prev/next month buttons that are underneath this row
|
const SizedBox(width: _monthNavButtonsWidth),
|
||||||
const SizedBox(width: _monthNavButtonsWidth),
|
],
|
||||||
],
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -755,25 +757,27 @@ class _MonthPickerState extends State<_MonthPicker> {
|
|||||||
return Semantics(
|
return Semantics(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
SizedBox(
|
||||||
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
|
||||||
height: _subHeaderHeight,
|
height: _subHeaderHeight,
|
||||||
child: Row(
|
child: Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsetsDirectional.only(start: 16, end: 4),
|
||||||
const Spacer(),
|
child: Row(
|
||||||
IconButton(
|
children: <Widget>[
|
||||||
icon: const Icon(Icons.chevron_left),
|
const Spacer(),
|
||||||
color: controlColor,
|
IconButton(
|
||||||
tooltip: _isDisplayingFirstMonth ? null : _localizations.previousMonthTooltip,
|
icon: const Icon(Icons.chevron_left),
|
||||||
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
|
color: controlColor,
|
||||||
),
|
tooltip: _isDisplayingFirstMonth ? null : _localizations.previousMonthTooltip,
|
||||||
IconButton(
|
onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth,
|
||||||
icon: const Icon(Icons.chevron_right),
|
),
|
||||||
color: controlColor,
|
IconButton(
|
||||||
tooltip: _isDisplayingLastMonth ? null : _localizations.nextMonthTooltip,
|
icon: const Icon(Icons.chevron_right),
|
||||||
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
|
color: controlColor,
|
||||||
),
|
tooltip: _isDisplayingLastMonth ? null : _localizations.nextMonthTooltip,
|
||||||
],
|
onPressed: _isDisplayingLastMonth ? null : _handleNextMonth,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Expanded(
|
Expanded(
|
||||||
@ -954,7 +958,7 @@ class _DayPickerState extends State<_DayPicker> {
|
|||||||
while (day < daysInMonth) {
|
while (day < daysInMonth) {
|
||||||
day++;
|
day++;
|
||||||
if (day < 1) {
|
if (day < 1) {
|
||||||
dayItems.add(Container());
|
dayItems.add(const SizedBox.shrink());
|
||||||
} else {
|
} else {
|
||||||
final DateTime dayToBuild = DateTime(year, month, day);
|
final DateTime dayToBuild = DateTime(year, month, day);
|
||||||
final bool isDisabled =
|
final bool isDisabled =
|
||||||
@ -1291,12 +1295,11 @@ class _YearPickerState extends State<YearPicker> {
|
|||||||
decoration: decoration,
|
decoration: decoration,
|
||||||
height: decorationHeight,
|
height: decorationHeight,
|
||||||
width: decorationWidth,
|
width: decorationWidth,
|
||||||
child: Center(
|
alignment: Alignment.center,
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
selected: isSelected,
|
selected: isSelected,
|
||||||
button: true,
|
button: true,
|
||||||
child: Text(year.toString(), style: itemStyle),
|
child: Text(year.toString(), style: itemStyle),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -224,8 +224,8 @@ class Card extends StatelessWidget {
|
|||||||
|
|
||||||
return Semantics(
|
return Semantics(
|
||||||
container: semanticContainer,
|
container: semanticContainer,
|
||||||
child: Container(
|
child: Padding(
|
||||||
margin: margin ?? cardTheme.margin ?? defaults.margin!,
|
padding: margin ?? cardTheme.margin ?? defaults.margin!,
|
||||||
child: Material(
|
child: Material(
|
||||||
type: MaterialType.card,
|
type: MaterialType.card,
|
||||||
color: color ?? cardTheme.color ?? defaults.color,
|
color: color ?? cardTheme.color ?? defaults.color,
|
||||||
|
@ -536,28 +536,32 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
|||||||
final Color? headerForegroundColor = datePickerTheme.headerForegroundColor ?? defaults.headerForegroundColor;
|
final Color? headerForegroundColor = datePickerTheme.headerForegroundColor ?? defaults.headerForegroundColor;
|
||||||
headlineStyle = headlineStyle?.copyWith(color: headerForegroundColor);
|
headlineStyle = headlineStyle?.copyWith(color: headerForegroundColor);
|
||||||
|
|
||||||
final Widget actions = Container(
|
final Widget actions = ConstrainedBox(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
constraints: const BoxConstraints(minHeight: 52.0),
|
constraints: const BoxConstraints(minHeight: 52.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
child: Padding(
|
||||||
child: OverflowBar(
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
spacing: 8,
|
child: Align(
|
||||||
children: <Widget>[
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
TextButton(
|
child: OverflowBar(
|
||||||
style: datePickerTheme.cancelButtonStyle ?? defaults.cancelButtonStyle,
|
spacing: 8,
|
||||||
onPressed: _handleCancel,
|
children: <Widget>[
|
||||||
child: Text(widget.cancelText ?? (
|
TextButton(
|
||||||
useMaterial3
|
style: datePickerTheme.cancelButtonStyle ?? defaults.cancelButtonStyle,
|
||||||
? localizations.cancelButtonLabel
|
onPressed: _handleCancel,
|
||||||
: localizations.cancelButtonLabel.toUpperCase()
|
child: Text(widget.cancelText ?? (
|
||||||
)),
|
useMaterial3
|
||||||
|
? localizations.cancelButtonLabel
|
||||||
|
: localizations.cancelButtonLabel.toUpperCase()
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
style: datePickerTheme.confirmButtonStyle ?? defaults.confirmButtonStyle,
|
||||||
|
onPressed: _handleOk,
|
||||||
|
child: Text(widget.confirmText ?? localizations.okButtonLabel),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextButton(
|
),
|
||||||
style: datePickerTheme.confirmButtonStyle ?? defaults.confirmButtonStyle,
|
|
||||||
onPressed: _handleOk,
|
|
||||||
child: Text(widget.confirmText ?? localizations.okButtonLabel),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -578,30 +582,32 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
|||||||
return Form(
|
return Form(
|
||||||
key: _formKey,
|
key: _formKey,
|
||||||
autovalidateMode: _autovalidateMode.value,
|
autovalidateMode: _autovalidateMode.value,
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
height: orientation == Orientation.portrait ? _inputFormPortraitHeight : _inputFormLandscapeHeight,
|
height: orientation == Orientation.portrait ? _inputFormPortraitHeight : _inputFormLandscapeHeight,
|
||||||
child: Shortcuts(
|
child: Padding(
|
||||||
shortcuts: _formShortcutMap,
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
child: Column(
|
child: Shortcuts(
|
||||||
children: <Widget>[
|
shortcuts: _formShortcutMap,
|
||||||
const Spacer(),
|
child: Column(
|
||||||
InputDatePickerFormField(
|
children: <Widget>[
|
||||||
initialDate: _selectedDate.value,
|
const Spacer(),
|
||||||
firstDate: widget.firstDate,
|
InputDatePickerFormField(
|
||||||
lastDate: widget.lastDate,
|
initialDate: _selectedDate.value,
|
||||||
onDateSubmitted: _handleDateChanged,
|
firstDate: widget.firstDate,
|
||||||
onDateSaved: _handleDateChanged,
|
lastDate: widget.lastDate,
|
||||||
selectableDayPredicate: widget.selectableDayPredicate,
|
onDateSubmitted: _handleDateChanged,
|
||||||
errorFormatText: widget.errorFormatText,
|
onDateSaved: _handleDateChanged,
|
||||||
errorInvalidText: widget.errorInvalidText,
|
selectableDayPredicate: widget.selectableDayPredicate,
|
||||||
fieldHintText: widget.fieldHintText,
|
errorFormatText: widget.errorFormatText,
|
||||||
fieldLabelText: widget.fieldLabelText,
|
errorInvalidText: widget.errorInvalidText,
|
||||||
keyboardType: widget.keyboardType,
|
fieldHintText: widget.fieldHintText,
|
||||||
autofocus: true,
|
fieldLabelText: widget.fieldLabelText,
|
||||||
),
|
keyboardType: widget.keyboardType,
|
||||||
const Spacer(),
|
autofocus: true,
|
||||||
],
|
),
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -1508,36 +1514,38 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> with Rest
|
|||||||
selectedStartDate: _selectedStart.value,
|
selectedStartDate: _selectedStart.value,
|
||||||
selectedEndDate: _selectedEnd.value,
|
selectedEndDate: _selectedEnd.value,
|
||||||
currentDate: widget.currentDate,
|
currentDate: widget.currentDate,
|
||||||
picker: Container(
|
picker: SizedBox(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 24),
|
|
||||||
height: orientation == Orientation.portrait
|
height: orientation == Orientation.portrait
|
||||||
? _inputFormPortraitHeight
|
? _inputFormPortraitHeight
|
||||||
: _inputFormLandscapeHeight,
|
: _inputFormLandscapeHeight,
|
||||||
child: Column(
|
child: Padding(
|
||||||
children: <Widget>[
|
padding: const EdgeInsets.symmetric(horizontal: 24),
|
||||||
const Spacer(),
|
child: Column(
|
||||||
_InputDateRangePicker(
|
children: <Widget>[
|
||||||
key: _inputPickerKey,
|
const Spacer(),
|
||||||
initialStartDate: _selectedStart.value,
|
_InputDateRangePicker(
|
||||||
initialEndDate: _selectedEnd.value,
|
key: _inputPickerKey,
|
||||||
firstDate: widget.firstDate,
|
initialStartDate: _selectedStart.value,
|
||||||
lastDate: widget.lastDate,
|
initialEndDate: _selectedEnd.value,
|
||||||
onStartDateChanged: _handleStartDateChanged,
|
firstDate: widget.firstDate,
|
||||||
onEndDateChanged: _handleEndDateChanged,
|
lastDate: widget.lastDate,
|
||||||
autofocus: true,
|
onStartDateChanged: _handleStartDateChanged,
|
||||||
autovalidate: _autoValidate.value,
|
onEndDateChanged: _handleEndDateChanged,
|
||||||
helpText: widget.helpText,
|
autofocus: true,
|
||||||
errorInvalidRangeText: widget.errorInvalidRangeText,
|
autovalidate: _autoValidate.value,
|
||||||
errorFormatText: widget.errorFormatText,
|
helpText: widget.helpText,
|
||||||
errorInvalidText: widget.errorInvalidText,
|
errorInvalidRangeText: widget.errorInvalidRangeText,
|
||||||
fieldStartHintText: widget.fieldStartHintText,
|
errorFormatText: widget.errorFormatText,
|
||||||
fieldEndHintText: widget.fieldEndHintText,
|
errorInvalidText: widget.errorInvalidText,
|
||||||
fieldStartLabelText: widget.fieldStartLabelText,
|
fieldStartHintText: widget.fieldStartHintText,
|
||||||
fieldEndLabelText: widget.fieldEndLabelText,
|
fieldEndHintText: widget.fieldEndHintText,
|
||||||
keyboardType: widget.keyboardType,
|
fieldStartLabelText: widget.fieldStartLabelText,
|
||||||
),
|
fieldEndLabelText: widget.fieldEndLabelText,
|
||||||
const Spacer(),
|
keyboardType: widget.keyboardType,
|
||||||
],
|
),
|
||||||
|
const Spacer(),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
onConfirm: _handleOk,
|
onConfirm: _handleOk,
|
||||||
@ -2157,11 +2165,11 @@ class _DayHeaders extends StatelessWidget {
|
|||||||
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
final MaterialLocalizations localizations = MaterialLocalizations.of(context);
|
||||||
final List<Widget> labels = _getDayHeaders(textStyle, localizations);
|
final List<Widget> labels = _getDayHeaders(textStyle, localizations);
|
||||||
|
|
||||||
// Add leading and trailing containers for edges of the custom grid layout.
|
// Add leading and trailing boxes for edges of the custom grid layout.
|
||||||
labels.insert(0, Container());
|
labels.insert(0, const SizedBox.shrink());
|
||||||
labels.add(Container());
|
labels.add(const SizedBox.shrink());
|
||||||
|
|
||||||
return Container(
|
return ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: MediaQuery.orientationOf(context) == Orientation.landscape
|
maxWidth: MediaQuery.orientationOf(context) == Orientation.landscape
|
||||||
? _maxCalendarWidthLandscape
|
? _maxCalendarWidthLandscape
|
||||||
@ -2428,8 +2436,9 @@ class _MonthItemState extends State<_MonthItem> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _buildEdgeContainer(BuildContext context, bool isHighlighted) {
|
Widget _buildEdgeBox(BuildContext context, bool isHighlighted) {
|
||||||
return Container(color: isHighlighted ? _highlightColor(context) : null);
|
const Widget empty = LimitedBox(maxWidth: 0.0, maxHeight: 0.0, child: SizedBox.expand());
|
||||||
|
return isHighlighted ? ColoredBox(color: _highlightColor(context), child: empty) : empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -2449,7 +2458,7 @@ class _MonthItemState extends State<_MonthItem> {
|
|||||||
// a leap year.
|
// a leap year.
|
||||||
for (int day = 0 - dayOffset + 1; day <= daysInMonth; day += 1) {
|
for (int day = 0 - dayOffset + 1; day <= daysInMonth; day += 1) {
|
||||||
if (day < 1) {
|
if (day < 1) {
|
||||||
dayItems.add(Container());
|
dayItems.add(const LimitedBox(maxWidth: 0.0, maxHeight: 0.0, child: SizedBox.expand()));
|
||||||
} else {
|
} else {
|
||||||
final DateTime dayToBuild = DateTime(year, month, day);
|
final DateTime dayToBuild = DateTime(year, month, day);
|
||||||
final Widget dayItem = _buildDayItem(
|
final Widget dayItem = _buildDayItem(
|
||||||
@ -2482,7 +2491,7 @@ class _MonthItemState extends State<_MonthItem> {
|
|||||||
widget.selectedDateEnd != null &&
|
widget.selectedDateEnd != null &&
|
||||||
dateAfterLeadingPadding.isAfter(widget.selectedDateStart!) &&
|
dateAfterLeadingPadding.isAfter(widget.selectedDateStart!) &&
|
||||||
!dateAfterLeadingPadding.isAfter(widget.selectedDateEnd!);
|
!dateAfterLeadingPadding.isAfter(widget.selectedDateEnd!);
|
||||||
weekList.insert(0, _buildEdgeContainer(context, isLeadingInRange));
|
weekList.insert(0, _buildEdgeBox(context, isLeadingInRange));
|
||||||
|
|
||||||
// Only add a trailing edge container if it is for a full week and not a
|
// Only add a trailing edge container if it is for a full week and not a
|
||||||
// partial week.
|
// partial week.
|
||||||
@ -2496,7 +2505,7 @@ class _MonthItemState extends State<_MonthItem> {
|
|||||||
widget.selectedDateEnd != null &&
|
widget.selectedDateEnd != null &&
|
||||||
!dateBeforeTrailingPadding.isBefore(widget.selectedDateStart!) &&
|
!dateBeforeTrailingPadding.isBefore(widget.selectedDateStart!) &&
|
||||||
dateBeforeTrailingPadding.isBefore(widget.selectedDateEnd!);
|
dateBeforeTrailingPadding.isBefore(widget.selectedDateEnd!);
|
||||||
weekList.add(_buildEdgeContainer(context, isTrailingInRange));
|
weekList.add(_buildEdgeBox(context, isTrailingInRange));
|
||||||
}
|
}
|
||||||
|
|
||||||
paddedDayItems.addAll(weekList);
|
paddedDayItems.addAll(weekList);
|
||||||
@ -2507,19 +2516,22 @@ class _MonthItemState extends State<_MonthItem> {
|
|||||||
: _maxCalendarWidthPortrait;
|
: _maxCalendarWidthPortrait;
|
||||||
return Column(
|
return Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Container(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints(maxWidth: maxWidth),
|
constraints: BoxConstraints(maxWidth: maxWidth).tighten(height: _monthItemHeaderHeight),
|
||||||
height: _monthItemHeaderHeight,
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
alignment: AlignmentDirectional.centerStart,
|
child: Align(
|
||||||
child: ExcludeSemantics(
|
alignment: AlignmentDirectional.centerStart,
|
||||||
child: Text(
|
child: ExcludeSemantics(
|
||||||
localizations.formatMonthYear(widget.displayedMonth),
|
child: Text(
|
||||||
style: textTheme.bodyMedium!.apply(color: themeData.colorScheme.onSurface),
|
localizations.formatMonthYear(widget.displayedMonth),
|
||||||
|
style: textTheme.bodyMedium!.apply(color: themeData.colorScheme.onSurface),
|
||||||
|
),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Container(
|
ConstrainedBox(
|
||||||
constraints: BoxConstraints(
|
constraints: BoxConstraints(
|
||||||
maxWidth: maxWidth,
|
maxWidth: maxWidth,
|
||||||
maxHeight: gridHeight,
|
maxHeight: gridHeight,
|
||||||
@ -2693,13 +2705,12 @@ class _DayItemState extends State<_DayItem> {
|
|||||||
|
|
||||||
Widget dayWidget = Container(
|
Widget dayWidget = Container(
|
||||||
decoration: decoration,
|
decoration: decoration,
|
||||||
child: Center(
|
alignment: Alignment.center,
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
label: semanticLabel,
|
label: semanticLabel,
|
||||||
selected: widget.isSelectedDayStart || widget.isSelectedDayEnd,
|
selected: widget.isSelectedDayStart || widget.isSelectedDayEnd,
|
||||||
child: ExcludeSemantics(
|
child: ExcludeSemantics(
|
||||||
child: Text(dayText, style: itemStyle),
|
child: Text(dayText, style: itemStyle),
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@ -2868,26 +2879,30 @@ class _InputDateRangePickerDialog extends StatelessWidget {
|
|||||||
entryModeButton: entryModeButton,
|
entryModeButton: entryModeButton,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Widget actions = Container(
|
final Widget actions = ConstrainedBox(
|
||||||
alignment: AlignmentDirectional.centerEnd,
|
|
||||||
constraints: const BoxConstraints(minHeight: 52.0),
|
constraints: const BoxConstraints(minHeight: 52.0),
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
child: Padding(
|
||||||
child: OverflowBar(
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
spacing: 8,
|
child: Align(
|
||||||
children: <Widget>[
|
alignment: AlignmentDirectional.centerEnd,
|
||||||
TextButton(
|
child: OverflowBar(
|
||||||
onPressed: onCancel,
|
spacing: 8,
|
||||||
child: Text(cancelText ?? (
|
children: <Widget>[
|
||||||
useMaterial3
|
TextButton(
|
||||||
? localizations.cancelButtonLabel
|
onPressed: onCancel,
|
||||||
: localizations.cancelButtonLabel.toUpperCase()
|
child: Text(cancelText ?? (
|
||||||
)),
|
useMaterial3
|
||||||
|
? localizations.cancelButtonLabel
|
||||||
|
: localizations.cancelButtonLabel.toUpperCase()
|
||||||
|
)),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: onConfirm,
|
||||||
|
child: Text(confirmText ?? localizations.okButtonLabel),
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
TextButton(
|
),
|
||||||
onPressed: onConfirm,
|
|
||||||
child: Text(confirmText ?? localizations.okButtonLabel),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
|||||||
behavior: HitTestBehavior.translucent,
|
behavior: HitTestBehavior.translucent,
|
||||||
excludeFromSemantics: true,
|
excludeFromSemantics: true,
|
||||||
dragStartBehavior: widget.dragStartBehavior,
|
dragStartBehavior: widget.dragStartBehavior,
|
||||||
child: Container(width: dragAreaWidth),
|
child: LimitedBox(maxHeight: 0.0, child: SizedBox(width: dragAreaWidth, height: double.infinity)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -701,6 +701,11 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
|||||||
platformHasBackButton = false;
|
platformHasBackButton = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget drawerScrim = const LimitedBox(maxWidth: 0.0, maxHeight: 0.0, child: SizedBox.expand());
|
||||||
|
if (_scrimColorTween.evaluate(_controller) case final Color color) {
|
||||||
|
drawerScrim = ColoredBox(color: color, child: drawerScrim);
|
||||||
|
}
|
||||||
|
|
||||||
final Widget child = _DrawerControllerScope(
|
final Widget child = _DrawerControllerScope(
|
||||||
controller: widget,
|
controller: widget,
|
||||||
child: RepaintBoundary(
|
child: RepaintBoundary(
|
||||||
@ -714,9 +719,7 @@ class DrawerControllerState extends State<DrawerController> with SingleTickerPro
|
|||||||
onTap: close,
|
onTap: close,
|
||||||
child: Semantics(
|
child: Semantics(
|
||||||
label: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
label: MaterialLocalizations.of(context).modalBarrierDismissLabel,
|
||||||
child: Container( // The drawer's "scrim"
|
child: drawerScrim,
|
||||||
color: _scrimColorTween.evaluate(_controller),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
@ -200,11 +200,11 @@ class _DropdownMenuItemButtonState<T> extends State<_DropdownMenuItemButton<T>>
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final DropdownMenuItem<T> dropdownMenuItem =
|
final DropdownMenuItem<T> dropdownMenuItem =
|
||||||
widget.route.items[widget.itemIndex].item!;
|
widget.route.items[widget.itemIndex].item!;
|
||||||
Widget child = Container(
|
Widget child = widget.route.items[widget.itemIndex];
|
||||||
padding: widget.padding,
|
if (widget.padding case final EdgeInsetsGeometry padding) {
|
||||||
height: widget.route.itemHeight,
|
child = Padding(padding: padding, child: child);
|
||||||
child: widget.route.items[widget.itemIndex],
|
}
|
||||||
);
|
child = SizedBox(height: widget.route.itemHeight, child: child);
|
||||||
// An [InkWell] is added to the item only if it is enabled
|
// An [InkWell] is added to the item only if it is enabled
|
||||||
if (dropdownMenuItem.enabled) {
|
if (dropdownMenuItem.enabled) {
|
||||||
child = InkWell(
|
child = InkWell(
|
||||||
@ -775,10 +775,9 @@ class _DropdownMenuItemContainer extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Container(
|
return ConstrainedBox(
|
||||||
constraints: const BoxConstraints(minHeight: _kMenuItemHeight),
|
constraints: const BoxConstraints(minHeight: _kMenuItemHeight),
|
||||||
alignment: alignment,
|
child: Align(alignment: alignment, child: child),
|
||||||
child: child,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1500,25 +1499,27 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> with WidgetsBindi
|
|||||||
|
|
||||||
Widget result = DefaultTextStyle(
|
Widget result = DefaultTextStyle(
|
||||||
style: _enabled ? _textStyle! : _textStyle!.copyWith(color: Theme.of(context).disabledColor),
|
style: _enabled ? _textStyle! : _textStyle!.copyWith(color: Theme.of(context).disabledColor),
|
||||||
child: Container(
|
child: SizedBox(
|
||||||
padding: padding.resolve(Directionality.of(context)),
|
|
||||||
height: widget.isDense ? _denseButtonHeight : null,
|
height: widget.isDense ? _denseButtonHeight : null,
|
||||||
child: Row(
|
child: Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
padding: padding.resolve(Directionality.of(context)),
|
||||||
mainAxisSize: MainAxisSize.min,
|
child: Row(
|
||||||
children: <Widget>[
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
if (widget.isExpanded)
|
mainAxisSize: MainAxisSize.min,
|
||||||
Expanded(child: innerItemsWidget)
|
children: <Widget>[
|
||||||
else
|
if (widget.isExpanded)
|
||||||
innerItemsWidget,
|
Expanded(child: innerItemsWidget)
|
||||||
IconTheme(
|
else
|
||||||
data: IconThemeData(
|
innerItemsWidget,
|
||||||
color: _iconColor,
|
IconTheme(
|
||||||
size: widget.iconSize,
|
data: IconThemeData(
|
||||||
|
color: _iconColor,
|
||||||
|
size: widget.iconSize,
|
||||||
|
),
|
||||||
|
child: widget.icon ?? defaultIcon,
|
||||||
),
|
),
|
||||||
child: widget.icon ?? defaultIcon,
|
],
|
||||||
),
|
),
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -789,7 +789,7 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
|
|||||||
hintText: widget.hintText,
|
hintText: widget.hintText,
|
||||||
helperText: widget.helperText,
|
helperText: widget.helperText,
|
||||||
errorText: widget.errorText,
|
errorText: widget.errorText,
|
||||||
prefixIcon: widget.leadingIcon != null ? Container(
|
prefixIcon: widget.leadingIcon != null ? SizedBox(
|
||||||
key: _leadingKey,
|
key: _leadingKey,
|
||||||
child: widget.leadingIcon
|
child: widget.leadingIcon
|
||||||
) : null,
|
) : null,
|
||||||
@ -816,11 +816,13 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
if (widget.expandedInsets != null) {
|
if (widget.expandedInsets case final EdgeInsets padding) {
|
||||||
menuAnchor = Container(
|
menuAnchor = Padding(
|
||||||
alignment: AlignmentDirectional.topStart,
|
padding: padding.copyWith(top: 0.0, bottom: 0.0),
|
||||||
padding: widget.expandedInsets?.copyWith(top: 0.0, bottom: 0.0),
|
child: Align(
|
||||||
child: menuAnchor,
|
alignment: AlignmentDirectional.topStart,
|
||||||
|
child: menuAnchor,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,10 +99,12 @@ void main() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Finder findStaticChildDecoration(WidgetTester tester) {
|
Finder findStaticChildColor(WidgetTester tester) {
|
||||||
return find.descendant(
|
return find.descendant(
|
||||||
of: findStatic(),
|
of: findStatic(),
|
||||||
matching: find.byType(DecoratedBox),
|
matching: find.byWidgetPredicate(
|
||||||
|
(Widget widget) => widget is ColoredBox && widget.color != CupertinoColors.activeOrange,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -496,7 +498,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(findStatic(), findsOneWidget);
|
expect(findStatic(), findsOneWidget);
|
||||||
|
|
||||||
expect(findStaticChildDecoration(tester), findsNWidgets(1));
|
expect(findStaticChildColor(tester), findsNWidgets(1));
|
||||||
|
|
||||||
// Close the CupertinoContextMenu.
|
// Close the CupertinoContextMenu.
|
||||||
await tester.tapAt(const Offset(1.0, 1.0));
|
await tester.tapAt(const Offset(1.0, 1.0));
|
||||||
@ -528,7 +530,7 @@ void main() {
|
|||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(findStatic(), findsOneWidget);
|
expect(findStatic(), findsOneWidget);
|
||||||
|
|
||||||
expect(findStaticChildDecoration(tester), findsNWidgets(3));
|
expect(findStaticChildColor(tester), findsNWidgets(2));
|
||||||
});
|
});
|
||||||
|
|
||||||
testWidgets('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async {
|
testWidgets('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async {
|
||||||
|
@ -18,12 +18,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.elevation, 1.0);
|
expect(material.elevation, 1.0);
|
||||||
expect(container.margin, const EdgeInsets.all(4.0));
|
expect(padding.padding, const EdgeInsets.all(4.0));
|
||||||
expect(material.color, colors.surfaceContainerLow);
|
expect(material.color, colors.surfaceContainerLow);
|
||||||
expect(material.shadowColor, colors.shadow);
|
expect(material.shadowColor, colors.shadow);
|
||||||
expect(material.surfaceTintColor, Colors.transparent); // Don't use surface tint. Toned surface container is used instead.
|
expect(material.surfaceTintColor, Colors.transparent); // Don't use surface tint. Toned surface container is used instead.
|
||||||
@ -42,12 +42,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(container.margin, const EdgeInsets.all(4.0));
|
expect(padding.padding, const EdgeInsets.all(4.0));
|
||||||
expect(material.color, colors.surfaceContainerHighest);
|
expect(material.color, colors.surfaceContainerHighest);
|
||||||
expect(material.shadowColor, colors.shadow);
|
expect(material.shadowColor, colors.shadow);
|
||||||
expect(material.surfaceTintColor, Colors.transparent);
|
expect(material.surfaceTintColor, Colors.transparent);
|
||||||
@ -66,12 +66,12 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
expect(material.elevation, 0.0);
|
expect(material.elevation, 0.0);
|
||||||
expect(container.margin, const EdgeInsets.all(4.0));
|
expect(padding.padding, const EdgeInsets.all(4.0));
|
||||||
expect(material.color, colors.surface);
|
expect(material.color, colors.surface);
|
||||||
expect(material.shadowColor, colors.shadow);
|
expect(material.shadowColor, colors.shadow);
|
||||||
expect(material.surfaceTintColor, Colors.transparent);
|
expect(material.surfaceTintColor, Colors.transparent);
|
||||||
@ -301,11 +301,11 @@ Material _getCardMaterial(WidgetTester tester) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Container _getCardContainer(WidgetTester tester) {
|
Padding _getCardPadding(WidgetTester tester) {
|
||||||
return tester.widget<Container>(
|
return tester.widget<Padding>(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: find.byType(Card),
|
of: find.byType(Card),
|
||||||
matching: find.byType(Container),
|
matching: find.byType(Padding),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
@ -39,7 +39,7 @@ void main() {
|
|||||||
expect(material.shadowColor, theme.colorScheme.shadow);
|
expect(material.shadowColor, theme.colorScheme.shadow);
|
||||||
expect(material.surfaceTintColor, Colors.transparent); // Default primary color
|
expect(material.surfaceTintColor, Colors.transparent); // Default primary color
|
||||||
expect(material.elevation, 1.0);
|
expect(material.elevation, 1.0);
|
||||||
expect(container.margin, const EdgeInsets.all(4.0));
|
expect(padding.padding, const EdgeInsets.all(4.0));
|
||||||
expect(material.shape, const RoundedRectangleBorder(
|
expect(material.shape, const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(12.0)),
|
borderRadius: BorderRadius.all(Radius.circular(12.0)),
|
||||||
));
|
));
|
||||||
@ -55,7 +55,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, cardTheme.clipBehavior);
|
expect(material.clipBehavior, cardTheme.clipBehavior);
|
||||||
@ -63,7 +63,7 @@ void main() {
|
|||||||
expect(material.shadowColor, cardTheme.shadowColor);
|
expect(material.shadowColor, cardTheme.shadowColor);
|
||||||
expect(material.surfaceTintColor, cardTheme.surfaceTintColor);
|
expect(material.surfaceTintColor, cardTheme.surfaceTintColor);
|
||||||
expect(material.elevation, cardTheme.elevation);
|
expect(material.elevation, cardTheme.elevation);
|
||||||
expect(container.margin, cardTheme.margin);
|
expect(padding.padding, cardTheme.margin);
|
||||||
expect(material.shape, cardTheme.shape);
|
expect(material.shape, cardTheme.shape);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -91,14 +91,14 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, clip);
|
expect(material.clipBehavior, clip);
|
||||||
expect(material.color, color);
|
expect(material.color, color);
|
||||||
expect(material.shadowColor, shadowColor);
|
expect(material.shadowColor, shadowColor);
|
||||||
expect(material.elevation, elevation);
|
expect(material.elevation, elevation);
|
||||||
expect(container.margin, margin);
|
expect(padding.padding, margin);
|
||||||
expect(material.shape, shape);
|
expect(material.shape, shape);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -187,7 +187,7 @@ void main() {
|
|||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Container container = _getCardContainer(tester);
|
final Padding padding = _getCardPadding(tester);
|
||||||
final Material material = _getCardMaterial(tester);
|
final Material material = _getCardMaterial(tester);
|
||||||
|
|
||||||
expect(material.clipBehavior, Clip.none);
|
expect(material.clipBehavior, Clip.none);
|
||||||
@ -195,7 +195,7 @@ void main() {
|
|||||||
expect(material.shadowColor, Colors.black);
|
expect(material.shadowColor, Colors.black);
|
||||||
expect(material.surfaceTintColor, null);
|
expect(material.surfaceTintColor, null);
|
||||||
expect(material.elevation, 1.0);
|
expect(material.elevation, 1.0);
|
||||||
expect(container.margin, const EdgeInsets.all(4.0));
|
expect(padding.padding, const EdgeInsets.all(4.0));
|
||||||
expect(material.shape, const RoundedRectangleBorder(
|
expect(material.shape, const RoundedRectangleBorder(
|
||||||
borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
borderRadius: BorderRadius.all(Radius.circular(4.0)),
|
||||||
));
|
));
|
||||||
@ -261,11 +261,11 @@ Material _getCardMaterial(WidgetTester tester) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Container _getCardContainer(WidgetTester tester) {
|
Padding _getCardPadding(WidgetTester tester) {
|
||||||
return tester.widget<Container>(
|
return tester.widget<Padding>(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: find.byType(Card),
|
of: find.byType(Card),
|
||||||
matching: find.byType(Container),
|
matching: find.byType(Padding),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -154,21 +154,18 @@ void main() {
|
|||||||
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
}, variant: TargetPlatformVariant.only(TargetPlatform.android));
|
||||||
|
|
||||||
testWidgets('Scaffold drawerScrimColor', (WidgetTester tester) async {
|
testWidgets('Scaffold drawerScrimColor', (WidgetTester tester) async {
|
||||||
// The scrim is a Container within a Semantics node labeled "Dismiss",
|
// The scrim is a ColoredBox within a Semantics node labeled "Dismiss",
|
||||||
// within a DrawerController. Sorry.
|
// within a DrawerController. Sorry.
|
||||||
Container getScrim() {
|
Widget getScrim() {
|
||||||
return tester.widget<Container>(
|
return tester.widget<Semantics>(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: find.descendant(
|
of: find.byType(DrawerController),
|
||||||
of: find.byType(DrawerController),
|
matching: find.byWidgetPredicate((Widget widget) {
|
||||||
matching: find.byWidgetPredicate((Widget widget) {
|
return widget is Semantics
|
||||||
return widget is Semantics
|
&& widget.properties.label == 'Dismiss';
|
||||||
&& widget.properties.label == 'Dismiss';
|
}),
|
||||||
}),
|
|
||||||
),
|
|
||||||
matching: find.byType(Container),
|
|
||||||
),
|
),
|
||||||
);
|
).child!;
|
||||||
}
|
}
|
||||||
|
|
||||||
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
@ -196,7 +193,8 @@ void main() {
|
|||||||
scaffoldKey.currentState!.openDrawer();
|
scaffoldKey.currentState!.openDrawer();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(getScrim().color, Colors.black54);
|
ColoredBox scrim = getScrim() as ColoredBox;
|
||||||
|
expect(scrim.color, Colors.black54);
|
||||||
|
|
||||||
await tester.tap(find.byType(Drawer));
|
await tester.tap(find.byType(Drawer));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
@ -208,7 +206,8 @@ void main() {
|
|||||||
scaffoldKey.currentState!.openDrawer();
|
scaffoldKey.currentState!.openDrawer();
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
expect(getScrim().color, const Color(0xFF323232));
|
scrim = getScrim() as ColoredBox;
|
||||||
|
expect(scrim.color, const Color(0xFF323232));
|
||||||
|
|
||||||
await tester.tap(find.byType(Drawer));
|
await tester.tap(find.byType(Drawer));
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
|
@ -312,8 +312,8 @@ Material _drawerMaterial(WidgetTester tester) {
|
|||||||
|
|
||||||
// The scrim is a Container within a Semantics node labeled "Dismiss",
|
// The scrim is a Container within a Semantics node labeled "Dismiss",
|
||||||
// within a DrawerController.
|
// within a DrawerController.
|
||||||
Container _scrim(WidgetTester tester) {
|
ColoredBox _scrim(WidgetTester tester) {
|
||||||
return tester.widget<Container>(
|
return tester.widget<ColoredBox>(
|
||||||
find.descendant(
|
find.descendant(
|
||||||
of: find.descendant(
|
of: find.descendant(
|
||||||
of: find.byType(DrawerController),
|
of: find.byType(DrawerController),
|
||||||
@ -322,7 +322,7 @@ Container _scrim(WidgetTester tester) {
|
|||||||
&& widget.properties.label == 'Dismiss';
|
&& widget.properties.label == 'Dismiss';
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
matching: find.byType(Container),
|
matching: find.byType(ColoredBox),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -442,7 +442,7 @@ void main() {
|
|||||||
label: const Text('label'),
|
label: const Text('label'),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Finder leadingIcon = find.widgetWithIcon(Container, Icons.search);
|
final Finder leadingIcon = find.widgetWithIcon(SizedBox, Icons.search).last;
|
||||||
final double iconWidth = tester.getSize(leadingIcon).width;
|
final double iconWidth = tester.getSize(leadingIcon).width;
|
||||||
final Finder updatedLabel = find.text('label');
|
final Finder updatedLabel = find.text('label');
|
||||||
final Offset updatedLabelTopLeft = tester.getTopLeft(updatedLabel);
|
final Offset updatedLabelTopLeft = tester.getTopLeft(updatedLabel);
|
||||||
@ -465,7 +465,7 @@ void main() {
|
|||||||
label: const Text('label'),
|
label: const Text('label'),
|
||||||
));
|
));
|
||||||
|
|
||||||
final Finder largeLeadingIcon = find.widgetWithIcon(Container, Icons.search);
|
final Finder largeLeadingIcon = find.widgetWithIcon(SizedBox, Icons.search).last;
|
||||||
final double largeIconWidth = tester.getSize(largeLeadingIcon).width;
|
final double largeIconWidth = tester.getSize(largeLeadingIcon).width;
|
||||||
final Finder updatedLabel1 = find.text('label');
|
final Finder updatedLabel1 = find.text('label');
|
||||||
final Offset updatedLabelTopLeft1 = tester.getTopLeft(updatedLabel1);
|
final Offset updatedLabelTopLeft1 = tester.getTopLeft(updatedLabel1);
|
||||||
@ -524,7 +524,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
final Finder leadingIcon = find.widgetWithIcon(Container, Icons.search);
|
final Finder leadingIcon = find.widgetWithIcon(SizedBox, Icons.search).last;
|
||||||
final double iconWidth = tester.getSize(leadingIcon).width;
|
final double iconWidth = tester.getSize(leadingIcon).width;
|
||||||
final Offset dropdownMenuTopRight = tester.getTopRight(find.byType(DropdownMenu<TestMenu>));
|
final Offset dropdownMenuTopRight = tester.getTopRight(find.byType(DropdownMenu<TestMenu>));
|
||||||
final Finder updatedLabel = find.text('label');
|
final Finder updatedLabel = find.text('label');
|
||||||
@ -556,7 +556,7 @@ void main() {
|
|||||||
));
|
));
|
||||||
await tester.pump();
|
await tester.pump();
|
||||||
|
|
||||||
final Finder largeLeadingIcon = find.widgetWithIcon(Container, Icons.search);
|
final Finder largeLeadingIcon = find.widgetWithIcon(SizedBox, Icons.search).last;
|
||||||
final double largeIconWidth = tester.getSize(largeLeadingIcon).width;
|
final double largeIconWidth = tester.getSize(largeLeadingIcon).width;
|
||||||
final Offset updatedDropdownMenuTopRight = tester.getTopRight(find.byType(DropdownMenu<TestMenu>));
|
final Offset updatedDropdownMenuTopRight = tester.getTopRight(find.byType(DropdownMenu<TestMenu>));
|
||||||
final Finder updatedLabel1 = find.text('label');
|
final Finder updatedLabel1 = find.text('label');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user