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
d3e1e293
Unverified
Commit
d3e1e293
authored
Feb 12, 2020
by
Arthur Denner
Committed by
GitHub
Feb 12, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SimpleDialogOption: support custom padding (#50035)
parent
4c1045c0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
19 deletions
+51
-19
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+7
-1
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+44
-18
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
d3e1e293
...
@@ -540,6 +540,7 @@ class SimpleDialogOption extends StatelessWidget {
...
@@ -540,6 +540,7 @@ class SimpleDialogOption extends StatelessWidget {
const
SimpleDialogOption
({
const
SimpleDialogOption
({
Key
key
,
Key
key
,
this
.
onPressed
,
this
.
onPressed
,
this
.
padding
,
this
.
child
,
this
.
child
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
...
@@ -556,12 +557,17 @@ class SimpleDialogOption extends StatelessWidget {
...
@@ -556,12 +557,17 @@ class SimpleDialogOption extends StatelessWidget {
/// Typically a [Text] widget.
/// Typically a [Text] widget.
final
Widget
child
;
final
Widget
child
;
/// The amount of space to surround the [child] with.
///
/// Defaults to EdgeInsets.symmetric(vertical: 8.0, horizontal: 24.0).
final
EdgeInsets
padding
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
return
InkWell
(
return
InkWell
(
onTap:
onPressed
,
onTap:
onPressed
,
child:
Padding
(
child:
Padding
(
padding:
const
EdgeInsets
.
symmetric
(
vertical:
8.0
,
horizontal:
24.0
),
padding:
padding
??
const
EdgeInsets
.
symmetric
(
vertical:
8.0
,
horizontal:
24.0
),
child:
child
,
child:
child
,
),
),
);
);
...
...
packages/flutter/test/material/dialog_test.dart
View file @
d3e1e293
...
@@ -11,7 +11,7 @@ import 'package:matcher/matcher.dart';
...
@@ -11,7 +11,7 @@ import 'package:matcher/matcher.dart';
import
'../widgets/semantics_tester.dart'
;
import
'../widgets/semantics_tester.dart'
;
MaterialApp
_
appWithAlertDialog
(
WidgetTester
tester
,
AlertDialog
dialog
,
{
ThemeData
theme
})
{
MaterialApp
_
buildAppWithDialog
(
Widget
dialog
,
{
ThemeData
theme
})
{
return
MaterialApp
(
return
MaterialApp
(
theme:
theme
,
theme:
theme
,
home:
Material
(
home:
Material
(
...
@@ -64,7 +64,7 @@ void main() {
...
@@ -64,7 +64,7 @@ void main() {
),
),
],
],
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -80,7 +80,7 @@ void main() {
...
@@ -80,7 +80,7 @@ void main() {
backgroundColor:
customColor
,
backgroundColor:
customColor
,
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
,
theme:
ThemeData
(
brightness:
Brightness
.
dark
)));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
,
theme:
ThemeData
(
brightness:
Brightness
.
dark
)));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -95,7 +95,7 @@ void main() {
...
@@ -95,7 +95,7 @@ void main() {
content:
Text
(
'Y'
),
content:
Text
(
'Y'
),
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
,
theme:
ThemeData
(
brightness:
Brightness
.
dark
)));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
,
theme:
ThemeData
(
brightness:
Brightness
.
dark
)));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -112,7 +112,7 @@ void main() {
...
@@ -112,7 +112,7 @@ void main() {
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
elevation:
customElevation
,
elevation:
customElevation
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -129,7 +129,7 @@ void main() {
...
@@ -129,7 +129,7 @@ void main() {
titleTextStyle:
titleTextStyle
,
titleTextStyle:
titleTextStyle
,
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -146,7 +146,7 @@ void main() {
...
@@ -146,7 +146,7 @@ void main() {
contentTextStyle:
contentTextStyle
,
contentTextStyle:
contentTextStyle
,
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -162,7 +162,7 @@ void main() {
...
@@ -162,7 +162,7 @@ void main() {
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
shape:
customBorder
,
shape:
customBorder
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -176,7 +176,7 @@ void main() {
...
@@ -176,7 +176,7 @@ void main() {
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
shape:
null
,
shape:
null
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -191,7 +191,7 @@ void main() {
...
@@ -191,7 +191,7 @@ void main() {
actions:
<
Widget
>[
],
actions:
<
Widget
>[
],
shape:
customBorder
,
shape:
customBorder
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -243,6 +243,32 @@ void main() {
...
@@ -243,6 +243,32 @@ void main() {
expect
(
await
result
,
equals
(
42
));
expect
(
await
result
,
equals
(
42
));
});
});
testWidgets
(
'Custom padding on SimpleDialogOption'
,
(
WidgetTester
tester
)
async
{
const
EdgeInsets
customPadding
=
EdgeInsets
.
fromLTRB
(
4
,
10
,
8
,
6
);
final
SimpleDialog
dialog
=
SimpleDialog
(
title:
const
Text
(
'Title'
),
children:
<
Widget
>[
SimpleDialogOption
(
onPressed:
()
{},
child:
const
Text
(
'First option'
),
padding:
customPadding
,
),
],
);
await
tester
.
pumpWidget
(
_buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
Rect
dialogRect
=
tester
.
getRect
(
find
.
byType
(
SimpleDialogOption
));
final
Rect
textRect
=
tester
.
getRect
(
find
.
text
(
'First option'
));
expect
(
textRect
.
left
,
dialogRect
.
left
+
customPadding
.
left
);
expect
(
textRect
.
top
,
dialogRect
.
top
+
customPadding
.
top
);
expect
(
textRect
.
right
,
dialogRect
.
right
-
customPadding
.
right
);
expect
(
textRect
.
bottom
,
dialogRect
.
bottom
-
customPadding
.
bottom
);
});
testWidgets
(
'Barrier dismissible'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Barrier dismissible'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
const
MaterialApp
(
const
MaterialApp
(
...
@@ -353,7 +379,7 @@ void main() {
...
@@ -353,7 +379,7 @@ void main() {
);
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
@@ -387,7 +413,7 @@ void main() {
...
@@ -387,7 +413,7 @@ void main() {
);
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
@@ -429,7 +455,7 @@ void main() {
...
@@ -429,7 +455,7 @@ void main() {
);
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
@@ -493,7 +519,7 @@ void main() {
...
@@ -493,7 +519,7 @@ void main() {
);
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
@@ -554,7 +580,7 @@ void main() {
...
@@ -554,7 +580,7 @@ void main() {
);
);
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
);
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
...
@@ -954,7 +980,7 @@ void main() {
...
@@ -954,7 +980,7 @@ void main() {
),
),
scrollable:
true
,
scrollable:
true
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -974,7 +1000,7 @@ void main() {
...
@@ -974,7 +1000,7 @@ void main() {
),
),
scrollable:
true
,
scrollable:
true
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -1000,7 +1026,7 @@ void main() {
...
@@ -1000,7 +1026,7 @@ void main() {
),
),
scrollable:
true
,
scrollable:
true
,
);
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
...
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