@@ -31,6 +31,12 @@ const EdgeInsets _defaultInsetPadding = EdgeInsets.symmetric(horizontal: 40.0, v
3131/// or [SimpleDialog] , which implement specific kinds of Material Design
3232/// dialogs.
3333///
34+ /// {@tool dartpad}
35+ /// This sample shows the creation of [Dialog] and [Dialog.fullscreen] widgets.
36+ ///
37+ /// ** See code in examples/api/lib/material/dialog/dialog.0.dart **
38+ /// {@end-tool}
39+ ///
3440/// See also:
3541///
3642/// * [AlertDialog] , for dialogs that have a message and some buttons.
@@ -55,7 +61,26 @@ class Dialog extends StatelessWidget {
5561 this .alignment,
5662 this .child,
5763 }) : assert (clipBehavior != null ),
58- assert (elevation == null || elevation >= 0.0 );
64+ assert (elevation == null || elevation >= 0.0 ),
65+ _fullscreen = false ;
66+
67+ /// Creates a fullscreen dialog.
68+ ///
69+ /// Typically used in conjunction with [showDialog] .
70+ const Dialog .fullscreen ({
71+ super .key,
72+ this .backgroundColor,
73+ this .insetAnimationDuration = Duration .zero,
74+ this .insetAnimationCurve = Curves .decelerate,
75+ this .child,
76+ }) : elevation = 0 ,
77+ shadowColor = null ,
78+ surfaceTintColor = null ,
79+ insetPadding = EdgeInsets .zero,
80+ clipBehavior = Clip .none,
81+ shape = null ,
82+ alignment = null ,
83+ _fullscreen = true ;
5984
6085 /// {@template flutter.material.dialog.backgroundColor}
6186 /// The background color of the surface of this [Dialog] .
@@ -130,7 +155,8 @@ class Dialog extends StatelessWidget {
130155 /// The duration of the animation to show when the system keyboard intrudes
131156 /// into the space that the dialog is placed in.
132157 ///
133- /// Defaults to 100 milliseconds.
158+ /// Defaults to 100 milliseconds when [Dialog] is used, and [Duration.zero]
159+ /// when [Dialog.fullscreen] is used.
134160 /// {@endtemplate}
135161 final Duration insetAnimationDuration;
136162
@@ -184,13 +210,44 @@ class Dialog extends StatelessWidget {
184210 /// {@macro flutter.widgets.ProxyWidget.child}
185211 final Widget ? child;
186212
213+ /// This value is used to determine if this is a fullscreen dialog.
214+ final bool _fullscreen;
215+
187216 @override
188217 Widget build (BuildContext context) {
189218 final ThemeData theme = Theme .of (context);
190219 final DialogTheme dialogTheme = DialogTheme .of (context);
191- final DialogTheme defaults = theme.useMaterial3 ? _DialogDefaultsM3 (context) : _DialogDefaultsM2 (context);
192-
193220 final EdgeInsets effectivePadding = MediaQuery .of (context).viewInsets + (insetPadding ?? EdgeInsets .zero);
221+ final DialogTheme defaults = theme.useMaterial3
222+ ? (_fullscreen ? _DialogFullscreenDefaultsM3 (context) : _DialogDefaultsM3 (context))
223+ : _DialogDefaultsM2 (context);
224+
225+ Widget dialogChild;
226+
227+ if (_fullscreen) {
228+ dialogChild = Material (
229+ color: backgroundColor ?? dialogTheme.backgroundColor ?? defaults.backgroundColor,
230+ child: child,
231+ );
232+ } else {
233+ dialogChild = Align (
234+ alignment: alignment ?? dialogTheme.alignment ?? defaults.alignment! ,
235+ child: ConstrainedBox (
236+ constraints: const BoxConstraints (minWidth: 280.0 ),
237+ child: Material (
238+ color: backgroundColor ?? dialogTheme.backgroundColor ?? Theme .of (context).dialogBackgroundColor,
239+ elevation: elevation ?? dialogTheme.elevation ?? defaults.elevation! ,
240+ shadowColor: shadowColor ?? dialogTheme.shadowColor ?? defaults.shadowColor,
241+ surfaceTintColor: surfaceTintColor ?? dialogTheme.surfaceTintColor ?? defaults.surfaceTintColor,
242+ shape: shape ?? dialogTheme.shape ?? defaults.shape! ,
243+ type: MaterialType .card,
244+ clipBehavior: clipBehavior,
245+ child: child,
246+ ),
247+ ),
248+ );
249+ }
250+
194251 return AnimatedPadding (
195252 padding: effectivePadding,
196253 duration: insetAnimationDuration,
@@ -201,22 +258,7 @@ class Dialog extends StatelessWidget {
201258 removeRight: true ,
202259 removeBottom: true ,
203260 context: context,
204- child: Align (
205- alignment: alignment ?? dialogTheme.alignment ?? defaults.alignment! ,
206- child: ConstrainedBox (
207- constraints: const BoxConstraints (minWidth: 280.0 ),
208- child: Material (
209- color: backgroundColor ?? dialogTheme.backgroundColor ?? Theme .of (context).dialogBackgroundColor,
210- elevation: elevation ?? dialogTheme.elevation ?? defaults.elevation! ,
211- shadowColor: shadowColor ?? dialogTheme.shadowColor ?? defaults.shadowColor,
212- surfaceTintColor: surfaceTintColor ?? dialogTheme.surfaceTintColor ?? defaults.surfaceTintColor,
213- shape: shape ?? dialogTheme.shape ?? defaults.shape! ,
214- type: MaterialType .card,
215- clipBehavior: clipBehavior,
216- child: child,
217- ),
218- ),
219- ),
261+ child: dialogChild,
220262 ),
221263 );
222264 }
@@ -1426,3 +1468,23 @@ class _DialogDefaultsM3 extends DialogTheme {
14261468}
14271469
14281470// END GENERATED TOKEN PROPERTIES - Dialog
1471+
1472+ // BEGIN GENERATED TOKEN PROPERTIES - DialogFullscreen
1473+
1474+ // Do not edit by hand. The code between the "BEGIN GENERATED" and
1475+ // "END GENERATED" comments are generated from data in the Material
1476+ // Design token database by the script:
1477+ // dev/tools/gen_defaults/bin/gen_defaults.dart.
1478+
1479+ // Token database version: v0_132
1480+
1481+ class _DialogFullscreenDefaultsM3 extends DialogTheme {
1482+ const _DialogFullscreenDefaultsM3 (this .context);
1483+
1484+ final BuildContext context;
1485+
1486+ @override
1487+ Color ? get backgroundColor => Theme .of (context).colorScheme.surface;
1488+ }
1489+
1490+ // END GENERATED TOKEN PROPERTIES - DialogFullscreen
0 commit comments