Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
7a83c6fc
Unverified
Commit
7a83c6fc
authored
Feb 20, 2020
by
Darren Austin
Committed by
GitHub
Feb 20, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose insetPadding and clipBehavior in Dialog and AlertDialog. (#50775)
parent
85b54d4c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
95 additions
and
2 deletions
+95
-2
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+40
-2
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+55
-0
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
7a83c6fc
...
...
@@ -26,6 +26,8 @@ import 'theme_data.dart';
// enum Department { treasury, state }
// BuildContext context;
const
EdgeInsets
_defaultInsetPadding
=
EdgeInsets
.
symmetric
(
horizontal:
40.0
,
vertical:
24.0
);
/// A material design dialog.
///
/// This dialog widget does not have any opinion about the contents of the
...
...
@@ -49,9 +51,12 @@ class Dialog extends StatelessWidget {
this
.
elevation
,
this
.
insetAnimationDuration
=
const
Duration
(
milliseconds:
100
),
this
.
insetAnimationCurve
=
Curves
.
decelerate
,
this
.
insetPadding
=
_defaultInsetPadding
,
this
.
clipBehavior
=
Clip
.
none
,
this
.
shape
,
this
.
child
,
})
:
super
(
key:
key
);
})
:
assert
(
clipBehavior
!=
null
),
super
(
key:
key
);
/// {@template flutter.material.dialog.backgroundColor}
/// The background color of the surface of this [Dialog].
...
...
@@ -87,6 +92,26 @@ class Dialog extends StatelessWidget {
/// {@endtemplate}
final
Curve
insetAnimationCurve
;
/// {@template flutter.material.dialog.insetPadding}
/// The amount of padding added to [MediaQueryData.viewInsets] on the outside
/// of the dialog. This defines the minimum space between the screen's edges
/// and the dialog.
///
/// Defaults to `EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0)`.
/// {@endtemplate}
final
EdgeInsets
insetPadding
;
/// {@template flutter.material.dialog.clipBehavior}
/// Controls how the contents of the dialog are clipped (or not) to the given
/// [shape].
///
/// See the enum [Clip] for details of all possible options and their common
/// use cases.
///
/// Defaults to [Clip.none], and must not be null.
/// {@endtemplate}
final
Clip
clipBehavior
;
/// {@template flutter.material.dialog.shape}
/// The shape of this dialog's border.
///
...
...
@@ -109,8 +134,9 @@ class Dialog extends StatelessWidget {
@override
Widget
build
(
BuildContext
context
)
{
final
DialogTheme
dialogTheme
=
DialogTheme
.
of
(
context
);
final
EdgeInsets
effectivePadding
=
MediaQuery
.
of
(
context
).
viewInsets
+
(
insetPadding
??
const
EdgeInsets
.
all
(
0.0
));
return
AnimatedPadding
(
padding:
MediaQuery
.
of
(
context
).
viewInsets
+
const
EdgeInsets
.
symmetric
(
horizontal:
40.0
,
vertical:
24.0
)
,
padding:
effectivePadding
,
duration:
insetAnimationDuration
,
curve:
insetAnimationCurve
,
child:
MediaQuery
.
removeViewInsets
(
...
...
@@ -127,6 +153,7 @@ class Dialog extends StatelessWidget {
elevation:
elevation
??
dialogTheme
.
elevation
??
_defaultElevation
,
shape:
shape
??
dialogTheme
.
shape
??
_defaultDialogShape
,
type:
MaterialType
.
card
,
clipBehavior:
clipBehavior
,
child:
child
,
),
),
...
...
@@ -229,9 +256,12 @@ class AlertDialog extends StatelessWidget {
this
.
backgroundColor
,
this
.
elevation
,
this
.
semanticLabel
,
this
.
insetPadding
=
_defaultInsetPadding
,
this
.
clipBehavior
=
Clip
.
none
,
this
.
shape
,
this
.
scrollable
=
false
,
})
:
assert
(
contentPadding
!=
null
),
assert
(
clipBehavior
!=
null
),
super
(
key:
key
);
/// The (optional) title of the dialog is displayed in a large font at the top
...
...
@@ -394,6 +424,12 @@ class AlertDialog extends StatelessWidget {
/// value is used.
final
String
semanticLabel
;
/// {@macro flutter.material.dialog.insetPadding}
final
EdgeInsets
insetPadding
;
/// {@macro flutter.material.dialog.clipBehavior}
final
Clip
clipBehavior
;
/// {@macro flutter.material.dialog.shape}
final
ShapeBorder
shape
;
...
...
@@ -518,6 +554,8 @@ class AlertDialog extends StatelessWidget {
return
Dialog
(
backgroundColor:
backgroundColor
,
elevation:
elevation
,
insetPadding:
insetPadding
,
clipBehavior:
clipBehavior
,
shape:
shape
,
child:
dialogChild
,
);
...
...
packages/flutter/test/material/dialog_test.dart
View file @
7a83c6fc
...
...
@@ -155,6 +155,20 @@ void main() {
expect
(
content
.
text
.
style
,
contentTextStyle
);
});
testWidgets
(
'Custom clipBehavior'
,
(
WidgetTester
tester
)
async
{
const
AlertDialog
dialog
=
AlertDialog
(
actions:
<
Widget
>[],
clipBehavior:
Clip
.
antiAlias
,
);
await
tester
.
pumpWidget
(
_buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
Material
materialWidget
=
_getMaterialFromDialog
(
tester
);
expect
(
materialWidget
.
clipBehavior
,
Clip
.
antiAlias
);
});
testWidgets
(
'Custom dialog shape'
,
(
WidgetTester
tester
)
async
{
const
RoundedRectangleBorder
customBorder
=
RoundedRectangleBorder
(
borderRadius:
BorderRadius
.
all
(
Radius
.
circular
(
16.0
)));
...
...
@@ -750,6 +764,47 @@ void main() {
);
});
testWidgets
(
'Dialog insetPadding added to outside of dialog'
,
(
WidgetTester
tester
)
async
{
// The default testing screen (800, 600)
const
Rect
screenRect
=
Rect
.
fromLTRB
(
0.0
,
0.0
,
800.0
,
600.0
);
// Test with no padding
await
tester
.
pumpWidget
(
const
MediaQuery
(
data:
MediaQueryData
(
viewInsets:
EdgeInsets
.
all
(
0.0
),
),
child:
Dialog
(
child:
Placeholder
(),
insetPadding:
null
,
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getRect
(
find
.
byType
(
Placeholder
)),
screenRect
);
// Test with an insetPadding
await
tester
.
pumpWidget
(
const
MediaQuery
(
data:
MediaQueryData
(
viewInsets:
EdgeInsets
.
all
(
0.0
),
),
child:
Dialog
(
insetPadding:
EdgeInsets
.
fromLTRB
(
10.0
,
20.0
,
30.0
,
40.0
),
child:
Placeholder
(),
),
),
);
await
tester
.
pumpAndSettle
();
expect
(
tester
.
getRect
(
find
.
byType
(
Placeholder
)),
Rect
.
fromLTRB
(
screenRect
.
left
+
10.0
,
screenRect
.
top
+
20.0
,
screenRect
.
right
-
30.0
,
screenRect
.
bottom
-
40.0
,
));
});
testWidgets
(
'Dialog widget contains route semantics from title'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
await
tester
.
pumpWidget
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment