Update ThemeData.dialogTheme
type to accept DialogThemeData
(#155129)
Following https://github.com/flutter/flutter/pull/153982, this PR is to normalize `ThemeData.dialogTheme`; change the `DialogTheme dialogTheme` property to `DialogThemeData dialogTheme` in ThemeData. In `ThemeData()` and `ThemeData.copyWith()`, the dialogTheme parameter type is changed to `Object?` to accept both `DialogTheme` and `DialogThemeData` so that we won't cause immediate breaking change and make sure rolling is smooth. Once all component themes are normalized, these `Object?` types should be changed to `xxxThemeData`. There's no way to create a dart fix because we can't add a "@deprecated" label for `DialogTheme`; `DialogTheme` is a new `InheritedWidget` subclass now. Addresses the "theme normalization" sub project within https://github.com/flutter/flutter/issues/91772
This commit is contained in:
parent
07745fb41f
commit
64906c28a6
@ -707,7 +707,7 @@ class _DatePickerDialogState extends State<DatePickerDialog> with RestorationMix
|
||||
// layout issues.
|
||||
final double textScaleFactor = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: _kMaxTextScaleFactor).scale(_fontSizeToScale) / _fontSizeToScale;
|
||||
final Size dialogSize = _dialogSize(context) * textScaleFactor;
|
||||
final DialogTheme dialogTheme = theme.dialogTheme;
|
||||
final DialogThemeData dialogTheme = theme.dialogTheme;
|
||||
return Dialog(
|
||||
backgroundColor: datePickerTheme.backgroundColor ?? defaults.backgroundColor,
|
||||
elevation: useMaterial3
|
||||
@ -1660,7 +1660,7 @@ class _DateRangePickerDialogState extends State<DateRangePickerDialog> with Rest
|
||||
: localizations.dateRangePickerHelpText.toUpperCase()
|
||||
),
|
||||
);
|
||||
final DialogTheme dialogTheme = theme.dialogTheme;
|
||||
final DialogThemeData dialogTheme = theme.dialogTheme;
|
||||
size = orientation == Orientation.portrait
|
||||
? (useMaterial3 ? _inputPortraitDialogSizeM3 : _inputPortraitDialogSizeM2)
|
||||
: _inputRangeLandscapeDialogSize;
|
||||
|
@ -230,7 +230,7 @@ class Dialog extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final ThemeData theme = Theme.of(context);
|
||||
final DialogThemeData dialogTheme = DialogTheme.of(context).data;
|
||||
final DialogThemeData dialogTheme = DialogTheme.of(context);
|
||||
final EdgeInsets effectivePadding = MediaQuery.viewInsetsOf(context)
|
||||
+ (insetPadding ?? dialogTheme.insetPadding ?? _defaultInsetPadding);
|
||||
final DialogThemeData defaults = theme.useMaterial3
|
||||
@ -720,7 +720,7 @@ class AlertDialog extends StatelessWidget {
|
||||
assert(debugCheckHasMaterialLocalizations(context));
|
||||
final ThemeData theme = Theme.of(context);
|
||||
|
||||
final DialogThemeData dialogTheme = DialogTheme.of(context).data;
|
||||
final DialogThemeData dialogTheme = DialogTheme.of(context);
|
||||
final DialogThemeData defaults = theme.useMaterial3 ? _DialogDefaultsM3(context) : _DialogDefaultsM2(context);
|
||||
|
||||
String? label = semanticLabel;
|
||||
@ -1235,7 +1235,7 @@ class SimpleDialog extends StatelessWidget {
|
||||
|
||||
// The paddingScaleFactor is used to adjust the padding of Dialog
|
||||
// children.
|
||||
final TextStyle defaultTextStyle = titleTextStyle ?? DialogTheme.of(context).data.titleTextStyle ?? theme.textTheme.titleLarge!;
|
||||
final TextStyle defaultTextStyle = titleTextStyle ?? DialogTheme.of(context).titleTextStyle ?? theme.textTheme.titleLarge!;
|
||||
final double fontSize = defaultTextStyle.fontSize ?? kDefaultFontSize;
|
||||
final double fontSizeToScale = fontSize == 0.0 ? kDefaultFontSize : fontSize;
|
||||
final double effectiveTextScale = MediaQuery.textScalerOf(context).scale(fontSizeToScale) / fontSizeToScale;
|
||||
@ -1445,7 +1445,7 @@ Future<T?> showDialog<T>({
|
||||
builder: builder,
|
||||
barrierColor: barrierColor
|
||||
?? DialogTheme.of(context).barrierColor
|
||||
?? Theme.of(context).dialogTheme.data.barrierColor
|
||||
?? Theme.of(context).dialogTheme.barrierColor
|
||||
?? Colors.black54,
|
||||
barrierDismissible: barrierDismissible,
|
||||
barrierLabel: barrierLabel,
|
||||
|
@ -190,9 +190,9 @@ class DialogTheme extends InheritedTheme with Diagnosticable {
|
||||
}
|
||||
|
||||
/// The [ThemeData.dialogTheme] property of the ambient [Theme].
|
||||
static DialogTheme of(BuildContext context) {
|
||||
static DialogThemeData of(BuildContext context) {
|
||||
final DialogTheme? dialogTheme = context.dependOnInheritedWidgetOfExactType<DialogTheme>();
|
||||
return dialogTheme ?? Theme.of(context).dialogTheme;
|
||||
return dialogTheme?.data ?? Theme.of(context).dialogTheme;
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -320,7 +320,8 @@ class ThemeData with Diagnosticable {
|
||||
ChipThemeData? chipTheme,
|
||||
DataTableThemeData? dataTableTheme,
|
||||
DatePickerThemeData? datePickerTheme,
|
||||
DialogTheme? dialogTheme,
|
||||
// TODO(QuncCccccc): Change the parameter type to DialogThemeData
|
||||
Object? dialogTheme,
|
||||
DividerThemeData? dividerTheme,
|
||||
DrawerThemeData? drawerTheme,
|
||||
DropdownMenuThemeData? dropdownMenuTheme,
|
||||
@ -497,7 +498,15 @@ class ThemeData with Diagnosticable {
|
||||
chipTheme ??= const ChipThemeData();
|
||||
dataTableTheme ??= const DataTableThemeData();
|
||||
datePickerTheme ??= const DatePickerThemeData();
|
||||
dialogTheme ??= const DialogTheme();
|
||||
// TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
|
||||
if (dialogTheme != null) {
|
||||
if (dialogTheme is DialogTheme) {
|
||||
dialogTheme = dialogTheme.data;
|
||||
} else if (dialogTheme is! DialogThemeData) {
|
||||
throw ArgumentError('dialogTheme must be either a DialogThemeData or a DialogTheme');
|
||||
}
|
||||
}
|
||||
dialogTheme ??= const DialogThemeData();
|
||||
dividerTheme ??= const DividerThemeData();
|
||||
drawerTheme ??= const DrawerThemeData();
|
||||
dropdownMenuTheme ??= const DropdownMenuThemeData();
|
||||
@ -590,7 +599,7 @@ class ThemeData with Diagnosticable {
|
||||
chipTheme: chipTheme,
|
||||
dataTableTheme: dataTableTheme,
|
||||
datePickerTheme: datePickerTheme,
|
||||
dialogTheme: dialogTheme,
|
||||
dialogTheme: dialogTheme as DialogThemeData,
|
||||
dividerTheme: dividerTheme,
|
||||
drawerTheme: drawerTheme,
|
||||
dropdownMenuTheme: dropdownMenuTheme,
|
||||
@ -1276,7 +1285,7 @@ class ThemeData with Diagnosticable {
|
||||
final DatePickerThemeData datePickerTheme;
|
||||
|
||||
/// A theme for customizing the shape of a dialog.
|
||||
final DialogTheme dialogTheme;
|
||||
final DialogThemeData dialogTheme;
|
||||
|
||||
/// A theme for customizing the color, thickness, and indents of [Divider]s,
|
||||
/// [VerticalDivider]s, etc.
|
||||
@ -1462,7 +1471,8 @@ class ThemeData with Diagnosticable {
|
||||
ChipThemeData? chipTheme,
|
||||
DataTableThemeData? dataTableTheme,
|
||||
DatePickerThemeData? datePickerTheme,
|
||||
DialogTheme? dialogTheme,
|
||||
// TODO(QuncCccccc): Change the parameter type to DialogThemeData
|
||||
Object? dialogTheme,
|
||||
DividerThemeData? dividerTheme,
|
||||
DrawerThemeData? drawerTheme,
|
||||
DropdownMenuThemeData? dropdownMenuTheme,
|
||||
@ -1510,6 +1520,15 @@ class ThemeData with Diagnosticable {
|
||||
ButtonBarThemeData? buttonBarTheme,
|
||||
}) {
|
||||
cupertinoOverrideTheme = cupertinoOverrideTheme?.noDefault();
|
||||
|
||||
// TODO(QuncCccccc): Clean this up once the type of `dialogTheme` is changed to `DialogThemeData`
|
||||
if (dialogTheme != null) {
|
||||
if (dialogTheme is DialogTheme) {
|
||||
dialogTheme = dialogTheme.data;
|
||||
} else if (dialogTheme is! DialogThemeData) {
|
||||
throw ArgumentError('dialogTheme must be either a DialogThemeData or a DialogTheme');
|
||||
}
|
||||
}
|
||||
return ThemeData.raw(
|
||||
// For the sanity of the reader, make sure these properties are in the same
|
||||
// order in every place that they are separated by section comments (e.g.
|
||||
@ -1571,7 +1590,7 @@ class ThemeData with Diagnosticable {
|
||||
chipTheme: chipTheme ?? this.chipTheme,
|
||||
dataTableTheme: dataTableTheme ?? this.dataTableTheme,
|
||||
datePickerTheme: datePickerTheme ?? this.datePickerTheme,
|
||||
dialogTheme: dialogTheme ?? this.dialogTheme,
|
||||
dialogTheme: dialogTheme as DialogThemeData? ?? this.dialogTheme,
|
||||
dividerTheme: dividerTheme ?? this.dividerTheme,
|
||||
drawerTheme: drawerTheme ?? this.drawerTheme,
|
||||
dropdownMenuTheme: dropdownMenuTheme ?? this.dropdownMenuTheme,
|
||||
@ -1764,7 +1783,7 @@ class ThemeData with Diagnosticable {
|
||||
chipTheme: ChipThemeData.lerp(a.chipTheme, b.chipTheme, t)!,
|
||||
dataTableTheme: DataTableThemeData.lerp(a.dataTableTheme, b.dataTableTheme, t),
|
||||
datePickerTheme: DatePickerThemeData.lerp(a.datePickerTheme, b.datePickerTheme, t),
|
||||
dialogTheme: DialogTheme.lerp(a.dialogTheme, b.dialogTheme, t),
|
||||
dialogTheme: DialogThemeData.lerp(a.dialogTheme, b.dialogTheme, t),
|
||||
dividerTheme: DividerThemeData.lerp(a.dividerTheme, b.dividerTheme, t),
|
||||
drawerTheme: DrawerThemeData.lerp(a.drawerTheme, b.drawerTheme, t)!,
|
||||
dropdownMenuTheme: DropdownMenuThemeData.lerp(a.dropdownMenuTheme, b.dropdownMenuTheme, t),
|
||||
@ -2062,7 +2081,7 @@ class ThemeData with Diagnosticable {
|
||||
properties.add(DiagnosticsProperty<ChipThemeData>('chipTheme', chipTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DataTableThemeData>('dataTableTheme', dataTableTheme, defaultValue: defaultData.dataTableTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DatePickerThemeData>('datePickerTheme', datePickerTheme, defaultValue: defaultData.datePickerTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DialogTheme>('dialogTheme', dialogTheme, defaultValue: defaultData.dialogTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DialogThemeData>('dialogTheme', dialogTheme, defaultValue: defaultData.dialogTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DividerThemeData>('dividerTheme', dividerTheme, defaultValue: defaultData.dividerTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DrawerThemeData>('drawerTheme', drawerTheme, defaultValue: defaultData.drawerTheme, level: DiagnosticLevel.debug));
|
||||
properties.add(DiagnosticsProperty<DropdownMenuThemeData>('dropdownMenuTheme', dropdownMenuTheme, defaultValue: defaultData.dropdownMenuTheme, level: DiagnosticLevel.debug));
|
||||
|
@ -603,7 +603,7 @@ void main() {
|
||||
expect(defaultDialogMaterial.elevation, datePickerDefaultDialogTheme.elevation);
|
||||
|
||||
// Test that it honors ThemeData.dialogTheme settings
|
||||
const DialogTheme customDialogTheme = DialogTheme(
|
||||
const DialogThemeData customDialogTheme = DialogThemeData(
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.all(Radius.circular(40.0)),
|
||||
),
|
||||
|
@ -244,13 +244,118 @@ void main() {
|
||||
expect(padding.padding, themeActionsPadding);
|
||||
});
|
||||
|
||||
testWidgets('Local DialogThemeData overrides global dialogTheme', (WidgetTester tester) async {
|
||||
const Color themeBackgroundColor = Color(0xff123456);
|
||||
const double themeElevation = 8.0;
|
||||
const Color themeShadowColor = Color(0xff000001);
|
||||
const Color themeSurfaceTintColor = Color(0xff000002);
|
||||
const BeveledRectangleBorder themeShape = BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(20.5)));
|
||||
const AlignmentGeometry themeAlignment = Alignment.bottomLeft;
|
||||
const Color themeIconColor = Color(0xff654321);
|
||||
const TextStyle themeTitleTextStyle = TextStyle(color: Color(0xffffffff));
|
||||
const TextStyle themeContentTextStyle = TextStyle(color: Color(0xff000000));
|
||||
const EdgeInsetsGeometry themeActionsPadding = EdgeInsets.all(8.0);
|
||||
const Color themeBarrierColor = Color(0xff000005);
|
||||
const EdgeInsets themeInsetPadding = EdgeInsets.all(30.0);
|
||||
const Clip themeClipBehavior = Clip.antiAlias;
|
||||
|
||||
const Color globalBackgroundColor = Color(0xff654321);
|
||||
const double globalElevation = 7.0;
|
||||
const Color globalShadowColor = Color(0xff200001);
|
||||
const Color globalSurfaceTintColor = Color(0xff222002);
|
||||
const BeveledRectangleBorder globalShape = BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(25.5)));
|
||||
const AlignmentGeometry globalAlignment = Alignment.centerRight;
|
||||
const Color globalIconColor = Color(0xff666666);
|
||||
const TextStyle globalTitleTextStyle = TextStyle(color: Color(0xff000000));
|
||||
const TextStyle globalContentTextStyle = TextStyle(color: Color(0xffdddddd));
|
||||
const EdgeInsetsGeometry globalActionsPadding = EdgeInsets.all(18.0);
|
||||
const Color globalBarrierColor = Color(0xff111115);
|
||||
const EdgeInsets globalInsetPadding = EdgeInsets.all(35.0);
|
||||
const Clip globalClipBehavior = Clip.hardEdge;
|
||||
const AlertDialog dialog = AlertDialog(
|
||||
title: Text('Title'),
|
||||
content: Text('Content'),
|
||||
icon: Icon(Icons.search),
|
||||
actions: <Widget>[
|
||||
Icon(Icons.cancel)
|
||||
],
|
||||
);
|
||||
|
||||
const DialogThemeData dialogTheme = DialogThemeData(
|
||||
backgroundColor: themeBackgroundColor,
|
||||
elevation: themeElevation,
|
||||
shadowColor: themeShadowColor,
|
||||
surfaceTintColor: themeSurfaceTintColor,
|
||||
shape: themeShape,
|
||||
alignment: themeAlignment,
|
||||
iconColor: themeIconColor,
|
||||
titleTextStyle: themeTitleTextStyle,
|
||||
contentTextStyle: themeContentTextStyle,
|
||||
actionsPadding: themeActionsPadding,
|
||||
barrierColor: themeBarrierColor,
|
||||
insetPadding: themeInsetPadding,
|
||||
clipBehavior: themeClipBehavior,
|
||||
);
|
||||
|
||||
const DialogThemeData globalDialogTheme = DialogThemeData(
|
||||
backgroundColor: globalBackgroundColor,
|
||||
elevation: globalElevation,
|
||||
shadowColor: globalShadowColor,
|
||||
surfaceTintColor: globalSurfaceTintColor,
|
||||
shape: globalShape,
|
||||
alignment: globalAlignment,
|
||||
iconColor: globalIconColor,
|
||||
titleTextStyle: globalTitleTextStyle,
|
||||
contentTextStyle: globalContentTextStyle,
|
||||
actionsPadding: globalActionsPadding,
|
||||
barrierColor: globalBarrierColor,
|
||||
insetPadding: globalInsetPadding,
|
||||
clipBehavior: globalClipBehavior,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(
|
||||
tester,
|
||||
dialog,
|
||||
dialogTheme: dialogTheme,
|
||||
theme: ThemeData(dialogTheme: globalDialogTheme),
|
||||
));
|
||||
await tester.tap(find.text('X'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final Material materialWidget = _getMaterialAlertDialog(tester);
|
||||
expect(materialWidget.color, themeBackgroundColor);
|
||||
expect(materialWidget.elevation, themeElevation);
|
||||
expect(materialWidget.shadowColor, themeShadowColor);
|
||||
expect(materialWidget.surfaceTintColor, themeSurfaceTintColor);
|
||||
expect(materialWidget.shape, themeShape);
|
||||
expect(materialWidget.clipBehavior, Clip.antiAlias);
|
||||
final Offset bottomLeft = tester.getBottomLeft(find.descendant(
|
||||
of: find.byType(Dialog),
|
||||
matching: find.byType(Material)
|
||||
));
|
||||
expect(bottomLeft.dx, 30.0); // 30 is the padding value.
|
||||
expect(bottomLeft.dy, 570.0); // 600 - 30
|
||||
expect(_getIconRenderObject(tester, Icons.search).text.style?.color, themeIconColor);
|
||||
expect(_getTextRenderObject(tester, 'Title').text.style?.color, themeTitleTextStyle.color);
|
||||
expect(_getTextRenderObject(tester, 'Content').text.style?.color, themeContentTextStyle.color);
|
||||
final ModalBarrier modalBarrier = tester.widget(find.byType(ModalBarrier).last);
|
||||
expect(modalBarrier.color, themeBarrierColor);
|
||||
|
||||
final Finder findPadding = find.ancestor(
|
||||
of: find.byIcon(Icons.cancel),
|
||||
matching: find.byType(Padding)
|
||||
).first;
|
||||
final Padding padding = tester.widget<Padding>(findPadding);
|
||||
expect(padding.padding, themeActionsPadding);
|
||||
});
|
||||
|
||||
testWidgets('Dialog background color', (WidgetTester tester) async {
|
||||
const Color customColor = Colors.pink;
|
||||
const AlertDialog dialog = AlertDialog(
|
||||
title: Text('Title'),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(backgroundColor: customColor));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(backgroundColor: customColor));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -269,7 +374,7 @@ void main() {
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(
|
||||
dialogTheme: const DialogTheme(
|
||||
dialogTheme: const DialogThemeData(
|
||||
elevation: customElevation,
|
||||
shadowColor: shadowColor,
|
||||
surfaceTintColor: surfaceTintColor,
|
||||
@ -295,7 +400,7 @@ void main() {
|
||||
title: Text('Title'),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(shape: customBorder));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(shape: customBorder));
|
||||
|
||||
await tester.pumpWidget(
|
||||
_appWithDialog(tester, dialog, theme: theme),
|
||||
@ -312,7 +417,7 @@ void main() {
|
||||
title: Text('Title'),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(alignment: Alignment.bottomLeft));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(alignment: Alignment.bottomLeft));
|
||||
|
||||
await tester.pumpWidget(
|
||||
_appWithDialog(tester, dialog, theme: theme),
|
||||
@ -335,7 +440,7 @@ void main() {
|
||||
);
|
||||
final ThemeData theme = ThemeData(
|
||||
useMaterial3: true,
|
||||
dialogTheme: const DialogTheme(alignment: Alignment.bottomLeft),
|
||||
dialogTheme: const DialogThemeData(alignment: Alignment.bottomLeft),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -359,7 +464,7 @@ void main() {
|
||||
actions: <Widget>[ ],
|
||||
alignment: Alignment.topRight,
|
||||
);
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, dialogTheme: const DialogTheme(alignment: Alignment.bottomLeft));
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, dialogTheme: const DialogThemeData(alignment: Alignment.bottomLeft));
|
||||
|
||||
await tester.pumpWidget(
|
||||
_appWithDialog(tester, dialog, theme: theme),
|
||||
@ -383,7 +488,7 @@ void main() {
|
||||
);
|
||||
final ThemeData theme = ThemeData(
|
||||
useMaterial3: true,
|
||||
dialogTheme: const DialogTheme(shape: customBorder),
|
||||
dialogTheme: const DialogThemeData(shape: customBorder),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
@ -403,7 +508,7 @@ void main() {
|
||||
title: Text('Title'),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, dialogTheme: const DialogTheme(shape: customBorder));
|
||||
final ThemeData theme = ThemeData(useMaterial3: false, dialogTheme: const DialogThemeData(shape: customBorder));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -419,7 +524,7 @@ void main() {
|
||||
const Color iconColor = Colors.pink, dialogThemeColor = Colors.green, iconThemeColor = Colors.yellow;
|
||||
final ThemeData theme = ThemeData(
|
||||
iconTheme: const IconThemeData(color: iconThemeColor),
|
||||
dialogTheme: const DialogTheme(iconColor: dialogThemeColor),
|
||||
dialogTheme: const DialogThemeData(iconColor: dialogThemeColor),
|
||||
);
|
||||
const AlertDialog dialog = AlertDialog(
|
||||
icon: Icon(Icons.ac_unit),
|
||||
@ -440,7 +545,7 @@ void main() {
|
||||
const Color dialogThemeColor = Colors.green, iconThemeColor = Colors.yellow;
|
||||
final ThemeData theme = ThemeData(
|
||||
iconTheme: const IconThemeData(color: iconThemeColor),
|
||||
dialogTheme: const DialogTheme(iconColor: dialogThemeColor),
|
||||
dialogTheme: const DialogThemeData(iconColor: dialogThemeColor),
|
||||
);
|
||||
const AlertDialog dialog = AlertDialog(
|
||||
icon: Icon(Icons.ac_unit),
|
||||
@ -513,7 +618,7 @@ void main() {
|
||||
title: Text(titleText),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(titleTextStyle: titleTextStyle));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(titleTextStyle: titleTextStyle));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -573,7 +678,7 @@ void main() {
|
||||
const SimpleDialog dialog = SimpleDialog(
|
||||
title: Text(titleText),
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(titleTextStyle: titleTextStyle));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(titleTextStyle: titleTextStyle));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -623,7 +728,7 @@ void main() {
|
||||
content: Text(contentText),
|
||||
actions: <Widget>[ ],
|
||||
);
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(contentTextStyle: contentTextStyle));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(contentTextStyle: contentTextStyle));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -664,7 +769,7 @@ void main() {
|
||||
testWidgets('Custom barrierColor - Theme', (WidgetTester tester) async {
|
||||
const Color barrierColor = Colors.blue;
|
||||
const SimpleDialog dialog = SimpleDialog();
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogTheme(barrierColor: barrierColor));
|
||||
final ThemeData theme = ThemeData(dialogTheme: const DialogThemeData(barrierColor: barrierColor));
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(tester, dialog, theme: theme));
|
||||
await tester.tap(find.text('X'));
|
||||
@ -677,7 +782,7 @@ void main() {
|
||||
testWidgets('DialogTheme.insetPadding updates Dialog insetPadding', (WidgetTester tester) async {
|
||||
// The default testing screen (800, 600)
|
||||
const Rect screenRect = Rect.fromLTRB(0.0, 0.0, 800.0, 600.0);
|
||||
const DialogTheme dialogTheme = DialogTheme(
|
||||
const DialogThemeData dialogTheme = DialogThemeData(
|
||||
insetPadding: EdgeInsets.fromLTRB(10, 15, 20, 25)
|
||||
);
|
||||
const Dialog dialog = Dialog(child: Placeholder());
|
||||
@ -702,7 +807,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('DialogTheme.clipBehavior updates the dialogs clip behavior', (WidgetTester tester) async {
|
||||
const DialogTheme dialogTheme = DialogTheme(clipBehavior: Clip.hardEdge);
|
||||
const DialogThemeData dialogTheme = DialogThemeData(clipBehavior: Clip.hardEdge);
|
||||
const Dialog dialog = Dialog(child: Placeholder());
|
||||
|
||||
await tester.pumpWidget(_appWithDialog(
|
||||
@ -723,7 +828,7 @@ void main() {
|
||||
child: Placeholder(),
|
||||
);
|
||||
final ThemeData theme = ThemeData(
|
||||
dialogTheme: const DialogTheme(clipBehavior: Clip.hardEdge),
|
||||
dialogTheme: const DialogThemeData(clipBehavior: Clip.hardEdge),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@ -743,7 +848,7 @@ void main() {
|
||||
);
|
||||
final ThemeData theme = ThemeData(
|
||||
useMaterial3: false,
|
||||
dialogTheme: const DialogTheme(clipBehavior: Clip.hardEdge),
|
||||
dialogTheme: const DialogThemeData(clipBehavior: Clip.hardEdge),
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
|
@ -893,7 +893,7 @@ void main() {
|
||||
chipTheme: chipTheme,
|
||||
dataTableTheme: const DataTableThemeData(),
|
||||
datePickerTheme: const DatePickerThemeData(),
|
||||
dialogTheme: const DialogTheme(backgroundColor: Colors.black),
|
||||
dialogTheme: const DialogThemeData(backgroundColor: Colors.black),
|
||||
dividerTheme: const DividerThemeData(color: Colors.black),
|
||||
drawerTheme: const DrawerThemeData(),
|
||||
dropdownMenuTheme: const DropdownMenuThemeData(),
|
||||
@ -1007,7 +1007,7 @@ void main() {
|
||||
chipTheme: otherChipTheme,
|
||||
dataTableTheme: const DataTableThemeData(),
|
||||
datePickerTheme: const DatePickerThemeData(backgroundColor: Colors.amber),
|
||||
dialogTheme: const DialogTheme(backgroundColor: Colors.white),
|
||||
dialogTheme: const DialogThemeData(backgroundColor: Colors.white),
|
||||
dividerTheme: const DividerThemeData(color: Colors.white),
|
||||
drawerTheme: const DrawerThemeData(),
|
||||
dropdownMenuTheme: const DropdownMenuThemeData(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user