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
bf45897f
Unverified
Commit
bf45897f
authored
Nov 01, 2019
by
Shi-Hao Hong
Committed by
GitHub
Nov 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Implement AlertDialog title/content overflow scroll #43226" (#44003)
parent
f3a6b0da
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
109 deletions
+34
-109
dialog.dart
packages/flutter/lib/src/material/dialog.dart
+34
-32
dialog_test.dart
packages/flutter/test/material/dialog_test.dart
+0
-77
No files found.
packages/flutter/lib/src/material/dialog.dart
View file @
bf45897f
...
@@ -133,6 +133,15 @@ class Dialog extends StatelessWidget {
...
@@ -133,6 +133,15 @@ class Dialog extends StatelessWidget {
/// of actions. The title is displayed above the content and the actions are
/// of actions. The title is displayed above the content and the actions are
/// displayed below the content.
/// displayed below the content.
///
///
/// If the content is too large to fit on the screen vertically, the dialog will
/// display the title and the actions and let the content overflow, which is
/// rarely desired. Consider using a scrolling widget for [content], such as
/// [SingleChildScrollView], to avoid overflow. (However, be aware that since
/// [AlertDialog] tries to size itself using the intrinsic dimensions of its
/// children, widgets such as [ListView], [GridView], and [CustomScrollView],
/// which use lazy viewports, will not work. If this is a problem, consider
/// using [Dialog] directly.)
///
/// For dialogs that offer the user a choice between several options, consider
/// For dialogs that offer the user a choice between several options, consider
/// using a [SimpleDialog].
/// using a [SimpleDialog].
///
///
...
@@ -152,12 +161,14 @@ class Dialog extends StatelessWidget {
...
@@ -152,12 +161,14 @@ class Dialog extends StatelessWidget {
/// builder: (BuildContext context) {
/// builder: (BuildContext context) {
/// return AlertDialog(
/// return AlertDialog(
/// title: Text('Rewind and remember'),
/// title: Text('Rewind and remember'),
/// content: Column(
/// content: SingleChildScrollView(
/// child: ListBody(
/// children: <Widget>[
/// children: <Widget>[
/// Text('You will never be satisfied.'),
/// Text('You will never be satisfied.'),
/// Text('You\’re like me. I’m never satisfied.'),
/// Text('You\’re like me. I’m never satisfied.'),
/// ],
/// ],
/// ),
/// ),
/// ),
/// actions: <Widget>[
/// actions: <Widget>[
/// FlatButton(
/// FlatButton(
/// child: Text('Regret'),
/// child: Text('Regret'),
...
@@ -306,13 +317,6 @@ class AlertDialog extends StatelessWidget {
...
@@ -306,13 +317,6 @@ class AlertDialog extends StatelessWidget {
}
}
Widget
dialogChild
=
IntrinsicWidth
(
Widget
dialogChild
=
IntrinsicWidth
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
children:
<
Widget
>[
if
(
title
!=
null
||
content
!=
null
)
Flexible
(
child:
SingleChildScrollView
(
child:
Column
(
child:
Column
(
mainAxisSize:
MainAxisSize
.
min
,
mainAxisSize:
MainAxisSize
.
min
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
crossAxisAlignment:
CrossAxisAlignment
.
stretch
,
...
@@ -330,16 +334,14 @@ class AlertDialog extends StatelessWidget {
...
@@ -330,16 +334,14 @@ class AlertDialog extends StatelessWidget {
),
),
),
),
if
(
content
!=
null
)
if
(
content
!=
null
)
Padding
(
Flexible
(
child:
Padding
(
padding:
contentPadding
,
padding:
contentPadding
,
child:
DefaultTextStyle
(
child:
DefaultTextStyle
(
style:
contentTextStyle
??
dialogTheme
.
contentTextStyle
??
theme
.
textTheme
.
subhead
,
style:
contentTextStyle
??
dialogTheme
.
contentTextStyle
??
theme
.
textTheme
.
subhead
,
child:
content
,
child:
content
,
),
),
),
),
],
),
),
),
),
if
(
actions
!=
null
)
if
(
actions
!=
null
)
ButtonBar
(
ButtonBar
(
...
...
packages/flutter/test/material/dialog_test.dart
View file @
bf45897f
...
@@ -716,83 +716,6 @@ void main() {
...
@@ -716,83 +716,6 @@ void main() {
expect
(
rootObserver
.
dialogCount
,
0
);
expect
(
rootObserver
.
dialogCount
,
0
);
expect
(
nestedObserver
.
dialogCount
,
1
);
expect
(
nestedObserver
.
dialogCount
,
1
);
});
});
group
(
'Scrollable title and content'
,
()
{
testWidgets
(
'Title is scrollable'
,
(
WidgetTester
tester
)
async
{
final
Key
titleKey
=
UniqueKey
();
final
AlertDialog
dialog
=
AlertDialog
(
title:
Container
(
key:
titleKey
,
color:
Colors
.
green
,
height:
1000
,
),
);
await
tester
.
pumpWidget
(
_appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byKey
(
titleKey
));
final
Offset
originalOffset
=
box
.
localToGlobal
(
Offset
.
zero
);
await
tester
.
drag
(
find
.
byKey
(
titleKey
),
const
Offset
(
0.0
,
-
200.0
));
expect
(
box
.
localToGlobal
(
Offset
.
zero
),
equals
(
originalOffset
.
translate
(
0.0
,
-
200.0
)));
});
testWidgets
(
'Content is scrollable'
,
(
WidgetTester
tester
)
async
{
final
Key
contentKey
=
UniqueKey
();
final
AlertDialog
dialog
=
AlertDialog
(
content:
Container
(
key:
contentKey
,
color:
Colors
.
orange
,
height:
1000
,
),
);
await
tester
.
pumpWidget
(
_appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderBox
box
=
tester
.
renderObject
(
find
.
byKey
(
contentKey
));
final
Offset
originalOffset
=
box
.
localToGlobal
(
Offset
.
zero
);
await
tester
.
drag
(
find
.
byKey
(
contentKey
),
const
Offset
(
0.0
,
-
200.0
));
expect
(
box
.
localToGlobal
(
Offset
.
zero
),
equals
(
originalOffset
.
translate
(
0.0
,
-
200.0
)));
});
testWidgets
(
'Title and content are scrollable'
,
(
WidgetTester
tester
)
async
{
final
Key
titleKey
=
UniqueKey
();
final
Key
contentKey
=
UniqueKey
();
final
AlertDialog
dialog
=
AlertDialog
(
title:
Container
(
key:
titleKey
,
color:
Colors
.
green
,
height:
400
,
),
content:
Container
(
key:
contentKey
,
color:
Colors
.
orange
,
height:
400
,
),
);
await
tester
.
pumpWidget
(
_appWithAlertDialog
(
tester
,
dialog
));
await
tester
.
tap
(
find
.
text
(
'X'
));
await
tester
.
pumpAndSettle
();
final
RenderBox
title
=
tester
.
renderObject
(
find
.
byKey
(
titleKey
));
final
RenderBox
content
=
tester
.
renderObject
(
find
.
byKey
(
contentKey
));
final
Offset
titleOriginalOffset
=
title
.
localToGlobal
(
Offset
.
zero
);
final
Offset
contentOriginalOffset
=
content
.
localToGlobal
(
Offset
.
zero
);
// Dragging the title widget should scroll both the title
// and the content widgets.
await
tester
.
drag
(
find
.
byKey
(
titleKey
),
const
Offset
(
0.0
,
-
200.0
));
expect
(
title
.
localToGlobal
(
Offset
.
zero
),
equals
(
titleOriginalOffset
.
translate
(
0.0
,
-
200.0
)));
expect
(
content
.
localToGlobal
(
Offset
.
zero
),
equals
(
contentOriginalOffset
.
translate
(
0.0
,
-
200.0
)));
// Dragging the content widget should scroll both the title
// and the content widgets.
await
tester
.
drag
(
find
.
byKey
(
contentKey
),
const
Offset
(
0.0
,
200.0
));
expect
(
title
.
localToGlobal
(
Offset
.
zero
),
equals
(
titleOriginalOffset
));
expect
(
content
.
localToGlobal
(
Offset
.
zero
),
equals
(
contentOriginalOffset
));
});
});
}
}
class
DialogObserver
extends
NavigatorObserver
{
class
DialogObserver
extends
NavigatorObserver
{
...
...
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