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
e7b6b521
Unverified
Commit
e7b6b521
authored
May 16, 2020
by
Enol Casielles Martinez
Committed by
GitHub
May 16, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid AnimatedBuilder rebuilding widget (#55832)
parent
afdc4408
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
16 deletions
+49
-16
bottom_sheet.dart
packages/flutter/lib/src/material/bottom_sheet.dart
+17
-16
bottom_sheet_test.dart
packages/flutter/test/material/bottom_sheet_test.dart
+32
-0
No files found.
packages/flutter/lib/src/material/bottom_sheet.dart
View file @
e7b6b521
...
...
@@ -369,6 +369,22 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
return
AnimatedBuilder
(
animation:
widget
.
route
.
animation
,
child:
BottomSheet
(
animationController:
widget
.
route
.
_animationController
,
onClosing:
()
{
if
(
widget
.
route
.
isCurrent
)
{
Navigator
.
pop
(
context
);
}
},
builder:
widget
.
route
.
builder
,
backgroundColor:
widget
.
backgroundColor
,
elevation:
widget
.
elevation
,
shape:
widget
.
shape
,
clipBehavior:
widget
.
clipBehavior
,
enableDrag:
widget
.
enableDrag
,
onDragStart:
handleDragStart
,
onDragEnd:
handleDragEnd
,
),
builder:
(
BuildContext
context
,
Widget
child
)
{
// Disable the initial animation when accessible navigation is on so
// that the semantics are added to the tree at the correct time.
...
...
@@ -383,22 +399,7 @@ class _ModalBottomSheetState<T> extends State<_ModalBottomSheet<T>> {
child:
ClipRect
(
child:
CustomSingleChildLayout
(
delegate:
_ModalBottomSheetLayout
(
animationValue
,
widget
.
isScrollControlled
),
child:
BottomSheet
(
animationController:
widget
.
route
.
_animationController
,
onClosing:
()
{
if
(
widget
.
route
.
isCurrent
)
{
Navigator
.
pop
(
context
);
}
},
builder:
widget
.
route
.
builder
,
backgroundColor:
widget
.
backgroundColor
,
elevation:
widget
.
elevation
,
shape:
widget
.
shape
,
clipBehavior:
widget
.
clipBehavior
,
enableDrag:
widget
.
enableDrag
,
onDragStart:
handleDragStart
,
onDragEnd:
handleDragEnd
,
),
child:
child
,
),
),
);
...
...
packages/flutter/test/material/bottom_sheet_test.dart
View file @
e7b6b521
...
...
@@ -306,6 +306,38 @@ void main() {
expect
(
find
.
text
(
'BottomSheet'
),
findsNothing
);
});
testWidgets
(
'Modal BottomSheet builder should only be called once'
,
(
WidgetTester
tester
)
async
{
BuildContext
savedContext
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Builder
(
builder:
(
BuildContext
context
)
{
savedContext
=
context
;
return
Container
();
},
),
));
int
numBuilderCalls
=
0
;
showModalBottomSheet
<
void
>(
context:
savedContext
,
isDismissible:
false
,
enableDrag:
true
,
builder:
(
BuildContext
context
)
{
numBuilderCalls
++;
return
const
Text
(
'BottomSheet'
);
},
);
await
tester
.
pumpAndSettle
();
expect
(
numBuilderCalls
,
1
);
// Swipe the bottom sheet to dismiss it.
await
tester
.
drag
(
find
.
text
(
'BottomSheet'
),
const
Offset
(
0.0
,
150.0
));
await
tester
.
pumpAndSettle
();
// Bottom sheet dismiss animation.
expect
(
numBuilderCalls
,
1
);
});
testWidgets
(
'Verify that a downwards fling dismisses a persistent BottomSheet'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
ScaffoldState
>
scaffoldKey
=
GlobalKey
<
ScaffoldState
>();
bool
showBottomSheetThenCalled
=
false
;
...
...
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