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
Hide 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 {
const
SimpleDialogOption
({
Key
key
,
this
.
onPressed
,
this
.
padding
,
this
.
child
,
})
:
super
(
key:
key
);
...
...
@@ -556,12 +557,17 @@ class SimpleDialogOption extends StatelessWidget {
/// Typically a [Text] widget.
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
Widget
build
(
BuildContext
context
)
{
return
InkWell
(
onTap:
onPressed
,
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
,
),
);
...
...
packages/flutter/test/material/dialog_test.dart
View file @
d3e1e293
...
...
@@ -11,7 +11,7 @@ import 'package:matcher/matcher.dart';
import
'../widgets/semantics_tester.dart'
;
MaterialApp
_
appWithAlertDialog
(
WidgetTester
tester
,
AlertDialog
dialog
,
{
ThemeData
theme
})
{
MaterialApp
_
buildAppWithDialog
(
Widget
dialog
,
{
ThemeData
theme
})
{
return
MaterialApp
(
theme:
theme
,
home:
Material
(
...
...
@@ -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
.
pumpAndSettle
();
...
...
@@ -80,7 +80,7 @@ void main() {
backgroundColor:
customColor
,
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
.
pumpAndSettle
();
...
...
@@ -95,7 +95,7 @@ void main() {
content:
Text
(
'Y'
),
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
.
pumpAndSettle
();
...
...
@@ -112,7 +112,7 @@ void main() {
actions:
<
Widget
>[
],
elevation:
customElevation
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -129,7 +129,7 @@ void main() {
titleTextStyle:
titleTextStyle
,
actions:
<
Widget
>[
],
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -146,7 +146,7 @@ void main() {
contentTextStyle:
contentTextStyle
,
actions:
<
Widget
>[
],
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -162,7 +162,7 @@ void main() {
actions:
<
Widget
>[
],
shape:
customBorder
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -176,7 +176,7 @@ void main() {
actions:
<
Widget
>[
],
shape:
null
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -191,7 +191,7 @@ void main() {
actions:
<
Widget
>[
],
shape:
customBorder
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -243,6 +243,32 @@ void main() {
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
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
...
...
@@ -353,7 +379,7 @@ void main() {
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -387,7 +413,7 @@ void main() {
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -429,7 +455,7 @@ void main() {
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -493,7 +519,7 @@ void main() {
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -554,7 +580,7 @@ void main() {
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
),
_
buildAppWithDialog
(
dialog
),
);
await
tester
.
tap
(
find
.
text
(
'X'
));
...
...
@@ -954,7 +980,7 @@ void main() {
),
scrollable:
true
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -974,7 +1000,7 @@ void main() {
),
scrollable:
true
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
...
...
@@ -1000,7 +1026,7 @@ void main() {
),
scrollable:
true
,
);
await
tester
.
pumpWidget
(
_
appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
pumpWidget
(
_
buildAppWithDialog
(
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
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