@@ -108,7 +108,7 @@ class Dialog extends StatelessWidget {
108
108
/// and a surface tint overlay on the background color if [surfaceTintColor] is
109
109
/// non null.
110
110
///
111
- /// If null then [DialogTheme .elevation] is used, and if that is null then
111
+ /// If null then [DialogThemeData .elevation] is used, and if that is null then
112
112
/// the elevation will match the Material Design specification for Dialogs.
113
113
///
114
114
/// See also:
@@ -197,7 +197,7 @@ class Dialog extends StatelessWidget {
197
197
/// See the enum [Clip] for details of all possible options and their common
198
198
/// use cases.
199
199
///
200
- /// If null, then [DialogTheme .clipBehavior] is used. If that is also null,
200
+ /// If null, then [DialogThemeData .clipBehavior] is used. If that is also null,
201
201
/// defaults to [Clip.none] .
202
202
/// {@endtemplate}
203
203
final Clip ? clipBehavior;
@@ -214,7 +214,7 @@ class Dialog extends StatelessWidget {
214
214
/// {@template flutter.material.dialog.alignment}
215
215
/// How to align the [Dialog] .
216
216
///
217
- /// If null, then [DialogTheme .alignment] is used. If that is also null, the
217
+ /// If null, then [DialogThemeData .alignment] is used. If that is also null, the
218
218
/// default is [Alignment.center] .
219
219
/// {@endtemplate}
220
220
final AlignmentGeometry ? alignment;
@@ -230,10 +230,10 @@ class Dialog extends StatelessWidget {
230
230
@override
231
231
Widget build (BuildContext context) {
232
232
final ThemeData theme = Theme .of (context);
233
- final DialogTheme dialogTheme = DialogTheme .of (context);
233
+ final DialogThemeData dialogTheme = DialogTheme .of (context).data ;
234
234
final EdgeInsets effectivePadding = MediaQuery .viewInsetsOf (context)
235
235
+ (insetPadding ?? dialogTheme.insetPadding ?? _defaultInsetPadding);
236
- final DialogTheme defaults = theme.useMaterial3
236
+ final DialogThemeData defaults = theme.useMaterial3
237
237
? (_fullscreen ? _DialogFullscreenDefaultsM3 (context) : _DialogDefaultsM3 (context))
238
238
: _DialogDefaultsM2 (context);
239
239
@@ -481,7 +481,7 @@ class AlertDialog extends StatelessWidget {
481
481
482
482
/// Color for the [Icon] in the [icon] of this [AlertDialog] .
483
483
///
484
- /// If null, [DialogTheme .iconColor] is used. If that is null, defaults to
484
+ /// If null, [DialogThemeData .iconColor] is used. If that is null, defaults to
485
485
/// color scheme's [ColorScheme.secondary] if [ThemeData.useMaterial3] is
486
486
/// true, black otherwise.
487
487
final Color ? iconColor;
@@ -519,7 +519,7 @@ class AlertDialog extends StatelessWidget {
519
519
520
520
/// Style for the text in the [title] of this [AlertDialog] .
521
521
///
522
- /// If null, [DialogTheme .titleTextStyle] is used. If that's null, defaults to
522
+ /// If null, [DialogThemeData .titleTextStyle] is used. If that's null, defaults to
523
523
/// [TextTheme.headlineSmall] of [ThemeData.textTheme] if
524
524
/// [ThemeData.useMaterial3] is true, [TextTheme.titleLarge] otherwise.
525
525
final TextStyle ? titleTextStyle;
@@ -554,7 +554,7 @@ class AlertDialog extends StatelessWidget {
554
554
555
555
/// Style for the text in the [content] of this [AlertDialog] .
556
556
///
557
- /// If null, [DialogTheme .contentTextStyle] is used. If that's null, defaults
557
+ /// If null, [DialogThemeData .contentTextStyle] is used. If that's null, defaults
558
558
/// to [TextTheme.bodyMedium] of [ThemeData.textTheme] if
559
559
/// [ThemeData.useMaterial3] is true, [TextTheme.titleMedium] otherwise.
560
560
final TextStyle ? contentTextStyle;
@@ -720,8 +720,8 @@ class AlertDialog extends StatelessWidget {
720
720
assert (debugCheckHasMaterialLocalizations (context));
721
721
final ThemeData theme = Theme .of (context);
722
722
723
- final DialogTheme dialogTheme = DialogTheme .of (context);
724
- final DialogTheme defaults = theme.useMaterial3 ? _DialogDefaultsM3 (context) : _DialogDefaultsM2 (context);
723
+ final DialogThemeData dialogTheme = DialogTheme .of (context).data ;
724
+ final DialogThemeData defaults = theme.useMaterial3 ? _DialogDefaultsM3 (context) : _DialogDefaultsM2 (context);
725
725
726
726
String ? label = semanticLabel;
727
727
switch (theme.platform) {
@@ -1155,7 +1155,7 @@ class SimpleDialog extends StatelessWidget {
1155
1155
1156
1156
/// Style for the text in the [title] of this [SimpleDialog] .
1157
1157
///
1158
- /// If null, [DialogTheme .titleTextStyle] is used. If that's null, defaults to
1158
+ /// If null, [DialogThemeData .titleTextStyle] is used. If that's null, defaults to
1159
1159
/// [TextTheme.titleLarge] of [ThemeData.textTheme] .
1160
1160
final TextStyle ? titleTextStyle;
1161
1161
@@ -1235,7 +1235,7 @@ class SimpleDialog extends StatelessWidget {
1235
1235
1236
1236
// The paddingScaleFactor is used to adjust the padding of Dialog
1237
1237
// children.
1238
- final TextStyle defaultTextStyle = titleTextStyle ?? DialogTheme .of (context).titleTextStyle ?? theme.textTheme.titleLarge! ;
1238
+ final TextStyle defaultTextStyle = titleTextStyle ?? DialogTheme .of (context).data. titleTextStyle ?? theme.textTheme.titleLarge! ;
1239
1239
final double fontSize = defaultTextStyle.fontSize ?? kDefaultFontSize;
1240
1240
final double fontSizeToScale = fontSize == 0.0 ? kDefaultFontSize : fontSize;
1241
1241
final double effectiveTextScale = MediaQuery .textScalerOf (context).scale (fontSizeToScale) / fontSizeToScale;
@@ -1342,7 +1342,7 @@ Widget _buildMaterialDialogTransitions(BuildContext context, Animation<double> a
1342
1342
///
1343
1343
/// The `barrierColor` argument is used to specify the color of the modal
1344
1344
/// barrier that darkens everything below the dialog. If `null` the `barrierColor`
1345
- /// field from `DialogTheme ` is used. If that is `null` the default color
1345
+ /// field from `DialogThemeData ` is used. If that is `null` the default color
1346
1346
/// `Colors.black54` is used.
1347
1347
///
1348
1348
/// The `useSafeArea` argument is used to indicate if the dialog should only
@@ -1443,7 +1443,10 @@ Future<T?> showDialog<T>({
1443
1443
return Navigator .of (context, rootNavigator: useRootNavigator).push <T >(DialogRoute <T >(
1444
1444
context: context,
1445
1445
builder: builder,
1446
- barrierColor: barrierColor ?? Theme .of (context).dialogTheme.barrierColor ?? Colors .black54,
1446
+ barrierColor: barrierColor
1447
+ ?? DialogTheme .of (context).barrierColor
1448
+ ?? Theme .of (context).dialogTheme.data.barrierColor
1449
+ ?? Colors .black54,
1447
1450
barrierDismissible: barrierDismissible,
1448
1451
barrierLabel: barrierLabel,
1449
1452
useSafeArea: useSafeArea,
@@ -1633,7 +1636,7 @@ double _scalePadding(double textScaleFactor) {
1633
1636
}
1634
1637
1635
1638
// Hand coded defaults based on Material Design 2.
1636
- class _DialogDefaultsM2 extends DialogTheme {
1639
+ class _DialogDefaultsM2 extends DialogThemeData {
1637
1640
_DialogDefaultsM2 (this .context)
1638
1641
: _textTheme = Theme .of (context).textTheme,
1639
1642
_iconTheme = Theme .of (context).iconTheme,
@@ -1674,7 +1677,7 @@ class _DialogDefaultsM2 extends DialogTheme {
1674
1677
// Design token database by the script:
1675
1678
// dev/tools/gen_defaults/bin/gen_defaults.dart.
1676
1679
1677
- class _DialogDefaultsM3 extends DialogTheme {
1680
+ class _DialogDefaultsM3 extends DialogThemeData {
1678
1681
_DialogDefaultsM3 (this .context)
1679
1682
: super (
1680
1683
alignment: Alignment .center,
@@ -1718,7 +1721,7 @@ class _DialogDefaultsM3 extends DialogTheme {
1718
1721
// Design token database by the script:
1719
1722
// dev/tools/gen_defaults/bin/gen_defaults.dart.
1720
1723
1721
- class _DialogFullscreenDefaultsM3 extends DialogTheme {
1724
+ class _DialogFullscreenDefaultsM3 extends DialogThemeData {
1722
1725
const _DialogFullscreenDefaultsM3 (this .context): super (clipBehavior: Clip .none);
1723
1726
1724
1727
final BuildContext context;
0 commit comments