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
2cb65260
Unverified
Commit
2cb65260
authored
Dec 08, 2020
by
Amit Patil
Committed by
GitHub
Dec 08, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
showDialog assertion for non-null builder or child property (#71838)
parent
995aa138
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
0 deletions
+52
-0
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+1
-0
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+51
-0
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
2cb65260
...
...
@@ -973,6 +973,7 @@ Future<T?> showDialog<T>({
Widget
?
child
,
})
{
assert
(
child
==
null
||
builder
==
null
);
assert
(
child
!=
null
||
builder
!=
null
);
assert
(
barrierDismissible
!=
null
);
assert
(
useSafeArea
!=
null
);
assert
(
useRootNavigator
!=
null
);
...
...
packages/flutter/test/material/dialog_test.dart
View file @
2cb65260
...
...
@@ -217,6 +217,57 @@ void main() {
expect
(
materialWidget
.
shape
,
customBorder
);
});
testWidgets
(
'showDialog child and builder cannot be simultaneously defined'
,
(
WidgetTester
tester
)
async
{
late
BuildContext
currentBuildContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
currentBuildContext
=
context
;
return
Container
();
}
),
),
),
),
);
expect
(()
async
{
showDialog
<
void
>(
context:
currentBuildContext
,
child:
const
Text
(
'Child'
),
builder:
(
BuildContext
context
)
{
return
const
Text
(
'Builder'
);
},
);
},
throwsAssertionError
);
});
testWidgets
(
'showDialog child or builder must be defined'
,
(
WidgetTester
tester
)
async
{
late
BuildContext
currentBuildContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
currentBuildContext
=
context
;
return
Container
();
}
),
),
),
),
);
expect
(
()
=>
showDialog
<
void
>(
context:
currentBuildContext
),
throwsAssertionError
,
);
});
testWidgets
(
'Simple dialog control test'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
MaterialApp
(
...
...
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