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
602ac0bc
Unverified
Commit
602ac0bc
authored
Mar 23, 2020
by
Christian Mürtz
Committed by
GitHub
Mar 23, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix RefreshIndicator performance issue (#47667)
parent
685e9d1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
12 deletions
+47
-12
refresh_indicator.dart
packages/flutter/lib/src/material/refresh_indicator.dart
+11
-11
refresh_indicator_test.dart
packages/flutter/test/material/refresh_indicator_test.dart
+36
-1
No files found.
packages/flutter/lib/src/material/refresh_indicator.dart
View file @
602ac0bc
...
@@ -409,26 +409,26 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
...
@@ -409,26 +409,26 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
return
_pendingRefreshFuture
;
return
_pendingRefreshFuture
;
}
}
final
GlobalKey
_key
=
GlobalKey
();
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
assert
(
debugCheckHasMaterialLocalizations
(
context
));
assert
(
debugCheckHasMaterialLocalizations
(
context
));
final
Widget
child
=
NotificationListener
<
ScrollNotification
>(
final
Widget
child
=
NotificationListener
<
ScrollNotification
>(
key:
_key
,
onNotification:
_handleScrollNotification
,
onNotification:
_handleScrollNotification
,
child:
NotificationListener
<
OverscrollIndicatorNotification
>(
child:
NotificationListener
<
OverscrollIndicatorNotification
>(
onNotification:
_handleGlowNotification
,
onNotification:
_handleGlowNotification
,
child:
widget
.
child
,
child:
widget
.
child
,
),
),
);
);
if
(
_mode
==
null
)
{
assert
(()
{
assert
(
_dragOffset
==
null
);
if
(
_mode
==
null
)
{
assert
(
_isIndicatorAtTop
==
null
);
assert
(
_dragOffset
==
null
);
return
child
;
assert
(
_isIndicatorAtTop
==
null
);
}
}
else
{
assert
(
_dragOffset
!=
null
);
assert
(
_dragOffset
!=
null
);
assert
(
_isIndicatorAtTop
!=
null
);
assert
(
_isIndicatorAtTop
!=
null
);
}
return
true
;
}());
final
bool
showIndeterminateIndicator
=
final
bool
showIndeterminateIndicator
=
_mode
==
_RefreshIndicatorMode
.
refresh
||
_mode
==
_RefreshIndicatorMode
.
done
;
_mode
==
_RefreshIndicatorMode
.
refresh
||
_mode
==
_RefreshIndicatorMode
.
done
;
...
@@ -436,7 +436,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
...
@@ -436,7 +436,7 @@ class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderS
return
Stack
(
return
Stack
(
children:
<
Widget
>[
children:
<
Widget
>[
child
,
child
,
Positioned
(
if
(
_mode
!=
null
)
Positioned
(
top:
_isIndicatorAtTop
?
0.0
:
null
,
top:
_isIndicatorAtTop
?
0.0
:
null
,
bottom:
!
_isIndicatorAtTop
?
0.0
:
null
,
bottom:
!
_isIndicatorAtTop
?
0.0
:
null
,
left:
0.0
,
left:
0.0
,
...
...
packages/flutter/test/material/refresh_indicator_test.dart
View file @
602ac0bc
...
@@ -420,4 +420,39 @@ void main() {
...
@@ -420,4 +420,39 @@ void main() {
expect
(
controller
.
offset
,
lessThan
(
0.0
));
expect
(
controller
.
offset
,
lessThan
(
0.0
));
expect
(
refreshCalled
,
isTrue
);
expect
(
refreshCalled
,
isTrue
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
macOS
}));
}
testWidgets
(
'RefreshIndicator does not force child to relayout'
,
(
WidgetTester
tester
)
async
{
int
layoutCount
=
0
;
Widget
layoutCallback
(
BuildContext
context
,
BoxConstraints
constraints
)
{
layoutCount
++;
return
ListView
(
physics:
const
AlwaysScrollableScrollPhysics
(),
children:
<
String
>[
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
].
map
<
Widget
>((
String
item
)
{
return
SizedBox
(
height:
200.0
,
child:
Text
(
item
),
);
}).
toList
(),
);
}
await
tester
.
pumpWidget
(
MaterialApp
(
home:
RefreshIndicator
(
onRefresh:
refresh
,
child:
LayoutBuilder
(
builder:
layoutCallback
),
),
),
);
await
tester
.
fling
(
find
.
text
(
'A'
),
const
Offset
(
0.0
,
300.0
),
1000.0
);
// trigger refresh
await
tester
.
pump
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the scroll animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator settle animation
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// finish the indicator hide animation
expect
(
layoutCount
,
1
);
});
}
\ No newline at end of file
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