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
3f56178d
Unverified
Commit
3f56178d
authored
Oct 15, 2020
by
Greg Spencer
Committed by
GitHub
Oct 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert some more widget tests to NNBD (#68129)
parent
f7ee4402
Changes
31
Show whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
411 additions
and
514 deletions
+411
-514
restoration_mixin_test.dart
packages/flutter/test/widgets/restoration_mixin_test.dart
+81
-84
restoration_scope_test.dart
packages/flutter/test/widgets/restoration_scope_test.dart
+15
-17
restoration_scopes_moving_test.dart
.../flutter/test/widgets/restoration_scopes_moving_test.dart
+11
-13
root_restoration_scope_test.dart
...ges/flutter/test/widgets/root_restoration_scope_test.dart
+12
-14
rotated_box_test.dart
packages/flutter/test/widgets/rotated_box_test.dart
+0
-2
route_notification_messages_test.dart
...lutter/test/widgets/route_notification_messages_test.dart
+9
-11
router_test.dart
packages/flutter/test/widgets/router_test.dart
+65
-70
row_test.dart
packages/flutter/test/widgets/row_test.dart
+54
-56
rtl_test.dart
packages/flutter/test/widgets/rtl_test.dart
+3
-5
run_app_async_test.dart
packages/flutter/test/widgets/run_app_async_test.dart
+3
-5
run_app_test.dart
packages/flutter/test/widgets/run_app_test.dart
+0
-2
safe_area_test.dart
packages/flutter/test/widgets/safe_area_test.dart
+0
-2
scroll_activity_test.dart
packages/flutter/test/widgets/scroll_activity_test.dart
+7
-9
scroll_aware_image_provider_test.dart
...lutter/test/widgets/scroll_aware_image_provider_test.dart
+68
-70
scroll_behavior_test.dart
packages/flutter/test/widgets/scroll_behavior_test.dart
+6
-8
scroll_controller_test.dart
packages/flutter/test/widgets/scroll_controller_test.dart
+0
-2
scroll_events_test.dart
packages/flutter/test/widgets/scroll_events_test.dart
+2
-5
scroll_interaction_test.dart
packages/flutter/test/widgets/scroll_interaction_test.dart
+0
-2
scroll_notification_test.dart
packages/flutter/test/widgets/scroll_notification_test.dart
+5
-7
scroll_physics_test.dart
packages/flutter/test/widgets/scroll_physics_test.dart
+11
-13
scroll_position_test.dart
packages/flutter/test/widgets/scroll_position_test.dart
+4
-7
scroll_simulation_test.dart
packages/flutter/test/widgets/scroll_simulation_test.dart
+0
-2
scroll_view_test.dart
packages/flutter/test/widgets/scroll_view_test.dart
+39
-76
scrollable_animations_test.dart
...ages/flutter/test/widgets/scrollable_animations_test.dart
+2
-4
scrollable_dispose_test.dart
packages/flutter/test/widgets/scrollable_dispose_test.dart
+0
-2
scrollable_fling_test.dart
packages/flutter/test/widgets/scrollable_fling_test.dart
+0
-2
scrollable_grid_test.dart
packages/flutter/test/widgets/scrollable_grid_test.dart
+0
-2
scrollable_in_overlay_test.dart
...ages/flutter/test/widgets/scrollable_in_overlay_test.dart
+0
-2
scrollable_list_hit_testing_test.dart
...lutter/test/widgets/scrollable_list_hit_testing_test.dart
+0
-2
scrollable_of_test.dart
packages/flutter/test/widgets/scrollable_of_test.dart
+8
-10
scrollable_restoration_test.dart
...ges/flutter/test/widgets/scrollable_restoration_test.dart
+6
-8
No files found.
packages/flutter/test/widgets/restoration_mixin_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -29,12 +27,12 @@ void main() {
...
@@ -29,12 +27,12 @@ void main() {
manager
.
doSerialization
();
manager
.
doSerialization
();
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
expect
(
state
.
bucket
.
restorationId
,
id
);
expect
(
state
.
bucket
?
.
restorationId
,
id
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
id
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
id
),
isTrue
);
expect
(
state
.
property
.
value
,
10
);
expect
(
state
.
property
.
value
,
10
);
expect
(
rawData
[
childrenMapKey
][
id
][
valuesMapKey
][
'foo'
],
10
);
expect
(
rawData
[
childrenMapKey
][
id
][
valuesMapKey
][
'foo'
],
10
);
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
});
});
...
@@ -53,10 +51,10 @@ void main() {
...
@@ -53,10 +51,10 @@ void main() {
manager
.
doSerialization
();
manager
.
doSerialization
();
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
property
.
value
,
22
);
expect
(
state
.
property
.
value
,
22
);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
});
});
...
@@ -76,9 +74,9 @@ void main() {
...
@@ -76,9 +74,9 @@ void main() {
// Claimed existing bucket with data.
// Claimed existing bucket with data.
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
...
@@ -94,12 +92,12 @@ void main() {
...
@@ -94,12 +92,12 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
.
restorationId
,
'something else'
);
expect
(
state
.
bucket
!
.
restorationId
,
'something else'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
});
});
testWidgets
(
'renames existing bucket when didUpdateRestorationId is called'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'renames existing bucket when didUpdateRestorationId is called'
,
(
WidgetTester
tester
)
async
{
...
@@ -118,9 +116,9 @@ void main() {
...
@@ -118,9 +116,9 @@ void main() {
// Claimed existing bucket with data.
// Claimed existing bucket with data.
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
...
@@ -129,12 +127,12 @@ void main() {
...
@@ -129,12 +127,12 @@ void main() {
state
.
injectId
(
'newnewnew'
);
state
.
injectId
(
'newnewnew'
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
.
restorationId
,
'newnewnew'
);
expect
(
state
.
bucket
!
.
restorationId
,
'newnewnew'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
});
});
testWidgets
(
'Disposing widget removes its data'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Disposing widget removes its data'
,
(
WidgetTester
tester
)
async
{
...
@@ -185,9 +183,9 @@ void main() {
...
@@ -185,9 +183,9 @@ void main() {
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
]);
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
to
o
gleBucketLog
.
clear
();
state
.
to
g
gleBucketLog
.
clear
();
// Change id to non-null.
// Change id to non-null.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -200,17 +198,17 @@ void main() {
...
@@ -200,17 +198,17 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
property
.
value
,
10
);
expect
(
state
.
property
.
value
,
10
);
expect
(
rawData
[
childrenMapKey
][
'child1'
][
valuesMapKey
][
'foo'
],
10
);
expect
(
rawData
[
childrenMapKey
][
'child1'
][
valuesMapKey
][
'foo'
],
10
);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
.
single
,
isNull
);
expect
(
state
.
to
g
gleBucketLog
.
single
,
isNull
);
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
to
o
gleBucketLog
.
clear
();
state
.
to
g
gleBucketLog
.
clear
();
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
// Change id back to null.
// Change id back to null.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -226,7 +224,7 @@ void main() {
...
@@ -226,7 +224,7 @@ void main() {
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'child1'
),
isFalse
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'child1'
),
isFalse
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
.
single
,
same
(
bucket
));
expect
(
state
.
to
g
gleBucketLog
.
single
,
same
(
bucket
));
});
});
testWidgets
(
'move in and out of scope'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'move in and out of scope'
,
(
WidgetTester
tester
)
async
{
...
@@ -248,9 +246,9 @@ void main() {
...
@@ -248,9 +246,9 @@ void main() {
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
]);
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
to
o
gleBucketLog
.
clear
();
state
.
to
g
gleBucketLog
.
clear
();
// Move it under a valid scope.
// Move it under a valid scope.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -264,17 +262,17 @@ void main() {
...
@@ -264,17 +262,17 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
property
.
value
,
10
);
expect
(
state
.
property
.
value
,
10
);
expect
(
rawData
[
childrenMapKey
][
'child1'
][
valuesMapKey
][
'foo'
],
10
);
expect
(
rawData
[
childrenMapKey
][
'child1'
][
valuesMapKey
][
'foo'
],
10
);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
.
single
,
isNull
);
expect
(
state
.
to
g
gleBucketLog
.
single
,
isNull
);
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
to
o
gleBucketLog
.
clear
();
state
.
to
g
gleBucketLog
.
clear
();
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
// Move out of scope again.
// Move out of scope again.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -288,7 +286,7 @@ void main() {
...
@@ -288,7 +286,7 @@ void main() {
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'child1'
),
isFalse
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'child1'
),
isFalse
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
.
single
,
same
(
bucket
));
expect
(
state
.
to
g
gleBucketLog
.
single
,
same
(
bucket
));
});
});
testWidgets
(
'moving scope moves its data'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'moving scope moves its data'
,
(
WidgetTester
tester
)
async
{
...
@@ -316,13 +314,13 @@ void main() {
...
@@ -316,13 +314,13 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
expect
(
state
.
bucket
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'moving-child'
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
][
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
][
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
bucket
.
write
(
'value'
,
11
);
state
.
bucket
!
.
write
(
'value'
,
11
);
manager
.
doSerialization
();
manager
.
doSerialization
();
// Move widget.
// Move widget.
...
@@ -345,11 +343,11 @@ void main() {
...
@@ -345,11 +343,11 @@ void main() {
),
),
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
.
read
<
int
>(
'value'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'value'
),
11
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
],
isEmpty
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
],
isEmpty
);
...
@@ -371,7 +369,7 @@ void main() {
...
@@ -371,7 +369,7 @@ void main() {
expect
(
state
.
property
.
value
,
10
);
// default
expect
(
state
.
property
.
value
,
10
);
// default
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
_clearLogs
(
state
);
_clearLogs
(
state
);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
...
@@ -381,7 +379,7 @@ void main() {
...
@@ -381,7 +379,7 @@ void main() {
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
restoreStateLog
,
isEmpty
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
_clearLogs
(
state
);
_clearLogs
(
state
);
final
_TestRestorableWidgetState
oldState
=
state
;
final
_TestRestorableWidgetState
oldState
=
state
;
...
@@ -392,7 +390,7 @@ void main() {
...
@@ -392,7 +390,7 @@ void main() {
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
restoreStateLog
.
single
,
isNull
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
});
});
testWidgets
(
'restore while running'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'restore while running'
,
(
WidgetTester
tester
)
async
{
...
@@ -423,7 +421,7 @@ void main() {
...
@@ -423,7 +421,7 @@ void main() {
_clearLogs
(
state
);
_clearLogs
(
state
);
final
_TestRestorableWidgetState
oldState
=
state
;
final
_TestRestorableWidgetState
oldState
=
state
;
final
RestorationBucket
oldBucket
=
oldState
.
bucket
;
final
RestorationBucket
oldBucket
=
oldState
.
bucket
!
;
await
tester
.
restoreFrom
(
data
);
await
tester
.
restoreFrom
(
data
);
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
...
@@ -431,7 +429,7 @@ void main() {
...
@@ -431,7 +429,7 @@ void main() {
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
value
,
20
);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
restoreStateLog
.
single
,
oldBucket
);
expect
(
state
.
restoreStateLog
.
single
,
oldBucket
);
expect
(
state
.
to
o
gleBucketLog
,
isEmpty
);
expect
(
state
.
to
g
gleBucketLog
,
isEmpty
);
});
});
testWidgets
(
'can register additional property outside of restoreState'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'can register additional property outside of restoreState'
,
(
WidgetTester
tester
)
async
{
...
@@ -446,28 +444,28 @@ void main() {
...
@@ -446,28 +444,28 @@ void main() {
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
state
.
registerAdditionalProperty
();
state
.
registerAdditionalProperty
();
expect
(
state
.
additionalProperty
.
value
,
11
);
expect
(
state
.
additionalProperty
!
.
value
,
11
);
expect
(
state
.
additionalProperty
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
expect
(
state
.
additionalProperty
!
.
log
,
<
String
>[
'createDefaultValue'
,
'initWithValue'
,
'toPrimitives'
]);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
state
.
additionalProperty
.
value
=
33
;
state
.
additionalProperty
!
.
value
=
33
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
33
);
expect
(
state
.
additionalProperty
!
.
value
,
33
);
final
TestRestorationData
data
=
await
tester
.
getRestorationData
();
final
TestRestorationData
data
=
await
tester
.
getRestorationData
();
state
.
setProperties
(()
{
state
.
setProperties
(()
{
state
.
additionalProperty
.
value
=
44
;
state
.
additionalProperty
!
.
value
=
44
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
44
);
expect
(
state
.
additionalProperty
!
.
value
,
44
);
_clearLogs
(
state
);
_clearLogs
(
state
);
await
tester
.
restoreFrom
(
data
);
await
tester
.
restoreFrom
(
data
);
expect
(
state
,
same
(
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
))));
expect
(
state
,
same
(
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
))));
expect
(
state
.
additionalProperty
.
value
,
33
);
expect
(
state
.
additionalProperty
!
.
value
,
33
);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'fromPrimitives'
,
'initWithValue'
]);
});
});
...
@@ -517,7 +515,7 @@ void main() {
...
@@ -517,7 +515,7 @@ void main() {
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
property
.
value
,
30
);
expect
(
state
.
property
.
value
,
30
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
30
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
30
);
_clearLogs
(
state
);
_clearLogs
(
state
);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
...
@@ -525,14 +523,14 @@ void main() {
...
@@ -525,14 +523,14 @@ void main() {
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
property
.
value
,
30
);
expect
(
state
.
property
.
value
,
30
);
expect
(
state
.
bucket
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
bucket
!
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
state
.
property
.
value
=
40
;
state
.
property
.
value
=
40
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
bucket
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
bucket
!
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
await
tester
.
restartAndRestore
();
await
tester
.
restartAndRestore
();
...
@@ -557,20 +555,20 @@ void main() {
...
@@ -557,20 +555,20 @@ void main() {
state
.
property
.
enabled
=
false
;
state
.
property
.
enabled
=
false
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
bucket
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
bucket
!
.
contains
(
'foo'
),
isFalse
);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
state
.
property
.
value
=
40
;
state
.
property
.
value
=
40
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
property
.
value
,
40
);
expect
(
state
.
property
.
value
,
40
);
expect
(
state
.
bucket
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
bucket
!
.
contains
(
'foo'
),
isFalse
);
expect
(
state
.
property
.
log
,
isEmpty
);
expect
(
state
.
property
.
log
,
isEmpty
);
state
.
setProperties
(()
{
state
.
setProperties
(()
{
state
.
property
.
enabled
=
true
;
state
.
property
.
enabled
=
true
;
});
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
40
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
40
);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
expect
(
state
.
property
.
log
,
<
String
>[
'toPrimitives'
]);
await
tester
.
restartAndRestore
();
await
tester
.
restartAndRestore
();
...
@@ -591,18 +589,18 @@ void main() {
...
@@ -591,18 +589,18 @@ void main() {
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
state
.
registerAdditionalProperty
();
state
.
registerAdditionalProperty
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
11
);
expect
(
state
.
additionalProperty
!
.
value
,
11
);
expect
(
state
.
bucket
.
read
<
int
>(
'additional'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'additional'
),
11
);
state
.
unregisterAdditionalProperty
();
state
.
unregisterAdditionalProperty
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
bucket
.
contains
(
'additional'
),
isFalse
);
expect
(
state
.
bucket
!
.
contains
(
'additional'
),
isFalse
);
expect
(()
=>
state
.
additionalProperty
.
value
,
throwsAssertionError
);
// No longer registered.
expect
(()
=>
state
.
additionalProperty
!
.
value
,
throwsAssertionError
);
// No longer registered.
// Can register the same property again.
// Can register the same property again.
state
.
registerAdditionalProperty
();
state
.
registerAdditionalProperty
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
11
);
expect
(
state
.
additionalProperty
!
.
value
,
11
);
expect
(
state
.
bucket
.
read
<
int
>(
'additional'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'additional'
),
11
);
});
});
testWidgets
(
'Disposing a property unregisters it, but keeps data'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Disposing a property unregisters it, but keeps data'
,
(
WidgetTester
tester
)
async
{
...
@@ -617,20 +615,20 @@ void main() {
...
@@ -617,20 +615,20 @@ void main() {
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
final
_TestRestorableWidgetState
state
=
tester
.
state
(
find
.
byType
(
_TestRestorableWidget
));
state
.
registerAdditionalProperty
();
state
.
registerAdditionalProperty
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
11
);
expect
(
state
.
additionalProperty
!
.
value
,
11
);
expect
(
state
.
bucket
.
read
<
int
>(
'additional'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'additional'
),
11
);
state
.
additionalProperty
.
dispose
();
state
.
additionalProperty
!
.
dispose
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
bucket
.
read
<
int
>(
'additional'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'additional'
),
11
);
// Can register property under same id again.
// Can register property under same id again.
state
.
additionalProperty
=
_TestRestorableProperty
(
22
);
state
.
additionalProperty
=
_TestRestorableProperty
(
22
);
state
.
registerAdditionalProperty
();
state
.
registerAdditionalProperty
();
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
state
.
additionalProperty
.
value
,
11
);
// Old value restored.
expect
(
state
.
additionalProperty
!
.
value
,
11
);
// Old value restored.
expect
(
state
.
bucket
.
read
<
int
>(
'additional'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'additional'
),
11
);
});
});
test
(
'RestorableProperty throws after disposed'
,
()
{
test
(
'RestorableProperty throws after disposed'
,
()
{
...
@@ -642,16 +640,16 @@ void main() {
...
@@ -642,16 +640,16 @@ void main() {
void
_clearLogs
(
_TestRestorableWidgetState
state
)
{
void
_clearLogs
(
_TestRestorableWidgetState
state
)
{
state
.
property
.
log
.
clear
();
state
.
property
.
log
.
clear
();
state
.
additionalProperty
?.
log
?
.
clear
();
state
.
additionalProperty
?.
log
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
restoreStateLog
.
clear
();
state
.
to
o
gleBucketLog
.
clear
();
state
.
to
g
gleBucketLog
.
clear
();
}
}
class
_TestRestorableWidget
extends
StatefulWidget
{
class
_TestRestorableWidget
extends
StatefulWidget
{
const
_TestRestorableWidget
({
Key
key
,
this
.
restorationId
})
:
super
(
key:
key
);
const
_TestRestorableWidget
({
Key
?
key
,
this
.
restorationId
})
:
super
(
key:
key
);
final
String
restorationId
;
final
String
?
restorationId
;
@override
@override
State
<
_TestRestorableWidget
>
createState
()
=>
_TestRestorableWidgetState
();
State
<
_TestRestorableWidget
>
createState
()
=>
_TestRestorableWidgetState
();
...
@@ -659,25 +657,24 @@ class _TestRestorableWidget extends StatefulWidget {
...
@@ -659,25 +657,24 @@ class _TestRestorableWidget extends StatefulWidget {
class
_TestRestorableWidgetState
extends
State
<
_TestRestorableWidget
>
with
RestorationMixin
{
class
_TestRestorableWidgetState
extends
State
<
_TestRestorableWidget
>
with
RestorationMixin
{
final
_TestRestorableProperty
property
=
_TestRestorableProperty
(
10
);
final
_TestRestorableProperty
property
=
_TestRestorableProperty
(
10
);
_TestRestorableProperty
additionalProperty
;
_TestRestorableProperty
?
additionalProperty
;
bool
_rerigisterAdditionalProperty
=
false
;
bool
_rerigisterAdditionalProperty
=
false
;
final
List
<
RestorationBucket
>
restoreStateLog
=
<
RestorationBucket
>[];
final
List
<
RestorationBucket
?>
restoreStateLog
=
<
RestorationBucket
>[];
final
List
<
RestorationBucket
>
toogleBucketLog
=
<
RestorationBucket
>[];
final
List
<
RestorationBucket
?>
toggleBucketLog
=
<
RestorationBucket
>[];
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
restoreStateLog
.
add
(
oldBucket
);
restoreStateLog
.
add
(
oldBucket
);
registerForRestoration
(
property
,
'foo'
);
registerForRestoration
(
property
,
'foo'
);
if
(
_rerigisterAdditionalProperty
&&
additionalProperty
!=
null
)
{
if
(
_rerigisterAdditionalProperty
&&
additionalProperty
!=
null
)
{
registerForRestoration
(
additionalProperty
,
'additional'
);
registerForRestoration
(
additionalProperty
!
,
'additional'
);
}
}
}
}
@override
@override
void
didToggleBucket
(
RestorationBucket
oldBucket
)
{
void
didToggleBucket
(
RestorationBucket
?
oldBucket
)
{
to
o
gleBucketLog
.
add
(
oldBucket
);
to
g
gleBucketLog
.
add
(
oldBucket
);
super
.
didToggleBucket
(
oldBucket
);
super
.
didToggleBucket
(
oldBucket
);
}
}
...
@@ -695,7 +692,7 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
...
@@ -695,7 +692,7 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
void
setProperties
(
VoidCallback
fn
)
=>
setState
(
fn
);
void
setProperties
(
VoidCallback
fn
)
=>
setState
(
fn
);
String
_injectedId
;
String
?
_injectedId
;
void
injectId
(
String
id
)
{
void
injectId
(
String
id
)
{
_injectedId
=
id
;
_injectedId
=
id
;
didUpdateRestorationId
();
didUpdateRestorationId
();
...
@@ -703,12 +700,12 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
...
@@ -703,12 +700,12 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
void
registerAdditionalProperty
({
bool
reregister
=
true
})
{
void
registerAdditionalProperty
({
bool
reregister
=
true
})
{
additionalProperty
??=
_TestRestorableProperty
(
11
);
additionalProperty
??=
_TestRestorableProperty
(
11
);
registerForRestoration
(
additionalProperty
,
'additional'
);
registerForRestoration
(
additionalProperty
!
,
'additional'
);
_rerigisterAdditionalProperty
=
reregister
;
_rerigisterAdditionalProperty
=
reregister
;
}
}
void
unregisterAdditionalProperty
()
{
void
unregisterAdditionalProperty
()
{
unregisterFromRestoration
(
additionalProperty
);
unregisterFromRestoration
(
additionalProperty
!
);
}
}
void
registerPropertyUnderSameId
()
{
void
registerPropertyUnderSameId
()
{
...
@@ -716,7 +713,7 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
...
@@ -716,7 +713,7 @@ class _TestRestorableWidgetState extends State<_TestRestorableWidget> with Resto
}
}
@override
@override
String
get
restorationId
=>
_injectedId
??
widget
.
restorationId
;
String
?
get
restorationId
=>
_injectedId
??
widget
.
restorationId
;
}
}
Map
<
String
,
dynamic
>
_createRawDataSet
()
{
Map
<
String
,
dynamic
>
_createRawDataSet
()
{
...
...
packages/flutter/test/widgets/restoration_scope_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -74,7 +72,7 @@ void main() {
...
@@ -74,7 +72,7 @@ void main() {
manager
.
doSerialization
();
manager
.
doSerialization
();
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
id
);
expect
(
state
.
bucket
!
.
restorationId
,
id
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
id
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
id
),
isTrue
);
});
});
...
@@ -94,8 +92,8 @@ void main() {
...
@@ -94,8 +92,8 @@ void main() {
manager
.
doSerialization
();
manager
.
doSerialization
();
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
});
});
testWidgets
(
'renames existing bucket when new ID is provided'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'renames existing bucket when new ID is provided'
,
(
WidgetTester
tester
)
async
{
...
@@ -115,9 +113,9 @@ void main() {
...
@@ -115,9 +113,9 @@ void main() {
// Claimed existing bucket with data.
// Claimed existing bucket with data.
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
!
.
restorationId
,
'child1'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
// Rename the existing bucket.
// Rename the existing bucket.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -131,8 +129,8 @@ void main() {
...
@@ -131,8 +129,8 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
.
restorationId
,
'something else'
);
expect
(
state
.
bucket
!
.
restorationId
,
'something else'
);
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
,
same
(
bucket
));
});
});
...
@@ -193,7 +191,7 @@ void main() {
...
@@ -193,7 +191,7 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
.
restorationId
,
'foo'
);
expect
(
state
.
bucket
!
.
restorationId
,
'foo'
);
// Change id back to null.
// Change id back to null.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -237,7 +235,7 @@ void main() {
...
@@ -237,7 +235,7 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
.
restorationId
,
'foo'
);
expect
(
state
.
bucket
!
.
restorationId
,
'foo'
);
// Move out of scope again.
// Move out of scope again.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -288,11 +286,11 @@ void main() {
...
@@ -288,11 +286,11 @@ void main() {
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'moving-child'
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
][
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
][
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
final
RestorationBucket
bucket
=
state
.
bucket
;
final
RestorationBucket
bucket
=
state
.
bucket
!
;
state
.
bucket
.
write
(
'value'
,
11
);
state
.
bucket
!
.
write
(
'value'
,
11
);
manager
.
doSerialization
();
manager
.
doSerialization
();
// Move scope.
// Move scope.
...
@@ -316,9 +314,9 @@ void main() {
...
@@ -316,9 +314,9 @@ void main() {
),
),
);
);
manager
.
doSerialization
();
manager
.
doSerialization
();
expect
(
state
.
bucket
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'moving-child'
);
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
,
same
(
bucket
));
expect
(
state
.
bucket
.
read
<
int
>(
'value'
),
11
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'value'
),
11
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
],
isEmpty
);
expect
(
rawData
[
childrenMapKey
][
'fixed'
],
isEmpty
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'moving-child'
),
isTrue
);
...
...
packages/flutter/test/widgets/restoration_scopes_moving_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -123,13 +121,13 @@ class TestWidgetWithCounterChildState extends State<TestWidgetWithCounterChild>
...
@@ -123,13 +121,13 @@ class TestWidgetWithCounterChildState extends State<TestWidgetWithCounterChild>
int
toggleCount
=
0
;
int
toggleCount
=
0
;
@override
@override
void
didToggleBucket
(
RestorationBucket
oldBucket
)
{
void
didToggleBucket
(
RestorationBucket
?
oldBucket
)
{
super
.
didToggleBucket
(
oldBucket
);
super
.
didToggleBucket
(
oldBucket
);
toggleCount
++;
toggleCount
++;
}
}
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
registerForRestoration
(
childRestorationEnabled
,
'childRestorationEnabled'
);
registerForRestoration
(
childRestorationEnabled
,
'childRestorationEnabled'
);
}
}
...
@@ -163,7 +161,7 @@ class TestWidgetWithCounterChildState extends State<TestWidgetWithCounterChild>
...
@@ -163,7 +161,7 @@ class TestWidgetWithCounterChildState extends State<TestWidgetWithCounterChild>
class
Counter
extends
StatefulWidget
{
class
Counter
extends
StatefulWidget
{
const
Counter
({
this
.
restorationId
});
const
Counter
({
this
.
restorationId
});
final
String
restorationId
;
final
String
?
restorationId
;
@override
@override
State
<
Counter
>
createState
()
=>
CounterState
();
State
<
Counter
>
createState
()
=>
CounterState
();
...
@@ -173,10 +171,10 @@ class CounterState extends State<Counter> with RestorationMixin {
...
@@ -173,10 +171,10 @@ class CounterState extends State<Counter> with RestorationMixin {
final
RestorableInt
count
=
RestorableInt
(
0
);
final
RestorableInt
count
=
RestorableInt
(
0
);
@override
@override
String
get
restorationId
=>
widget
.
restorationId
;
String
?
get
restorationId
=>
widget
.
restorationId
;
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
registerForRestoration
(
count
,
'counter'
);
registerForRestoration
(
count
,
'counter'
);
}
}
...
@@ -202,20 +200,20 @@ class CounterState extends State<Counter> with RestorationMixin {
...
@@ -202,20 +200,20 @@ class CounterState extends State<Counter> with RestorationMixin {
}
}
class
TestWidget
extends
StatefulWidget
{
class
TestWidget
extends
StatefulWidget
{
const
TestWidget
({
@
required
this
.
restorationId
});
const
TestWidget
({
required
this
.
restorationId
});
final
String
restorationId
;
final
String
?
restorationId
;
@override
@override
State
<
TestWidget
>
createState
()
=>
TestWidgetState
();
State
<
TestWidget
>
createState
()
=>
TestWidgetState
();
}
}
class
TestWidgetState
extends
State
<
TestWidget
>
with
RestorationMixin
{
class
TestWidgetState
extends
State
<
TestWidget
>
with
RestorationMixin
{
List
<
RestorationBucket
>
buckets
=
<
RestorationBucket
>[];
List
<
RestorationBucket
?
>
buckets
=
<
RestorationBucket
>[];
List
<
bool
>
flags
=
<
bool
>[];
List
<
bool
>
flags
=
<
bool
>[];
@override
@override
void
restoreState
(
RestorationBucket
oldBucket
,
bool
initialRestore
)
{
void
restoreState
(
RestorationBucket
?
oldBucket
,
bool
initialRestore
)
{
buckets
.
add
(
oldBucket
);
buckets
.
add
(
oldBucket
);
flags
.
add
(
initialRestore
);
flags
.
add
(
initialRestore
);
}
}
...
@@ -223,13 +221,13 @@ class TestWidgetState extends State<TestWidget> with RestorationMixin {
...
@@ -223,13 +221,13 @@ class TestWidgetState extends State<TestWidget> with RestorationMixin {
int
toggleCount
=
0
;
int
toggleCount
=
0
;
@override
@override
void
didToggleBucket
(
RestorationBucket
oldBucket
)
{
void
didToggleBucket
(
RestorationBucket
?
oldBucket
)
{
super
.
didToggleBucket
(
oldBucket
);
super
.
didToggleBucket
(
oldBucket
);
toggleCount
++;
toggleCount
++;
}
}
@override
@override
String
get
restorationId
=>
widget
.
restorationId
;
String
?
get
restorationId
=>
widget
.
restorationId
;
@override
@override
Widget
build
(
BuildContext
context
)
{
Widget
build
(
BuildContext
context
)
{
...
...
packages/flutter/test/widgets/root_restoration_scope_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
...
@@ -44,7 +42,7 @@ void main() {
...
@@ -44,7 +42,7 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
0
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
0
);
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
...
@@ -82,7 +80,7 @@ void main() {
...
@@ -82,7 +80,7 @@ void main() {
expect
(
binding
.
firstFrameIsDeferred
,
isFalse
);
expect
(
binding
.
firstFrameIsDeferred
,
isFalse
);
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
});
});
...
@@ -108,7 +106,7 @@ void main() {
...
@@ -108,7 +106,7 @@ void main() {
expect
(
binding
.
firstFrameIsDeferred
,
isFalse
);
expect
(
binding
.
firstFrameIsDeferred
,
isFalse
);
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
rawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
});
});
...
@@ -158,7 +156,7 @@ void main() {
...
@@ -158,7 +156,7 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
// Change ID back to null.
// Change ID back to null.
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
...
@@ -203,7 +201,7 @@ void main() {
...
@@ -203,7 +201,7 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
0
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
0
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
inScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
inScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
// Move out of scope.
// Move out of scope.
...
@@ -232,7 +230,7 @@ void main() {
...
@@ -232,7 +230,7 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
outOfScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
outOfScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
inScopeRawData
,
isEmpty
);
expect
(
inScopeRawData
,
isEmpty
);
...
@@ -255,7 +253,7 @@ void main() {
...
@@ -255,7 +253,7 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
state
.
bucket
.
restorationId
,
'root-child'
);
expect
(
state
.
bucket
!
.
restorationId
,
'root-child'
);
expect
(
outOfScopeRawData
,
isEmpty
);
expect
(
outOfScopeRawData
,
isEmpty
);
expect
(
inScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
expect
(
inScopeRawData
[
childrenMapKey
].
containsKey
(
'root-child'
),
isTrue
);
});
});
...
@@ -280,9 +278,9 @@ void main() {
...
@@ -280,9 +278,9 @@ void main() {
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
binding
.
restorationManager
.
rootBucketAccessed
,
1
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
expect
(
find
.
text
(
'Hello'
),
findsOneWidget
);
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
state
.
bucket
.
write
(
'foo'
,
42
);
state
.
bucket
!
.
write
(
'foo'
,
42
);
expect
(
firstRawData
[
childrenMapKey
][
'root-child'
][
valuesMapKey
][
'foo'
],
42
);
expect
(
firstRawData
[
childrenMapKey
][
'root-child'
][
valuesMapKey
][
'foo'
],
42
);
final
RestorationBucket
firstBucket
=
state
.
bucket
;
final
RestorationBucket
firstBucket
=
state
.
bucket
!
;
// Replace with new root.
// Replace with new root.
final
Map
<
String
,
dynamic
>
secondRawData
=
<
String
,
dynamic
>{
final
Map
<
String
,
dynamic
>
secondRawData
=
<
String
,
dynamic
>{
...
@@ -300,7 +298,7 @@ void main() {
...
@@ -300,7 +298,7 @@ void main() {
firstRoot
.
dispose
();
firstRoot
.
dispose
();
expect
(
state
.
bucket
,
isNot
(
same
(
firstBucket
)));
expect
(
state
.
bucket
,
isNot
(
same
(
firstBucket
)));
expect
(
state
.
bucket
.
read
<
int
>(
'foo'
),
22
);
expect
(
state
.
bucket
!
.
read
<
int
>(
'foo'
),
22
);
});
});
testWidgets
(
'injects null when rootBucket is null'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'injects null when rootBucket is null'
,
(
WidgetTester
tester
)
async
{
...
@@ -361,7 +359,7 @@ void main() {
...
@@ -361,7 +359,7 @@ void main() {
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
final
BucketSpyState
state
=
tester
.
state
(
find
.
byType
(
BucketSpy
));
expect
(
state
.
bucket
,
isNotNull
);
expect
(
state
.
bucket
,
isNotNull
);
binding
.
restorationManager
.
rootBucket
=
SynchronousFuture
<
RestorationBucket
>(
null
);
binding
.
restorationManager
.
rootBucket
=
SynchronousFuture
<
RestorationBucket
?
>(
null
);
await
tester
.
pump
();
await
tester
.
pump
();
root
.
dispose
();
root
.
dispose
();
...
@@ -372,7 +370,7 @@ void main() {
...
@@ -372,7 +370,7 @@ void main() {
}
}
class
TestAutomatedTestWidgetsFlutterBinding
extends
AutomatedTestWidgetsFlutterBinding
{
class
TestAutomatedTestWidgetsFlutterBinding
extends
AutomatedTestWidgetsFlutterBinding
{
MockRestorationManager
_restorationManager
;
late
MockRestorationManager
_restorationManager
;
@override
@override
MockRestorationManager
get
restorationManager
=>
_restorationManager
;
MockRestorationManager
get
restorationManager
=>
_restorationManager
;
...
...
packages/flutter/test/widgets/rotated_box_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/widgets/route_notification_messages_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
@TestOn
(
'chrome'
)
@TestOn
(
'chrome'
)
import
'dart:ui'
;
import
'dart:ui'
;
...
@@ -14,7 +12,7 @@ import 'package:flutter/material.dart';
...
@@ -14,7 +12,7 @@ import 'package:flutter/material.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter/services.dart'
;
class
OnTapPage
extends
StatelessWidget
{
class
OnTapPage
extends
StatelessWidget
{
const
OnTapPage
({
Key
key
,
this
.
id
,
this
.
onTap
})
:
super
(
key:
key
);
const
OnTapPage
({
Key
?
key
,
required
this
.
id
,
required
this
.
onTap
})
:
super
(
key:
key
);
final
String
id
;
final
String
id
;
final
VoidCallback
onTap
;
final
VoidCallback
onTap
;
...
@@ -28,7 +26,7 @@ class OnTapPage extends StatelessWidget {
...
@@ -28,7 +26,7 @@ class OnTapPage extends StatelessWidget {
behavior:
HitTestBehavior
.
opaque
,
behavior:
HitTestBehavior
.
opaque
,
child:
Container
(
child:
Container
(
child:
Center
(
child:
Center
(
child:
Text
(
id
,
style:
Theme
.
of
(
context
).
textTheme
.
headline3
),
child:
Text
(
id
,
style:
Theme
.
of
(
context
)
!
.
textTheme
.
headline3
),
),
),
),
),
),
),
...
@@ -271,7 +269,7 @@ void main() {
...
@@ -271,7 +269,7 @@ void main() {
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
,
reportConfiguration:
true
,
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
}
}
);
);
...
@@ -323,24 +321,24 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
...
@@ -323,24 +321,24 @@ class SimpleRouteInformationParser extends RouteInformationParser<RouteInformati
class
SimpleRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
ChangeNotifier
{
class
SimpleRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
ChangeNotifier
{
SimpleRouterDelegate
({
SimpleRouterDelegate
({
@
required
this
.
builder
,
required
this
.
builder
,
this
.
onPopRoute
,
this
.
onPopRoute
,
this
.
reportConfiguration
=
false
,
this
.
reportConfiguration
=
false
,
});
});
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
late
RouteInformation
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
set
routeInformation
(
RouteInformation
newValue
)
{
_routeInformation
=
newValue
;
_routeInformation
=
newValue
;
notifyListeners
();
notifyListeners
();
}
}
SimpleRouterDelegateBuilder
builder
;
SimpleRouterDelegateBuilder
builder
;
SimpleRouterDelegatePopRoute
onPopRoute
;
SimpleRouterDelegatePopRoute
?
onPopRoute
;
final
bool
reportConfiguration
;
final
bool
reportConfiguration
;
@override
@override
RouteInformation
get
currentConfiguration
{
RouteInformation
?
get
currentConfiguration
{
if
(
reportConfiguration
)
if
(
reportConfiguration
)
return
routeInformation
;
return
routeInformation
;
return
null
;
return
null
;
...
@@ -355,7 +353,7 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
...
@@ -355,7 +353,7 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
@override
@override
Future
<
bool
>
popRoute
()
{
Future
<
bool
>
popRoute
()
{
if
(
onPopRoute
!=
null
)
if
(
onPopRoute
!=
null
)
return
onPopRoute
();
return
onPopRoute
!
();
return
SynchronousFuture
<
bool
>(
true
);
return
SynchronousFuture
<
bool
>(
true
);
}
}
...
@@ -364,7 +362,7 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
...
@@ -364,7 +362,7 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
}
}
class
TestPage
extends
Page
<
void
>
{
class
TestPage
extends
Page
<
void
>
{
const
TestPage
({
LocalKey
key
,
String
name
})
:
super
(
key:
key
,
name:
name
);
const
TestPage
({
LocalKey
?
key
,
String
?
name
})
:
super
(
key:
key
,
name:
name
);
@override
@override
Route
<
void
>
createRoute
(
BuildContext
context
)
{
Route
<
void
>
createRoute
(
BuildContext
context
)
{
...
...
packages/flutter/test/widgets/router_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -20,8 +18,8 @@ void main() {
...
@@ -20,8 +18,8 @@ void main() {
routeInformationProvider:
provider
,
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
}
}
),
),
)
)
...
@@ -43,10 +41,10 @@ void main() {
...
@@ -43,10 +41,10 @@ void main() {
);
);
final
SimpleAsyncRouteInformationParser
parser
=
SimpleAsyncRouteInformationParser
();
final
SimpleAsyncRouteInformationParser
parser
=
SimpleAsyncRouteInformationParser
();
final
SimpleAsyncRouterDelegate
delegate
=
SimpleAsyncRouterDelegate
(
final
SimpleAsyncRouterDelegate
delegate
=
SimpleAsyncRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
if
(
information
==
null
)
if
(
information
==
null
)
return
const
Text
(
'waiting'
);
return
const
Text
(
'waiting'
);
return
Text
(
information
.
location
);
return
Text
(
information
.
location
!
);
}
}
);
);
await
tester
.
runAsync
(()
async
{
await
tester
.
runAsync
(()
async
{
...
@@ -84,10 +82,10 @@ void main() {
...
@@ -84,10 +82,10 @@ void main() {
await
tester
.
pumpWidget
(
buildBoilerPlate
(
await
tester
.
pumpWidget
(
buildBoilerPlate
(
Text
(
'dummy'
,
key:
key
)
Text
(
'dummy'
,
key:
key
)
));
));
final
BuildContext
textContext
=
key
.
currentContext
;
final
BuildContext
textContext
=
key
.
currentContext
!
;
// This should not throw error.
// This should not throw error.
Router
<
dynamic
>
router
=
Router
.
of
(
textContext
,
nullOk:
true
);
Router
<
dynamic
>
?
router
=
Router
.
of
(
textContext
,
nullOk:
true
);
expect
(
router
,
isNull
);
expect
(
router
,
isNull
);
// Test when the nullOk is not specified.
// Test when the nullOk is not specified.
...
@@ -113,8 +111,8 @@ void main() {
...
@@ -113,8 +111,8 @@ void main() {
routeInformationProvider:
provider
,
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
},
},
onPopRoute:
()
{
onPopRoute:
()
{
provider
.
value
=
const
RouteInformation
(
provider
.
value
=
const
RouteInformation
(
...
@@ -149,8 +147,8 @@ void main() {
...
@@ -149,8 +147,8 @@ void main() {
Router
<
RouteInformation
>(
Router
<
RouteInformation
>(
routeInformationProvider:
provider
,
routeInformationProvider:
provider
,
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
},
},
),
),
);
);
...
@@ -169,8 +167,8 @@ void main() {
...
@@ -169,8 +167,8 @@ void main() {
Router
<
RouteInformation
>(
Router
<
RouteInformation
>(
routeInformationParser:
SimpleRouteInformationParser
(),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
},
},
),
),
);
);
...
@@ -191,8 +189,8 @@ void main() {
...
@@ -191,8 +189,8 @@ void main() {
);
);
final
BackButtonDispatcher
dispatcher
=
RootBackButtonDispatcher
();
final
BackButtonDispatcher
dispatcher
=
RootBackButtonDispatcher
();
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
final
SimpleNavigatorRouterDelegate
delegate
=
SimpleNavigatorRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
},
},
onPopPage:
(
Route
<
void
>
route
,
void
result
)
{
onPopPage:
(
Route
<
void
>
route
,
void
result
)
{
provider
.
value
=
const
RouteInformation
(
provider
.
value
=
const
RouteInformation
(
...
@@ -214,7 +212,7 @@ void main() {
...
@@ -214,7 +212,7 @@ void main() {
// Pushes a nameless route.
// Pushes a nameless route.
showDialog
<
void
>(
showDialog
<
void
>(
useRootNavigator:
false
,
useRootNavigator:
false
,
context:
delegate
.
navigatorKey
.
currentContext
,
context:
delegate
.
navigatorKey
.
currentContext
!
,
builder:
(
BuildContext
context
)
=>
const
Text
(
'dialog'
)
builder:
(
BuildContext
context
)
=>
const
Text
(
'dialog'
)
);
);
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
...
@@ -249,15 +247,15 @@ void main() {
...
@@ -249,15 +247,15 @@ void main() {
routeInformationProvider:
provider
,
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
final
BackButtonDispatcher
innerDispatcher
=
ChildBackButtonDispatcher
(
outerDispatcher
);
final
BackButtonDispatcher
innerDispatcher
=
ChildBackButtonDispatcher
(
outerDispatcher
);
innerDispatcher
.
takePriority
();
innerDispatcher
.
takePriority
();
// Creates the sub-router.
// Creates the sub-router.
return
Router
<
RouteInformation
>(
return
Router
<
RouteInformation
>(
backButtonDispatcher:
innerDispatcher
,
backButtonDispatcher:
innerDispatcher
,
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
innerInformation
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
innerInformation
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
},
},
onPopRoute:
()
{
onPopRoute:
()
{
provider
.
value
=
const
RouteInformation
(
provider
.
value
=
const
RouteInformation
(
...
@@ -301,15 +299,15 @@ void main() {
...
@@ -301,15 +299,15 @@ void main() {
routeInformationProvider:
provider
,
routeInformationProvider:
provider
,
routeInformationParser:
SimpleRouteInformationParser
(),
routeInformationParser:
SimpleRouteInformationParser
(),
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
// Creates the sub-router.
// Creates the sub-router.
return
Column
(
return
Column
(
children:
<
Widget
>[
children:
<
Widget
>[
Text
(
information
.
location
),
Text
(
information
!.
location
!
),
Router
<
RouteInformation
>(
Router
<
RouteInformation
>(
backButtonDispatcher:
innerDispatcher1
,
backButtonDispatcher:
innerDispatcher1
,
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
innerInformation
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
innerInformation
)
{
return
Container
();
return
Container
();
},
},
onPopRoute:
()
{
onPopRoute:
()
{
...
@@ -323,7 +321,7 @@ void main() {
...
@@ -323,7 +321,7 @@ void main() {
Router
<
RouteInformation
>(
Router
<
RouteInformation
>(
backButtonDispatcher:
innerDispatcher2
,
backButtonDispatcher:
innerDispatcher2
,
routerDelegate:
SimpleRouterDelegate
(
routerDelegate:
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
innerInformation
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
innerInformation
)
{
return
Container
();
return
Container
();
},
},
onPopRoute:
()
{
onPopRoute:
()
{
...
@@ -373,7 +371,7 @@ void main() {
...
@@ -373,7 +371,7 @@ void main() {
});
});
testWidgets
(
'router does report URL change correctly'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'router does report URL change correctly'
,
(
WidgetTester
tester
)
async
{
RouteInformation
reportedRouteInformation
;
RouteInformation
?
reportedRouteInformation
;
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
onRouterReport:
(
RouteInformation
information
)
{
onRouterReport:
(
RouteInformation
information
)
{
// Makes sure we only report once after manually cleaning up.
// Makes sure we only report once after manually cleaning up.
...
@@ -383,8 +381,8 @@ void main() {
...
@@ -383,8 +381,8 @@ void main() {
);
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
,
reportConfiguration:
true
,
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
}
}
);
);
delegate
.
onPopRoute
=
()
{
delegate
.
onPopRoute
=
()
{
...
@@ -415,7 +413,7 @@ void main() {
...
@@ -415,7 +413,7 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'initial'
),
findsNothing
);
expect
(
find
.
text
(
'initial'
),
findsNothing
);
expect
(
find
.
text
(
'update'
),
findsOneWidget
);
expect
(
find
.
text
(
'update'
),
findsOneWidget
);
expect
(
reportedRouteInformation
.
location
,
'update'
);
expect
(
reportedRouteInformation
!
.
location
,
'update'
);
// The router should not report if only state changes.
// The router should not report if only state changes.
reportedRouteInformation
=
null
;
reportedRouteInformation
=
null
;
...
@@ -433,13 +431,13 @@ void main() {
...
@@ -433,13 +431,13 @@ void main() {
expect
(
result
,
isTrue
);
expect
(
result
,
isTrue
);
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
expect
(
reportedRouteInformation
.
location
,
'popped'
);
expect
(
reportedRouteInformation
!
.
location
,
'popped'
);
});
});
testWidgets
(
'router can be forced to recognize or ignore navigating events'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'router can be forced to recognize or ignore navigating events'
,
(
WidgetTester
tester
)
async
{
RouteInformation
reportedRouteInformation
;
RouteInformation
?
reportedRouteInformation
;
bool
isNavigating
=
false
;
bool
isNavigating
=
false
;
RouteInformation
nextRouteInformation
;
late
RouteInformation
nextRouteInformation
;
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
onRouterReport:
(
RouteInformation
information
)
{
onRouterReport:
(
RouteInformation
information
)
{
// Makes sure we only report once after manually cleaning up.
// Makes sure we only report once after manually cleaning up.
...
@@ -451,9 +449,9 @@ void main() {
...
@@ -451,9 +449,9 @@ void main() {
location:
'initial'
,
location:
'initial'
,
);
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
);
delegate
.
builder
=
(
BuildContext
context
,
RouteInformation
information
)
{
delegate
.
builder
=
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
ElevatedButton
(
return
ElevatedButton
(
child:
Text
(
information
.
location
),
child:
Text
(
information
!.
location
!
),
onPressed:
()
{
onPressed:
()
{
if
(
isNavigating
)
{
if
(
isNavigating
)
{
Router
.
navigate
(
context
,
()
{
Router
.
navigate
(
context
,
()
{
...
@@ -497,11 +495,11 @@ void main() {
...
@@ -497,11 +495,11 @@ void main() {
// report a route information because isNavigating = true.
// report a route information because isNavigating = true.
await
tester
.
tap
(
find
.
byType
(
ElevatedButton
));
await
tester
.
tap
(
find
.
byType
(
ElevatedButton
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
reportedRouteInformation
.
location
,
'update'
);
expect
(
reportedRouteInformation
!
.
location
,
'update'
);
});
});
testWidgets
(
'router does not report when route information is up to date with route information provider'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'router does not report when route information is up to date with route information provider'
,
(
WidgetTester
tester
)
async
{
RouteInformation
reportedRouteInformation
;
RouteInformation
?
reportedRouteInformation
;
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
final
SimpleRouteInformationProvider
provider
=
SimpleRouteInformationProvider
(
onRouterReport:
(
RouteInformation
information
)
{
onRouterReport:
(
RouteInformation
information
)
{
reportedRouteInformation
=
information
;
reportedRouteInformation
=
information
;
...
@@ -511,8 +509,8 @@ void main() {
...
@@ -511,8 +509,8 @@ void main() {
location:
'initial'
,
location:
'initial'
,
);
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
);
delegate
.
builder
=
(
BuildContext
context
,
RouteInformation
routeInformation
)
{
delegate
.
builder
=
(
BuildContext
context
,
RouteInformation
?
routeInformation
)
{
return
Text
(
routeInformation
.
location
);
return
Text
(
routeInformation
!.
location
!
);
};
};
await
tester
.
pumpWidget
(
buildBoilerPlate
(
await
tester
.
pumpWidget
(
buildBoilerPlate
(
...
@@ -546,10 +544,10 @@ void main() {
...
@@ -546,10 +544,10 @@ void main() {
),
),
);
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
final
List
<
Widget
>
children
=
<
Widget
>[];
final
List
<
Widget
>
children
=
<
Widget
>[];
if
(
information
.
location
!=
null
)
if
(
information
!.
location
!
!=
null
)
children
.
add
(
Text
(
information
.
location
));
children
.
add
(
Text
(
information
.
location
!
));
if
(
information
.
state
!=
null
)
if
(
information
.
state
!=
null
)
children
.
add
(
Text
(
information
.
state
.
toString
()));
children
.
add
(
Text
(
information
.
state
.
toString
()));
return
Column
(
return
Column
(
...
@@ -573,7 +571,7 @@ void main() {
...
@@ -573,7 +571,7 @@ void main() {
final
ByteData
routerMessage
=
const
JSONMethodCodec
().
encodeMethodCall
(
final
ByteData
routerMessage
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'pushRouteInformation'
,
testRouteInformation
)
const
MethodCall
(
'pushRouteInformation'
,
testRouteInformation
)
);
);
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
routerMessage
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
routerMessage
,
(
_
)
{
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'testRouteName'
),
findsOneWidget
);
expect
(
find
.
text
(
'testRouteName'
),
findsOneWidget
);
expect
(
find
.
text
(
'state'
),
findsOneWidget
);
expect
(
find
.
text
(
'state'
),
findsOneWidget
);
...
@@ -582,7 +580,7 @@ void main() {
...
@@ -582,7 +580,7 @@ void main() {
const
String
testRouteName
=
'newTestRouteName'
;
const
String
testRouteName
=
'newTestRouteName'
;
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'pushRoute'
,
testRouteName
));
const
MethodCall
(
'pushRoute'
,
testRouteName
));
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'newTestRouteName'
),
findsOneWidget
);
expect
(
find
.
text
(
'newTestRouteName'
),
findsOneWidget
);
});
});
...
@@ -596,8 +594,8 @@ void main() {
...
@@ -596,8 +594,8 @@ void main() {
);
);
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
final
SimpleRouterDelegate
delegate
=
SimpleRouterDelegate
(
reportConfiguration:
true
,
reportConfiguration:
true
,
builder:
(
BuildContext
context
,
RouteInformation
information
)
{
builder:
(
BuildContext
context
,
RouteInformation
?
information
)
{
return
Text
(
information
.
location
);
return
Text
(
information
!.
location
!
);
}
}
);
);
delegate
.
onPopRoute
=
()
{
delegate
.
onPopRoute
=
()
{
...
@@ -617,7 +615,7 @@ void main() {
...
@@ -617,7 +615,7 @@ void main() {
// Pop route through the message channel.
// Pop route through the message channel.
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
final
ByteData
message
=
const
JSONMethodCodec
().
encodeMethodCall
(
const
MethodCall
(
'popRoute'
));
await
ServicesBinding
.
instance
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
ServicesBinding
.
instance
!
.
defaultBinaryMessenger
.
handlePlatformMessage
(
'flutter/navigation'
,
message
,
(
_
)
{
});
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
expect
(
find
.
text
(
'popped'
),
findsOneWidget
);
});
});
...
@@ -631,7 +629,7 @@ Widget buildBoilerPlate(Widget child) {
...
@@ -631,7 +629,7 @@ Widget buildBoilerPlate(Widget child) {
);
);
}
}
typedef
SimpleRouterDelegateBuilder
=
Widget
Function
(
BuildContext
,
RouteInformation
);
typedef
SimpleRouterDelegateBuilder
=
Widget
Function
(
BuildContext
,
RouteInformation
?
);
typedef
SimpleRouterDelegatePopRoute
=
Future
<
bool
>
Function
();
typedef
SimpleRouterDelegatePopRoute
=
Future
<
bool
>
Function
();
typedef
SimpleNavigatorRouterDelegatePopPage
<
T
>
=
bool
Function
(
Route
<
T
>
route
,
T
result
);
typedef
SimpleNavigatorRouterDelegatePopPage
<
T
>
=
bool
Function
(
Route
<
T
>
route
,
T
result
);
typedef
RouterReportRouterInformation
=
void
Function
(
RouteInformation
);
typedef
RouterReportRouterInformation
=
void
Function
(
RouteInformation
);
...
@@ -657,19 +655,19 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
...
@@ -657,19 +655,19 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
this
.
reportConfiguration
=
false
,
this
.
reportConfiguration
=
false
,
});
});
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
?
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
RouteInformation
?
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
set
routeInformation
(
RouteInformation
?
newValue
)
{
_routeInformation
=
newValue
;
_routeInformation
=
newValue
;
notifyListeners
();
notifyListeners
();
}
}
SimpleRouterDelegateBuilder
builder
;
SimpleRouterDelegateBuilder
?
builder
;
SimpleRouterDelegatePopRoute
onPopRoute
;
SimpleRouterDelegatePopRoute
?
onPopRoute
;
final
bool
reportConfiguration
;
final
bool
reportConfiguration
;
@override
@override
RouteInformation
get
currentConfiguration
{
RouteInformation
?
get
currentConfiguration
{
if
(
reportConfiguration
)
if
(
reportConfiguration
)
return
routeInformation
;
return
routeInformation
;
return
null
;
return
null
;
...
@@ -683,26 +681,24 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
...
@@ -683,26 +681,24 @@ class SimpleRouterDelegate extends RouterDelegate<RouteInformation> with ChangeN
@override
@override
Future
<
bool
>
popRoute
()
{
Future
<
bool
>
popRoute
()
{
if
(
onPopRoute
!=
null
)
return
onPopRoute
?.
call
()
??
SynchronousFuture
<
bool
>(
true
);
return
onPopRoute
();
return
SynchronousFuture
<
bool
>(
true
);
}
}
@override
@override
Widget
build
(
BuildContext
context
)
=>
builder
(
context
,
routeInformation
);
Widget
build
(
BuildContext
context
)
=>
builder
!
(
context
,
routeInformation
);
}
}
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
class
SimpleNavigatorRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
PopNavigatorRouterDelegateMixin
<
RouteInformation
>,
ChangeNotifier
{
SimpleNavigatorRouterDelegate
({
SimpleNavigatorRouterDelegate
({
@
required
this
.
builder
,
required
this
.
builder
,
this
.
onPopPage
,
required
this
.
onPopPage
,
});
});
@override
@override
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
GlobalKey
<
NavigatorState
>
navigatorKey
=
GlobalKey
<
NavigatorState
>();
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
late
RouteInformation
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
set
routeInformation
(
RouteInformation
newValue
)
{
_routeInformation
=
newValue
;
_routeInformation
=
newValue
;
notifyListeners
();
notifyListeners
();
...
@@ -733,7 +729,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
...
@@ -733,7 +729,7 @@ class SimpleNavigatorRouterDelegate extends RouterDelegate<RouteInformation> wit
child:
Text
(
'base'
),
child:
Text
(
'base'
),
),
),
MaterialPage
<
void
>(
MaterialPage
<
void
>(
key:
ValueKey
<
String
>(
routeInformation
?.
location
),
key:
ValueKey
<
String
>(
routeInformation
.
location
!
),
child:
builder
(
context
,
routeInformation
),
child:
builder
(
context
,
routeInformation
),
)
)
],
],
...
@@ -746,11 +742,11 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang
...
@@ -746,11 +742,11 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang
this
.
onRouterReport
this
.
onRouterReport
});
});
RouterReportRouterInformation
onRouterReport
;
RouterReportRouterInformation
?
onRouterReport
;
@override
@override
RouteInformation
get
value
=>
_value
;
RouteInformation
get
value
=>
_value
;
RouteInformation
_value
;
late
RouteInformation
_value
;
set
value
(
RouteInformation
newValue
)
{
set
value
(
RouteInformation
newValue
)
{
_value
=
newValue
;
_value
=
newValue
;
notifyListeners
();
notifyListeners
();
...
@@ -758,15 +754,14 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang
...
@@ -758,15 +754,14 @@ class SimpleRouteInformationProvider extends RouteInformationProvider with Chang
@override
@override
void
routerReportsNewRouteInformation
(
RouteInformation
routeInformation
)
{
void
routerReportsNewRouteInformation
(
RouteInformation
routeInformation
)
{
if
(
onRouterReport
!=
null
)
onRouterReport
?.
call
(
routeInformation
);
onRouterReport
(
routeInformation
);
}
}
}
}
class
SimpleAsyncRouteInformationParser
extends
RouteInformationParser
<
RouteInformation
>
{
class
SimpleAsyncRouteInformationParser
extends
RouteInformationParser
<
RouteInformation
>
{
SimpleAsyncRouteInformationParser
();
SimpleAsyncRouteInformationParser
();
Future
<
RouteInformation
>
parsingFuture
;
late
Future
<
RouteInformation
>
parsingFuture
;
@override
@override
Future
<
RouteInformation
>
parseRouteInformation
(
RouteInformation
information
)
{
Future
<
RouteInformation
>
parseRouteInformation
(
RouteInformation
information
)
{
...
@@ -781,18 +776,18 @@ class SimpleAsyncRouteInformationParser extends RouteInformationParser<RouteInfo
...
@@ -781,18 +776,18 @@ class SimpleAsyncRouteInformationParser extends RouteInformationParser<RouteInfo
class
SimpleAsyncRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
ChangeNotifier
{
class
SimpleAsyncRouterDelegate
extends
RouterDelegate
<
RouteInformation
>
with
ChangeNotifier
{
SimpleAsyncRouterDelegate
({
SimpleAsyncRouterDelegate
({
@
required
this
.
builder
,
required
this
.
builder
,
});
});
RouteInformation
get
routeInformation
=>
_routeInformation
;
RouteInformation
?
get
routeInformation
=>
_routeInformation
;
RouteInformation
_routeInformation
;
RouteInformation
?
_routeInformation
;
set
routeInformation
(
RouteInformation
newValue
)
{
set
routeInformation
(
RouteInformation
?
newValue
)
{
_routeInformation
=
newValue
;
_routeInformation
=
newValue
;
notifyListeners
();
notifyListeners
();
}
}
SimpleRouterDelegateBuilder
builder
;
SimpleRouterDelegateBuilder
builder
;
Future
<
void
>
setNewRouteFuture
;
late
Future
<
void
>
setNewRouteFuture
;
@override
@override
Future
<
void
>
setNewRoutePath
(
RouteInformation
configuration
)
{
Future
<
void
>
setNewRoutePath
(
RouteInformation
configuration
)
{
...
...
packages/flutter/test/widgets/row_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -37,7 +35,7 @@ void main() {
...
@@ -37,7 +35,7 @@ void main() {
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -68,7 +66,7 @@ void main() {
...
@@ -68,7 +66,7 @@ void main() {
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -98,7 +96,7 @@ void main() {
...
@@ -98,7 +96,7 @@ void main() {
const
Key
child0Key
=
Key
(
'child0'
);
const
Key
child0Key
=
Key
(
'child0'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -129,7 +127,7 @@ void main() {
...
@@ -129,7 +127,7 @@ void main() {
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -161,7 +159,7 @@ void main() {
...
@@ -161,7 +159,7 @@ void main() {
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -194,7 +192,7 @@ void main() {
...
@@ -194,7 +192,7 @@ void main() {
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child3Key
=
Key
(
'child3'
);
const
Key
child3Key
=
Key
(
'child3'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -227,7 +225,7 @@ void main() {
...
@@ -227,7 +225,7 @@ void main() {
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child2Key
=
Key
(
'child2'
);
const
Key
child2Key
=
Key
(
'child2'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -258,7 +256,7 @@ void main() {
...
@@ -258,7 +256,7 @@ void main() {
const
Key
child0Key
=
Key
(
'child0'
);
const
Key
child0Key
=
Key
(
'child0'
);
const
Key
child1Key
=
Key
(
'child1'
);
const
Key
child1Key
=
Key
(
'child1'
);
final
FlutterExceptionHandler
oldHandler
=
FlutterError
.
onError
;
final
FlutterExceptionHandler
?
oldHandler
=
FlutterError
.
onError
;
dynamic
exception
;
dynamic
exception
;
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
FlutterError
.
onError
=
(
FlutterErrorDetails
details
)
{
exception
??=
details
.
exception
;
exception
??=
details
.
exception
;
...
@@ -344,19 +342,19 @@ void main() {
...
@@ -344,19 +342,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
600.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
600.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -394,19 +392,19 @@ void main() {
...
@@ -394,19 +392,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
200.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
200.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -442,13 +440,13 @@ void main() {
...
@@ -442,13 +440,13 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
400.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
400.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
...
@@ -486,19 +484,19 @@ void main() {
...
@@ -486,19 +484,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
500.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
500.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
600.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
600.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -536,19 +534,19 @@ void main() {
...
@@ -536,19 +534,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
350.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
350.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -588,25 +586,25 @@ void main() {
...
@@ -588,25 +586,25 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
250.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
250.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
450.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
450.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child3Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child3Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
650.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
650.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
,
4
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
,
4
]);
...
@@ -644,19 +642,19 @@ void main() {
...
@@ -644,19 +642,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
550.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
550.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -692,13 +690,13 @@ void main() {
...
@@ -692,13 +690,13 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
150.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
150.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
...
@@ -767,19 +765,19 @@ void main() {
...
@@ -767,19 +765,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
600.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
600.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -817,19 +815,19 @@ void main() {
...
@@ -817,19 +815,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
600.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
600.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
500.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
500.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -865,13 +863,13 @@ void main() {
...
@@ -865,13 +863,13 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
400.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
400.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
...
@@ -909,19 +907,19 @@ void main() {
...
@@ -909,19 +907,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
200.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
200.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
100.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -959,19 +957,19 @@ void main() {
...
@@ -959,19 +957,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
700.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
350.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
350.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -1011,25 +1009,25 @@ void main() {
...
@@ -1011,25 +1009,25 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
650.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
650.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
450.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
450.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
250.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
250.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child3Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child3Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
,
4
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
,
4
]);
...
@@ -1067,19 +1065,19 @@ void main() {
...
@@ -1067,19 +1065,19 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
550.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
550.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
300.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child2Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
200.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
50.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
,
3
]);
...
@@ -1115,13 +1113,13 @@ void main() {
...
@@ -1115,13 +1113,13 @@ void main() {
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child0Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
150.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
150.0
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
renderBox
=
tester
.
renderObject
(
find
.
byKey
(
child1Key
));
expect
(
renderBox
.
size
.
width
,
equals
(
150.0
));
expect
(
renderBox
.
size
.
width
,
equals
(
150.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
expect
(
renderBox
.
size
.
height
,
equals
(
100.0
));
boxParentData
=
renderBox
.
parentData
as
BoxParentData
;
boxParentData
=
renderBox
.
parentData
!
as
BoxParentData
;
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
boxParentData
.
offset
.
dx
,
equals
(
0.0
));
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
expect
(
OrderPainter
.
log
,
<
int
>[
1
,
2
]);
...
...
packages/flutter/test/widgets/rtl_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -26,20 +24,20 @@ void main() {
...
@@ -26,20 +24,20 @@ void main() {
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
const
Padding
(
const
Padding
(
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
null
),
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
Object
()
),
padding:
EdgeInsets
.
only
(
left:
1.0
),
padding:
EdgeInsets
.
only
(
left:
1.0
),
),
),
);
);
await
tester
.
pumpWidget
(
const
Directionality
(
await
tester
.
pumpWidget
(
const
Directionality
(
textDirection:
TextDirection
.
rtl
,
textDirection:
TextDirection
.
rtl
,
child:
Padding
(
child:
Padding
(
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
null
),
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
Object
()
),
padding:
EdgeInsetsDirectional
.
only
(
start:
1.0
),
padding:
EdgeInsetsDirectional
.
only
(
start:
1.0
),
),
),
));
));
await
tester
.
pumpWidget
(
await
tester
.
pumpWidget
(
const
Padding
(
const
Padding
(
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
null
),
key:
GlobalObjectKey
<
State
<
StatefulWidget
>>(
Object
()
),
padding:
EdgeInsets
.
only
(
left:
1.0
),
padding:
EdgeInsets
.
only
(
left:
1.0
),
),
),
);
);
...
...
packages/flutter/test/widgets/run_app_async_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:fake_async/fake_async.dart'
;
import
'package:fake_async/fake_async.dart'
;
...
@@ -11,7 +9,7 @@ import 'package:fake_async/fake_async.dart';
...
@@ -11,7 +9,7 @@ import 'package:fake_async/fake_async.dart';
void
main
(
)
{
void
main
(
)
{
setUp
(()
{
setUp
(()
{
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsFlutterBinding
.
ensureInitialized
();
WidgetsBinding
.
instance
.
resetEpoch
();
WidgetsBinding
.
instance
!
.
resetEpoch
();
});
});
test
(
'WidgetBinding build rendering tree and warm up frame back to back'
,
()
{
test
(
'WidgetBinding build rendering tree and warm up frame back to back'
,
()
{
...
@@ -25,9 +23,9 @@ void main() {
...
@@ -25,9 +23,9 @@ void main() {
),
),
);
);
// Rendering tree is not built synchronously.
// Rendering tree is not built synchronously.
expect
(
WidgetsBinding
.
instance
.
renderViewElement
,
isNull
);
expect
(
WidgetsBinding
.
instance
!
.
renderViewElement
,
isNull
);
fakeAsync
.
flushTimers
();
fakeAsync
.
flushTimers
();
expect
(
WidgetsBinding
.
instance
.
renderViewElement
,
isNotNull
);
expect
(
WidgetsBinding
.
instance
!
.
renderViewElement
,
isNotNull
);
});
});
});
});
}
}
packages/flutter/test/widgets/run_app_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/widgets/safe_area_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/scroll_activity_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -167,7 +165,7 @@ class _PageView62209State extends State<PageView62209> {
...
@@ -167,7 +165,7 @@ class _PageView62209State extends State<PageView62209> {
}
}
class
Carousel62209Page
extends
StatelessWidget
{
class
Carousel62209Page
extends
StatelessWidget
{
const
Carousel62209Page
({
this
.
number
,
Key
key
})
:
super
(
key:
key
);
const
Carousel62209Page
({
required
this
.
number
,
Key
?
key
})
:
super
(
key:
key
);
final
int
number
;
final
int
number
;
...
@@ -178,7 +176,7 @@ class Carousel62209Page extends StatelessWidget {
...
@@ -178,7 +176,7 @@ class Carousel62209Page extends StatelessWidget {
}
}
class
Carousel62209
extends
StatefulWidget
{
class
Carousel62209
extends
StatefulWidget
{
const
Carousel62209
({
Key
key
,
this
.
pages
})
:
super
(
key:
key
);
const
Carousel62209
({
Key
?
key
,
required
this
.
pages
})
:
super
(
key:
key
);
final
List
<
Carousel62209Page
>
pages
;
final
List
<
Carousel62209Page
>
pages
;
...
@@ -188,11 +186,11 @@ class Carousel62209 extends StatefulWidget {
...
@@ -188,11 +186,11 @@ class Carousel62209 extends StatefulWidget {
class
_Carousel62209State
extends
State
<
Carousel62209
>
{
class
_Carousel62209State
extends
State
<
Carousel62209
>
{
// page variables
// page variables
PageController
_pageController
;
late
PageController
_pageController
;
int
_currentPage
=
0
;
int
_currentPage
=
0
;
// controls updates outside of user interaction
// controls updates outside of user interaction
List
<
Carousel62209Page
>
_pages
;
late
List
<
Carousel62209Page
>
_pages
;
bool
_jumpingToPage
=
false
;
bool
_jumpingToPage
=
false
;
@override
@override
...
@@ -216,13 +214,13 @@ class _Carousel62209State extends State<Carousel62209> {
...
@@ -216,13 +214,13 @@ class _Carousel62209State extends State<Carousel62209> {
_pages
=
widget
.
pages
.
toList
();
_pages
=
widget
.
pages
.
toList
();
}
else
{
}
else
{
_jumpingToPage
=
true
;
_jumpingToPage
=
true
;
SchedulerBinding
.
instance
.
addPostFrameCallback
((
_
)
{
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
if
(
mounted
)
{
if
(
mounted
)
{
setState
(()
{
setState
(()
{
_pages
=
widget
.
pages
.
toList
();
_pages
=
widget
.
pages
.
toList
();
_currentPage
=
newPage
;
_currentPage
=
newPage
;
_pageController
.
jumpToPage
(
_currentPage
);
_pageController
.
jumpToPage
(
_currentPage
);
SchedulerBinding
.
instance
.
addPostFrameCallback
((
_
)
{
SchedulerBinding
.
instance
!
.
addPostFrameCallback
((
_
)
{
_jumpingToPage
=
false
;
_jumpingToPage
=
false
;
});
});
});
});
...
@@ -240,7 +238,7 @@ class _Carousel62209State extends State<Carousel62209> {
...
@@ -240,7 +238,7 @@ class _Carousel62209State extends State<Carousel62209> {
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
bool
_handleScrollNotification
(
ScrollNotification
notification
)
{
if
(
notification
is
ScrollUpdateNotification
)
{
if
(
notification
is
ScrollUpdateNotification
)
{
final
int
page
=
_pageController
.
page
.
round
();
final
int
page
=
_pageController
.
page
!
.
round
();
if
(!
_jumpingToPage
&&
_currentPage
!=
page
)
{
if
(!
_jumpingToPage
&&
_currentPage
!=
page
)
{
_currentPage
=
page
;
_currentPage
=
page
;
}
}
...
...
packages/flutter/test/widgets/scroll_aware_image_provider_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
as
ui
show
Image
;
import
'dart:ui'
as
ui
show
Image
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -13,29 +11,29 @@ import '../painting/image_test_utils.dart';
...
@@ -13,29 +11,29 @@ import '../painting/image_test_utils.dart';
void
main
(
)
{
void
main
(
)
{
ui
.
Image
testImage
;
late
ui
.
Image
testImage
;
setUpAll
(()
async
{
setUpAll
(()
async
{
testImage
=
await
createTestImage
(
width:
10
,
height:
10
);
testImage
=
await
createTestImage
(
width:
10
,
height:
10
);
});
});
tearDown
(()
{
tearDown
(()
{
imageCache
.
clear
();
imageCache
?
.
clear
();
});
});
T
_findPhysics
<
T
extends
ScrollPhysics
>(
WidgetTester
tester
)
{
T
_findPhysics
<
T
extends
ScrollPhysics
>(
WidgetTester
tester
)
{
return
Scrollable
.
of
(
find
.
byType
(
TestWidget
).
evaluate
().
first
).
position
.
physics
as
T
;
return
Scrollable
.
of
(
find
.
byType
(
TestWidget
).
evaluate
().
first
)
!
.
position
.
physics
as
T
;
}
}
ScrollMetrics
_findMetrics
(
WidgetTester
tester
)
{
ScrollMetrics
_findMetrics
(
WidgetTester
tester
)
{
return
Scrollable
.
of
(
find
.
byType
(
TestWidget
).
evaluate
().
first
).
position
;
return
Scrollable
.
of
(
find
.
byType
(
TestWidget
).
evaluate
().
first
)
!
.
position
;
}
}
testWidgets
(
'ScrollAwareImageProvider does not delay if widget is not in scrollable'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider does not delay if widget is not in scrollable'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
<
TestWidgetState
>
key
=
GlobalKey
<
TestWidgetState
>();
final
GlobalKey
<
TestWidgetState
>
key
=
GlobalKey
<
TestWidgetState
>();
await
tester
.
pumpWidget
(
TestWidget
(
key
));
await
tester
.
pumpWidget
(
TestWidget
(
key
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -43,19 +41,19 @@ void main() {
...
@@ -43,19 +41,19 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
final
ImageStream
stream
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
final
ImageStream
stream
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
.
hasListeners
,
true
);
expect
(
stream
.
completer
!
.
hasListeners
,
true
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
testImageProvider
.
complete
();
testImageProvider
.
complete
();
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
});
});
testWidgets
(
'ScrollAwareImageProvider does not delay if in scrollable that is not scrolling'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider does not delay if in scrollable that is not scrolling'
,
(
WidgetTester
tester
)
async
{
...
@@ -70,7 +68,7 @@ void main() {
...
@@ -70,7 +68,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -78,19 +76,19 @@ void main() {
...
@@ -78,19 +76,19 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
final
ImageStream
stream
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
final
ImageStream
stream
=
imageProvider
.
resolve
(
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
.
hasListeners
,
true
);
expect
(
stream
.
completer
!
.
hasListeners
,
true
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
testImageProvider
.
complete
();
testImageProvider
.
complete
();
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
expect
(
_findPhysics
<
RecordingPhysics
>(
tester
).
velocities
,
<
double
>[
0
]);
expect
(
_findPhysics
<
RecordingPhysics
>(
tester
).
velocities
,
<
double
>[
0
]);
});
});
...
@@ -110,7 +108,7 @@ void main() {
...
@@ -110,7 +108,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -118,7 +116,7 @@ void main() {
...
@@ -118,7 +116,7 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
scrollController
.
animateTo
(
scrollController
.
animateTo
(
100
,
100
,
...
@@ -142,13 +140,13 @@ void main() {
...
@@ -142,13 +140,13 @@ void main() {
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
.
hasListeners
,
true
);
expect
(
stream
.
completer
!
.
hasListeners
,
true
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
testImageProvider
.
complete
();
testImageProvider
.
complete
();
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
});
});
testWidgets
(
'ScrollAwareImageProvider delays if in scrollable that is scrolling fast'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider delays if in scrollable that is scrolling fast'
,
(
WidgetTester
tester
)
async
{
...
@@ -167,7 +165,7 @@ void main() {
...
@@ -167,7 +165,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -175,7 +173,7 @@ void main() {
...
@@ -175,7 +173,7 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
scrollController
.
animateTo
(
scrollController
.
animateTo
(
3000
,
3000
,
...
@@ -200,22 +198,22 @@ void main() {
...
@@ -200,22 +198,22 @@ void main() {
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
expect
(
physics
.
velocities
.
last
,
0
);
expect
(
physics
.
velocities
.
last
,
0
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
testImageProvider
.
configuration
,
ImageConfiguration
.
empty
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
,
isNotNull
);
expect
(
stream
.
completer
.
hasListeners
,
true
);
expect
(
stream
.
completer
!
.
hasListeners
,
true
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
testImageProvider
.
complete
();
testImageProvider
.
complete
();
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
});
});
testWidgets
(
'ScrollAwareImageProvider delays if in scrollable that is scrolling fast and fizzles if disposed'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider delays if in scrollable that is scrolling fast and fizzles if disposed'
,
(
WidgetTester
tester
)
async
{
...
@@ -234,7 +232,7 @@ void main() {
...
@@ -234,7 +232,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
keys
.
last
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -242,7 +240,7 @@ void main() {
...
@@ -242,7 +240,7 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
scrollController
.
animateTo
(
scrollController
.
animateTo
(
3000
,
3000
,
...
@@ -267,8 +265,8 @@ void main() {
...
@@ -267,8 +265,8 @@ void main() {
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
// as if we had picked a context that scrolled out of the tree.
// as if we had picked a context that scrolled out of the tree.
context
.
dispose
();
context
.
dispose
();
...
@@ -279,12 +277,12 @@ void main() {
...
@@ -279,12 +277,12 @@ void main() {
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
testImageProvider
.
complete
();
testImageProvider
.
complete
();
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
});
});
testWidgets
(
'ScrollAwareImageProvider resolves from ImageCache and does not set completer twice'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider resolves from ImageCache and does not set completer twice'
,
(
WidgetTester
tester
)
async
{
...
@@ -299,7 +297,7 @@ void main() {
...
@@ -299,7 +297,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -307,7 +305,7 @@ void main() {
...
@@ -307,7 +305,7 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
final
ControllablePhysics
physics
=
_findPhysics
<
ControllablePhysics
>(
tester
);
final
ControllablePhysics
physics
=
_findPhysics
<
ControllablePhysics
>(
tester
);
physics
.
recommendDeferredLoadingValue
=
true
;
physics
.
recommendDeferredLoadingValue
=
true
;
...
@@ -316,28 +314,28 @@ void main() {
...
@@ -316,28 +314,28 @@ void main() {
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
// Simulate a case where someone else has managed to complete this stream -
// Simulate a case where someone else has managed to complete this stream -
// so it can land in the cache right before we stop scrolling fast.
// so it can land in the cache right before we stop scrolling fast.
// If we miss the early return, we will fail.
// If we miss the early return, we will fail.
testImageProvider
.
complete
();
testImageProvider
.
complete
();
imageCache
.
putIfAbsent
(
testImageProvider
,
()
=>
testImageProvider
.
load
(
testImageProvider
,
PaintingBinding
.
instance
.
instantiateImageCodec
));
imageCache
!.
putIfAbsent
(
testImageProvider
,
()
=>
testImageProvider
.
load
(
testImageProvider
,
PaintingBinding
.
instance
!
.
instantiateImageCodec
));
// We've stopped scrolling fast.
// We've stopped scrolling fast.
physics
.
recommendDeferredLoadingValue
=
false
;
physics
.
recommendDeferredLoadingValue
=
false
;
await
tester
.
idle
();
await
tester
.
idle
();
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
});
});
testWidgets
(
'ScrollAwareImageProvider does not block LRU updates to image cache'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ScrollAwareImageProvider does not block LRU updates to image cache'
,
(
WidgetTester
tester
)
async
{
final
int
oldSize
=
imageCache
.
maximumSize
;
final
int
oldSize
=
imageCache
!
.
maximumSize
;
imageCache
.
maximumSize
=
1
;
imageCache
!
.
maximumSize
=
1
;
final
GlobalKey
<
TestWidgetState
>
key
=
GlobalKey
<
TestWidgetState
>();
final
GlobalKey
<
TestWidgetState
>
key
=
GlobalKey
<
TestWidgetState
>();
final
ScrollController
scrollController
=
ScrollController
();
final
ScrollController
scrollController
=
ScrollController
();
...
@@ -350,7 +348,7 @@ void main() {
...
@@ -350,7 +348,7 @@ void main() {
),
),
));
));
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
);
final
DisposableBuildContext
context
=
DisposableBuildContext
(
key
.
currentState
!
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider
=
TestImageProvider
(
testImage
);
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
final
ScrollAwareImageProvider
<
TestImageProvider
>
imageProvider
=
ScrollAwareImageProvider
<
TestImageProvider
>(
context:
context
,
context:
context
,
...
@@ -358,7 +356,7 @@ void main() {
...
@@ -358,7 +356,7 @@ void main() {
);
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
final
ControllablePhysics
physics
=
_findPhysics
<
ControllablePhysics
>(
tester
);
final
ControllablePhysics
physics
=
_findPhysics
<
ControllablePhysics
>(
tester
);
physics
.
recommendDeferredLoadingValue
=
true
;
physics
.
recommendDeferredLoadingValue
=
true
;
...
@@ -367,41 +365,41 @@ void main() {
...
@@ -367,41 +365,41 @@ void main() {
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
testImageProvider
.
configuration
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
stream
.
completer
,
null
);
expect
(
imageCache
.
currentSize
,
0
);
expect
(
imageCache
!
.
currentSize
,
0
);
// Occupy the only slot in the cache with another image.
// Occupy the only slot in the cache with another image.
final
TestImageProvider
testImageProvider2
=
TestImageProvider
(
testImage
);
final
TestImageProvider
testImageProvider2
=
TestImageProvider
(
testImage
);
testImageProvider2
.
complete
();
testImageProvider2
.
complete
();
await
precacheImage
(
testImageProvider2
,
context
.
context
);
await
precacheImage
(
testImageProvider2
,
context
.
context
!
);
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
containsKey
(
testImageProvider2
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider2
),
true
);
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
// Complete the original image while we're still scrolling fast.
// Complete the original image while we're still scrolling fast.
testImageProvider
.
complete
();
testImageProvider
.
complete
();
stream
.
setCompleter
(
testImageProvider
.
load
(
testImageProvider
,
PaintingBinding
.
instance
.
instantiateImageCodec
));
stream
.
setCompleter
(
testImageProvider
.
load
(
testImageProvider
,
PaintingBinding
.
instance
!
.
instantiateImageCodec
));
// Verify that this hasn't changed the cache state yet
// Verify that this hasn't changed the cache state yet
expect
(
imageCache
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
false
);
expect
(
imageCache
.
containsKey
(
testImageProvider2
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider2
),
true
);
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
await
tester
.
pump
();
await
tester
.
pump
();
// After pumping a frame, the original image should be in the cache because
// After pumping a frame, the original image should be in the cache because
// it took the LRU slot.
// it took the LRU slot.
expect
(
imageCache
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider
),
true
);
expect
(
imageCache
.
containsKey
(
testImageProvider2
),
false
);
expect
(
imageCache
!
.
containsKey
(
testImageProvider2
),
false
);
expect
(
imageCache
.
currentSize
,
1
);
expect
(
imageCache
!
.
currentSize
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
expect
(
testImageProvider
.
loadCallCount
,
1
);
imageCache
.
maximumSize
=
oldSize
;
imageCache
!
.
maximumSize
=
oldSize
;
});
});
}
}
class
TestWidget
extends
StatefulWidget
{
class
TestWidget
extends
StatefulWidget
{
const
TestWidget
(
Key
key
)
:
super
(
key:
key
);
const
TestWidget
(
Key
?
key
)
:
super
(
key:
key
);
@override
@override
State
<
TestWidget
>
createState
()
=>
TestWidgetState
();
State
<
TestWidget
>
createState
()
=>
TestWidgetState
();
...
@@ -413,13 +411,13 @@ class TestWidgetState extends State<TestWidget> {
...
@@ -413,13 +411,13 @@ class TestWidgetState extends State<TestWidget> {
}
}
class
RecordingPhysics
extends
ScrollPhysics
{
class
RecordingPhysics
extends
ScrollPhysics
{
RecordingPhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
RecordingPhysics
({
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
final
List
<
double
>
velocities
=
<
double
>[];
final
List
<
double
>
velocities
=
<
double
>[];
@override
@override
RecordingPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
RecordingPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
RecordingPhysics
(
parent:
buildParent
(
ancestor
));
return
RecordingPhysics
(
parent:
buildParent
(
ancestor
)
!
);
}
}
@override
@override
...
@@ -433,13 +431,13 @@ class RecordingPhysics extends ScrollPhysics {
...
@@ -433,13 +431,13 @@ class RecordingPhysics extends ScrollPhysics {
// times without worrying about actual scrolling mechanics.
// times without worrying about actual scrolling mechanics.
// ignore: must_be_immutable
// ignore: must_be_immutable
class
ControllablePhysics
extends
ScrollPhysics
{
class
ControllablePhysics
extends
ScrollPhysics
{
ControllablePhysics
({
ScrollPhysics
parent
})
:
super
(
parent:
parent
);
ControllablePhysics
({
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
bool
recommendDeferredLoadingValue
=
false
;
bool
recommendDeferredLoadingValue
=
false
;
@override
@override
ControllablePhysics
applyTo
(
ScrollPhysics
ancestor
)
{
ControllablePhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
ControllablePhysics
(
parent:
buildParent
(
ancestor
));
return
ControllablePhysics
(
parent:
buildParent
(
ancestor
)
!
);
}
}
@override
@override
...
...
packages/flutter/test/widgets/scroll_behavior_test.dart
View file @
3f56178d
...
@@ -2,13 +2,11 @@
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
GestureVelocityTrackerBuilder
lastCreatedBuilder
;
late
GestureVelocityTrackerBuilder
lastCreatedBuilder
;
class
TestScrollBehavior
extends
ScrollBehavior
{
class
TestScrollBehavior
extends
ScrollBehavior
{
const
TestScrollBehavior
(
this
.
flag
);
const
TestScrollBehavior
(
this
.
flag
);
...
@@ -36,15 +34,15 @@ class TestScrollBehavior extends ScrollBehavior {
...
@@ -36,15 +34,15 @@ class TestScrollBehavior extends ScrollBehavior {
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Inherited ScrollConfiguration changed'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Inherited ScrollConfiguration changed'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
(
debugLabel:
'scrollable'
);
final
GlobalKey
key
=
GlobalKey
(
debugLabel:
'scrollable'
);
TestScrollBehavior
behavior
;
TestScrollBehavior
?
behavior
;
ScrollPositionWithSingleContext
position
;
late
ScrollPositionWithSingleContext
position
;
final
Widget
scrollView
=
SingleChildScrollView
(
final
Widget
scrollView
=
SingleChildScrollView
(
key:
key
,
key:
key
,
child:
Builder
(
child:
Builder
(
builder:
(
BuildContext
context
)
{
builder:
(
BuildContext
context
)
{
behavior
=
ScrollConfiguration
.
of
(
context
)
as
TestScrollBehavior
;
behavior
=
ScrollConfiguration
.
of
(
context
)
as
TestScrollBehavior
;
position
=
Scrollable
.
of
(
context
).
position
as
ScrollPositionWithSingleContext
;
position
=
Scrollable
.
of
(
context
)
!
.
position
as
ScrollPositionWithSingleContext
;
return
Container
(
height:
1000.0
);
return
Container
(
height:
1000.0
);
},
},
),
),
...
@@ -58,7 +56,7 @@ void main() {
...
@@ -58,7 +56,7 @@ void main() {
);
);
expect
(
behavior
,
isNotNull
);
expect
(
behavior
,
isNotNull
);
expect
(
behavior
.
flag
,
isTrue
);
expect
(
behavior
!
.
flag
,
isTrue
);
expect
(
position
.
physics
,
isA
<
ClampingScrollPhysics
>());
expect
(
position
.
physics
,
isA
<
ClampingScrollPhysics
>());
expect
(
lastCreatedBuilder
(
const
PointerDownEvent
()),
isA
<
VelocityTracker
>());
expect
(
lastCreatedBuilder
(
const
PointerDownEvent
()),
isA
<
VelocityTracker
>());
ScrollMetrics
metrics
=
position
.
copyWith
();
ScrollMetrics
metrics
=
position
.
copyWith
();
...
@@ -74,7 +72,7 @@ void main() {
...
@@ -74,7 +72,7 @@ void main() {
);
);
expect
(
behavior
,
isNotNull
);
expect
(
behavior
,
isNotNull
);
expect
(
behavior
.
flag
,
isFalse
);
expect
(
behavior
!
.
flag
,
isFalse
);
expect
(
position
.
physics
,
isA
<
BouncingScrollPhysics
>());
expect
(
position
.
physics
,
isA
<
BouncingScrollPhysics
>());
expect
(
lastCreatedBuilder
(
const
PointerDownEvent
()),
isA
<
IOSScrollViewFlingVelocityTracker
>());
expect
(
lastCreatedBuilder
(
const
PointerDownEvent
()),
isA
<
IOSScrollViewFlingVelocityTracker
>());
// Regression test for https://github.com/flutter/flutter/issues/5856
// Regression test for https://github.com/flutter/flutter/issues/5856
...
...
packages/flutter/test/widgets/scroll_controller_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/scroll_events_test.dart
View file @
3f56178d
...
@@ -2,15 +2,12 @@
...
@@ -2,15 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:meta/meta.dart'
;
Widget
_buildScroller
(
{
List
<
String
>
log
})
{
Widget
_buildScroller
(
{
required
List
<
String
>
log
})
{
return
NotificationListener
<
ScrollNotification
>(
return
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
notification
)
{
onNotification:
(
ScrollNotification
notification
)
{
if
(
notification
is
ScrollStartNotification
)
{
if
(
notification
is
ScrollStartNotification
)
{
...
@@ -29,7 +26,7 @@ Widget _buildScroller({ List<String> log }) {
...
@@ -29,7 +26,7 @@ Widget _buildScroller({ List<String> log }) {
}
}
void
main
(
)
{
void
main
(
)
{
Completer
<
void
>
animateTo
(
WidgetTester
tester
,
double
newScrollOffset
,
{
@
required
Duration
duration
})
{
Completer
<
void
>
animateTo
(
WidgetTester
tester
,
double
newScrollOffset
,
{
required
Duration
duration
})
{
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
Completer
<
void
>
completer
=
Completer
<
void
>();
final
ScrollableState
scrollable
=
tester
.
state
(
find
.
byType
(
Scrollable
));
final
ScrollableState
scrollable
=
tester
.
state
(
find
.
byType
(
Scrollable
));
scrollable
.
position
.
animateTo
(
newScrollOffset
,
duration:
duration
,
curve:
Curves
.
linear
).
whenComplete
(
completer
.
complete
);
scrollable
.
position
.
animateTo
(
newScrollOffset
,
duration:
duration
,
curve:
Curves
.
linear
).
whenComplete
(
completer
.
complete
);
...
...
packages/flutter/test/widgets/scroll_interaction_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/scroll_notification_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
...
@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Scroll notification basics'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Scroll notification basics'
,
(
WidgetTester
tester
)
async
{
ScrollNotification
notification
;
late
ScrollNotification
notification
;
await
tester
.
pumpWidget
(
NotificationListener
<
ScrollNotification
>(
await
tester
.
pumpWidget
(
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
onNotification:
(
ScrollNotification
value
)
{
...
@@ -30,7 +28,7 @@ void main() {
...
@@ -30,7 +28,7 @@ void main() {
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
depth
,
equals
(
0
));
final
ScrollStartNotification
start
=
notification
as
ScrollStartNotification
;
final
ScrollStartNotification
start
=
notification
as
ScrollStartNotification
;
expect
(
start
.
dragDetails
,
isNotNull
);
expect
(
start
.
dragDetails
,
isNotNull
);
expect
(
start
.
dragDetails
.
globalPosition
,
equals
(
const
Offset
(
100.0
,
100.0
)));
expect
(
start
.
dragDetails
!
.
globalPosition
,
equals
(
const
Offset
(
100.0
,
100.0
)));
await
gesture
.
moveBy
(
const
Offset
(-
10.0
,
-
10.0
));
await
gesture
.
moveBy
(
const
Offset
(-
10.0
,
-
10.0
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
...
@@ -38,8 +36,8 @@ void main() {
...
@@ -38,8 +36,8 @@ void main() {
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
depth
,
equals
(
0
));
final
ScrollUpdateNotification
update
=
notification
as
ScrollUpdateNotification
;
final
ScrollUpdateNotification
update
=
notification
as
ScrollUpdateNotification
;
expect
(
update
.
dragDetails
,
isNotNull
);
expect
(
update
.
dragDetails
,
isNotNull
);
expect
(
update
.
dragDetails
.
globalPosition
,
equals
(
const
Offset
(
90.0
,
90.0
)));
expect
(
update
.
dragDetails
!
.
globalPosition
,
equals
(
const
Offset
(
90.0
,
90.0
)));
expect
(
update
.
dragDetails
.
delta
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
expect
(
update
.
dragDetails
!
.
delta
,
equals
(
const
Offset
(
0.0
,
-
10.0
)));
await
gesture
.
up
();
await
gesture
.
up
();
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
...
@@ -47,7 +45,7 @@ void main() {
...
@@ -47,7 +45,7 @@ void main() {
expect
(
notification
.
depth
,
equals
(
0
));
expect
(
notification
.
depth
,
equals
(
0
));
final
ScrollEndNotification
end
=
notification
as
ScrollEndNotification
;
final
ScrollEndNotification
end
=
notification
as
ScrollEndNotification
;
expect
(
end
.
dragDetails
,
isNotNull
);
expect
(
end
.
dragDetails
,
isNotNull
);
expect
(
end
.
dragDetails
.
velocity
,
equals
(
Velocity
.
zero
));
expect
(
end
.
dragDetails
!
.
velocity
,
equals
(
Velocity
.
zero
));
});
});
testWidgets
(
'Scroll notification depth'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Scroll notification depth'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/scroll_physics_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -12,20 +10,20 @@ import 'package:flutter_test/flutter_test.dart';
...
@@ -12,20 +10,20 @@ import 'package:flutter_test/flutter_test.dart';
class
TestScrollPhysics
extends
ScrollPhysics
{
class
TestScrollPhysics
extends
ScrollPhysics
{
const
TestScrollPhysics
({
const
TestScrollPhysics
({
this
.
name
,
required
this
.
name
,
ScrollPhysics
parent
ScrollPhysics
?
parent
})
:
super
(
parent:
parent
);
})
:
super
(
parent:
parent
);
final
String
name
;
final
String
name
;
@override
@override
TestScrollPhysics
applyTo
(
ScrollPhysics
ancestor
)
{
TestScrollPhysics
applyTo
(
ScrollPhysics
?
ancestor
)
{
return
TestScrollPhysics
(
return
TestScrollPhysics
(
name:
name
,
name:
name
,
parent:
parent
?.
applyTo
(
ancestor
)
??
ancestor
,
parent:
parent
?.
applyTo
(
ancestor
)
??
ancestor
!
,
);
);
}
}
TestScrollPhysics
get
namedParent
=>
parent
as
TestScrollPhysics
;
TestScrollPhysics
get
namedParent
=>
parent
!
as
TestScrollPhysics
;
String
get
names
=>
parent
==
null
?
name
:
'
$name
${namedParent.names}
'
;
String
get
names
=>
parent
==
null
?
name
:
'
$name
${namedParent.names}
'
;
@override
@override
...
@@ -69,7 +67,7 @@ void main() {
...
@@ -69,7 +67,7 @@ void main() {
const
ScrollPhysics
always
=
AlwaysScrollableScrollPhysics
();
const
ScrollPhysics
always
=
AlwaysScrollableScrollPhysics
();
const
ScrollPhysics
page
=
PageScrollPhysics
();
const
ScrollPhysics
page
=
PageScrollPhysics
();
String
types
(
ScrollPhysics
s
)
=>
s
.
parent
==
null
?
'
${s.runtimeType}
'
:
'
${s.runtimeType}
${types(s
.parent)}
'
;
String
types
(
ScrollPhysics
?
value
)
=>
value
!.
parent
==
null
?
'
${value.runtimeType}
'
:
'
${value.runtimeType}
${types(value
.parent)}
'
;
expect
(
expect
(
types
(
bounce
.
applyTo
(
clamp
.
applyTo
(
never
.
applyTo
(
always
.
applyTo
(
page
))))),
types
(
bounce
.
applyTo
(
clamp
.
applyTo
(
never
.
applyTo
(
always
.
applyTo
(
page
))))),
...
@@ -112,13 +110,13 @@ void main() {
...
@@ -112,13 +110,13 @@ void main() {
// Calls to createBallisticSimulation may happen on every frame (i.e. when the maxScrollExtent changes)
// Calls to createBallisticSimulation may happen on every frame (i.e. when the maxScrollExtent changes)
// Changing velocity for time 0 may cause a sudden, unwanted damping/speedup effect
// Changing velocity for time 0 may cause a sudden, unwanted damping/speedup effect
expect
(
bounce
.
createBallisticSimulation
(
position
,
1000
).
dx
(
0
),
moreOrLessEquals
(
1000
));
expect
(
bounce
.
createBallisticSimulation
(
position
,
1000
)
!
.
dx
(
0
),
moreOrLessEquals
(
1000
));
expect
(
clamp
.
createBallisticSimulation
(
position
,
1000
).
dx
(
0
),
moreOrLessEquals
(
1000
));
expect
(
clamp
.
createBallisticSimulation
(
position
,
1000
)
!
.
dx
(
0
),
moreOrLessEquals
(
1000
));
expect
(
page
.
createBallisticSimulation
(
position
,
1000
).
dx
(
0
),
moreOrLessEquals
(
1000
));
expect
(
page
.
createBallisticSimulation
(
position
,
1000
)
!
.
dx
(
0
),
moreOrLessEquals
(
1000
));
});
});
group
(
'BouncingScrollPhysics test'
,
()
{
group
(
'BouncingScrollPhysics test'
,
()
{
BouncingScrollPhysics
physicsUnderTest
;
late
BouncingScrollPhysics
physicsUnderTest
;
setUp
(()
{
setUp
(()
{
physicsUnderTest
=
const
BouncingScrollPhysics
();
physicsUnderTest
=
const
BouncingScrollPhysics
();
...
@@ -253,7 +251,7 @@ void main() {
...
@@ -253,7 +251,7 @@ void main() {
axisDirection:
AxisDirection
.
down
,
axisDirection:
AxisDirection
.
down
,
);
);
expect
(
position
.
pixels
,
pixels
);
expect
(
position
.
pixels
,
pixels
);
FlutterError
error
;
late
FlutterError
error
;
try
{
try
{
physics
.
applyBoundaryConditions
(
position
,
pixels
);
physics
.
applyBoundaryConditions
(
position
,
pixels
);
}
on
FlutterError
catch
(
e
)
{
}
on
FlutterError
catch
(
e
)
{
...
...
packages/flutter/test/widgets/scroll_position_test.dart
View file @
3f56178d
...
@@ -2,11 +2,8 @@
...
@@ -2,11 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
;
import
'dart:ui'
;
import
'package:meta/meta.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
@@ -16,8 +13,8 @@ ScrollController _controller = ScrollController(
...
@@ -16,8 +13,8 @@ ScrollController _controller = ScrollController(
class
ThePositiveNumbers
extends
StatelessWidget
{
class
ThePositiveNumbers
extends
StatelessWidget
{
const
ThePositiveNumbers
({
const
ThePositiveNumbers
({
Key
key
,
Key
?
key
,
@
required
this
.
from
,
required
this
.
from
,
})
:
super
(
key:
key
);
})
:
super
(
key:
key
);
final
int
from
;
final
int
from
;
@override
@override
...
@@ -93,7 +90,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
...
@@ -93,7 +90,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
expect
(
find
.
text
(
'16'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'16'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'100'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'100'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
navigatorKey
.
currentState
.
pushNamed
(
'/second'
);
navigatorKey
.
currentState
!
.
pushNamed
(
'/second'
);
await
tester
.
pump
();
// navigating always takes two frames, one to start...
await
tester
.
pump
();
// navigating always takes two frames, one to start...
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// ...and one to end the transition
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
// ...and one to end the transition
...
@@ -114,7 +111,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
...
@@ -114,7 +111,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
expect
(
find
.
text
(
'10010'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'10010'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'10100'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
expect
(
find
.
text
(
'10100'
),
findsNothing
,
reason:
'with maintainState:
$maintainState
'
);
navigatorKey
.
currentState
.
pop
();
navigatorKey
.
currentState
!
.
pop
();
await
tester
.
pump
();
// again, navigating always takes two frames
await
tester
.
pump
();
// again, navigating always takes two frames
// Ensure we don't clamp the scroll offset even during the navigation.
// Ensure we don't clamp the scroll offset even during the navigation.
...
...
packages/flutter/test/widgets/scroll_simulation_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/scroll_view_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
@@ -33,7 +31,7 @@ class WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliza
...
@@ -33,7 +31,7 @@ class WidgetsLocalizationsDelegate extends LocalizationsDelegate<WidgetsLocaliza
bool
shouldReload
(
WidgetsLocalizationsDelegate
old
)
=>
false
;
bool
shouldReload
(
WidgetsLocalizationsDelegate
old
)
=>
false
;
}
}
Widget
textFieldBoilerplate
(
{
Widget
child
})
{
Widget
textFieldBoilerplate
(
{
required
Widget
child
})
{
return
MaterialApp
(
return
MaterialApp
(
home:
Localizations
(
home:
Localizations
(
locale:
const
Locale
(
'en'
,
'US'
),
locale:
const
Locale
(
'en'
,
'US'
),
...
@@ -125,11 +123,11 @@ void main() {
...
@@ -125,11 +123,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'ListView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -159,11 +157,11 @@ void main() {
...
@@ -159,11 +157,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'ListView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -195,11 +193,11 @@ void main() {
...
@@ -195,11 +193,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'ListView.separated dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.separated dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -230,11 +228,11 @@ void main() {
...
@@ -230,11 +228,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'GridView dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -264,11 +262,11 @@ void main() {
...
@@ -264,11 +262,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'GridView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.builder dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -299,11 +297,11 @@ void main() {
...
@@ -299,11 +297,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'GridView.count dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.count dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -333,11 +331,11 @@ void main() {
...
@@ -333,11 +331,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'GridView.extent dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.extent dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -367,11 +365,11 @@ void main() {
...
@@ -367,11 +365,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'GridView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.custom dismiss keyboard onDrag test'
,
(
WidgetTester
tester
)
async
{
...
@@ -404,11 +402,11 @@ void main() {
...
@@ -404,11 +402,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'ListView dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -435,11 +433,11 @@ void main() {
...
@@ -435,11 +433,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'ListView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -469,11 +467,11 @@ void main() {
...
@@ -469,11 +467,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'ListView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -505,11 +503,11 @@ void main() {
...
@@ -505,11 +503,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'ListView.separated dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView.separated dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -540,11 +538,11 @@ void main() {
...
@@ -540,11 +538,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'GridView dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -574,11 +572,11 @@ void main() {
...
@@ -574,11 +572,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'GridView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.builder dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -609,11 +607,11 @@ void main() {
...
@@ -609,11 +607,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'GridView.count dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.count dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -643,11 +641,11 @@ void main() {
...
@@ -643,11 +641,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'GridView.extent dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.extent dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -677,11 +675,11 @@ void main() {
...
@@ -677,11 +675,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'GridView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'GridView.custom dismiss keyboard manual test'
,
(
WidgetTester
tester
)
async
{
...
@@ -714,11 +712,11 @@ void main() {
...
@@ -714,11 +712,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
});
});
testWidgets
(
'ListView restart ballistic activity out of range'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'ListView restart ballistic activity out of range'
,
(
WidgetTester
tester
)
async
{
...
@@ -831,11 +829,11 @@ void main() {
...
@@ -831,11 +829,11 @@ void main() {
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
Finder
finder
=
find
.
byType
(
TextField
).
first
;
final
TextField
textField
=
tester
.
widget
(
finder
);
final
TextField
textField
=
tester
.
widget
(
finder
);
await
tester
.
showKeyboard
(
finder
);
await
tester
.
showKeyboard
(
finder
);
expect
(
textField
.
focusNode
.
hasFocus
,
isTrue
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isTrue
);
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
drag
(
finder
,
const
Offset
(
0.0
,
-
40.0
));
await
tester
.
pumpAndSettle
();
await
tester
.
pumpAndSettle
();
expect
(
textField
.
focusNode
.
hasFocus
,
isFalse
);
expect
(
textField
.
focusNode
!
.
hasFocus
,
isFalse
);
});
});
testWidgets
(
'Can jumpTo during drag'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Can jumpTo during drag'
,
(
WidgetTester
tester
)
async
{
...
@@ -1164,41 +1162,6 @@ void main() {
...
@@ -1164,41 +1162,6 @@ void main() {
// A separatorBuilder that always returns a Divider is fine
// A separatorBuilder that always returns a Divider is fine
await
tester
.
pumpWidget
(
buildFrame
(
const
Divider
()));
await
tester
.
pumpWidget
(
buildFrame
(
const
Divider
()));
expect
(
tester
.
takeException
(),
isNull
);
expect
(
tester
.
takeException
(),
isNull
);
// A separatorBuilder that returns null throws a FlutterError
await
tester
.
pumpWidget
(
buildFrame
(
null
));
expect
(
tester
.
takeException
(),
isFlutterError
);
expect
(
find
.
byType
(
ErrorWidget
),
findsOneWidget
);
});
testWidgets
(
'itemBuilder can return null'
,
(
WidgetTester
tester
)
async
{
const
List
<
String
>
listOfValues
=
<
String
>[
'ALPHA'
,
'BETA'
,
'GAMMA'
,
'DELTA'
];
const
Key
key
=
Key
(
'list'
);
const
int
RENDER_NULL_AT
=
2
;
// only render the first 2 values
Widget
buildFrame
()
{
return
MaterialApp
(
home:
Material
(
child:
ListView
.
builder
(
key:
key
,
itemBuilder:
(
BuildContext
context
,
int
index
)
{
if
(
index
==
RENDER_NULL_AT
)
{
return
null
;
}
return
Text
(
listOfValues
[
index
]);
},
itemCount:
listOfValues
.
length
,
),
),
);
}
// The length of a list is itemCount or the index of the first itemBuilder
// that returns null, whichever is smaller
await
tester
.
pumpWidget
(
buildFrame
());
expect
(
tester
.
takeException
(),
isNull
);
expect
(
find
.
byType
(
ErrorWidget
),
findsNothing
);
expect
(
find
.
byType
(
Text
),
findsNWidgets
(
RENDER_NULL_AT
));
});
});
testWidgets
(
'when itemBuilder throws, creates Error Widget'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'when itemBuilder throws, creates Error Widget'
,
(
WidgetTester
tester
)
async
{
...
...
packages/flutter/test/widgets/scrollable_animations_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
@@ -71,10 +69,10 @@ void main() {
...
@@ -71,10 +69,10 @@ void main() {
final
double
targetPosition
=
controller
.
position
.
pixels
+
doubleTolerance
;
final
double
targetPosition
=
controller
.
position
.
pixels
+
doubleTolerance
;
controller
.
position
.
animateTo
(
targetPosition
,
duration:
const
Duration
(
seconds:
10
),
curve:
Curves
.
linear
);
controller
.
position
.
animateTo
(
targetPosition
,
duration:
const
Duration
(
seconds:
10
),
curve:
Curves
.
linear
);
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
1
),
reason:
'Expected an animation.'
);
expect
(
SchedulerBinding
.
instance
!
.
transientCallbackCount
,
equals
(
1
),
reason:
'Expected an animation.'
);
});
});
}
}
void
expectNoAnimation
(
)
{
void
expectNoAnimation
(
)
{
expect
(
SchedulerBinding
.
instance
.
transientCallbackCount
,
equals
(
0
),
reason:
'Expected no animation.'
);
expect
(
SchedulerBinding
.
instance
!
.
transientCallbackCount
,
equals
(
0
),
reason:
'Expected no animation.'
);
}
}
packages/flutter/test/widgets/scrollable_dispose_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/foundation.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
packages/flutter/test/widgets/scrollable_fling_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
import
'package:flutter/gestures.dart'
show
DragStartBehavior
;
...
...
packages/flutter/test/widgets/scrollable_grid_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
...
...
packages/flutter/test/widgets/scrollable_in_overlay_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
...
...
packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
packages/flutter/test/widgets/scrollable_of_test.dart
View file @
3f56178d
...
@@ -2,13 +2,11 @@
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
class
ScrollPositionListener
extends
StatefulWidget
{
class
ScrollPositionListener
extends
StatefulWidget
{
const
ScrollPositionListener
({
Key
key
,
this
.
child
,
this
.
log
})
:
super
(
key:
key
);
const
ScrollPositionListener
({
Key
?
key
,
required
this
.
child
,
required
this
.
log
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
child
;
final
ValueChanged
<
String
>
log
;
final
ValueChanged
<
String
>
log
;
...
@@ -18,7 +16,7 @@ class ScrollPositionListener extends StatefulWidget {
...
@@ -18,7 +16,7 @@ class ScrollPositionListener extends StatefulWidget {
}
}
class
_ScrollPositionListenerState
extends
State
<
ScrollPositionListener
>
{
class
_ScrollPositionListenerState
extends
State
<
ScrollPositionListener
>
{
ScrollPosition
_position
;
ScrollPosition
?
_position
;
@override
@override
void
didChangeDependencies
()
{
void
didChangeDependencies
()
{
...
@@ -26,7 +24,7 @@ class _ScrollPositionListenerState extends State<ScrollPositionListener> {
...
@@ -26,7 +24,7 @@ class _ScrollPositionListenerState extends State<ScrollPositionListener> {
_position
?.
removeListener
(
listener
);
_position
?.
removeListener
(
listener
);
_position
=
Scrollable
.
of
(
context
)?.
position
;
_position
=
Scrollable
.
of
(
context
)?.
position
;
_position
?.
addListener
(
listener
);
_position
?.
addListener
(
listener
);
widget
.
log
(
'didChangeDependencies
${_position?.pixels
?
.toStringAsFixed(1)}
'
);
widget
.
log
(
'didChangeDependencies
${_position?.pixels.toStringAsFixed(1)}
'
);
}
}
@override
@override
...
@@ -39,20 +37,20 @@ class _ScrollPositionListenerState extends State<ScrollPositionListener> {
...
@@ -39,20 +37,20 @@ class _ScrollPositionListenerState extends State<ScrollPositionListener> {
Widget
build
(
BuildContext
context
)
=>
widget
.
child
;
Widget
build
(
BuildContext
context
)
=>
widget
.
child
;
void
listener
()
{
void
listener
()
{
widget
.
log
(
'listener
${_position?.pixels
?
.toStringAsFixed(1)}
'
);
widget
.
log
(
'listener
${_position?.pixels.toStringAsFixed(1)}
'
);
}
}
}
}
void
main
(
)
{
void
main
(
)
{
testWidgets
(
'Scrollable.of() dependent rebuilds when Scrollable position changes'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Scrollable.of() dependent rebuilds when Scrollable position changes'
,
(
WidgetTester
tester
)
async
{
String
logValue
;
late
String
logValue
;
final
ScrollController
controller
=
ScrollController
();
final
ScrollController
controller
=
ScrollController
();
// Changing the SingleChildScrollView's physics causes the
// Changing the SingleChildScrollView's physics causes the
// ScrollController's ScrollPosition to be rebuilt.
// ScrollController's ScrollPosition to be rebuilt.
Widget
buildFrame
(
ScrollPhysics
physics
)
{
Widget
buildFrame
(
ScrollPhysics
?
physics
)
{
return
SingleChildScrollView
(
return
SingleChildScrollView
(
controller:
controller
,
controller:
controller
,
physics:
physics
,
physics:
physics
,
...
@@ -86,7 +84,7 @@ void main() {
...
@@ -86,7 +84,7 @@ void main() {
});
});
testWidgets
(
'Scrollable.of() is possible using ScrollNotification context'
,
(
WidgetTester
tester
)
async
{
testWidgets
(
'Scrollable.of() is possible using ScrollNotification context'
,
(
WidgetTester
tester
)
async
{
ScrollNotification
notification
;
late
ScrollNotification
notification
;
await
tester
.
pumpWidget
(
NotificationListener
<
ScrollNotification
>(
await
tester
.
pumpWidget
(
NotificationListener
<
ScrollNotification
>(
onNotification:
(
ScrollNotification
value
)
{
onNotification:
(
ScrollNotification
value
)
{
...
@@ -102,6 +100,6 @@ void main() {
...
@@ -102,6 +100,6 @@ void main() {
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
await
tester
.
pump
(
const
Duration
(
seconds:
1
));
final
StatefulElement
scrollableElement
=
find
.
byType
(
Scrollable
).
evaluate
().
first
as
StatefulElement
;
final
StatefulElement
scrollableElement
=
find
.
byType
(
Scrollable
).
evaluate
().
first
as
StatefulElement
;
expect
(
Scrollable
.
of
(
notification
.
context
),
equals
(
scrollableElement
.
state
));
expect
(
Scrollable
.
of
(
notification
.
context
!
),
equals
(
scrollableElement
.
state
));
});
});
}
}
packages/flutter/test/widgets/scrollable_restoration_test.dart
View file @
3f56178d
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter/material.dart'
;
import
'package:flutter/material.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
@@ -397,20 +395,20 @@ void main() {
...
@@ -397,20 +395,20 @@ void main() {
),
),
);
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
.
paintExtent
,
150
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
!
.
paintExtent
,
150
);
expect
(
find
.
text
(
'Tile 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 10'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 10'
),
findsNothing
);
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0
,
-
500
));
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0
,
-
500
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
.
paintExtent
,
56
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
!
.
paintExtent
,
56
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
await
tester
.
restartAndRestore
();
await
tester
.
restartAndRestore
();
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
.
paintExtent
,
56
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
!
.
paintExtent
,
56
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
...
@@ -418,13 +416,13 @@ void main() {
...
@@ -418,13 +416,13 @@ void main() {
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0
,
600
));
await
tester
.
drag
(
find
.
byType
(
ListView
),
const
Offset
(
0
,
600
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
.
paintExtent
,
150
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
!
.
paintExtent
,
150
);
expect
(
find
.
text
(
'Tile 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 0'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 10'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 10'
),
findsNothing
);
await
tester
.
restoreFrom
(
data
);
await
tester
.
restoreFrom
(
data
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
.
paintExtent
,
56
);
expect
(
tester
.
renderObject
<
RenderSliver
>(
find
.
byType
(
SliverAppBar
)).
geometry
!
.
paintExtent
,
56
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 0'
),
findsNothing
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
expect
(
find
.
text
(
'Tile 10'
),
findsOneWidget
);
});
});
...
@@ -552,7 +550,7 @@ Future<void> restoreScrollAndVerify(WidgetTester tester, {double secondOffset =
...
@@ -552,7 +550,7 @@ Future<void> restoreScrollAndVerify(WidgetTester tester, {double secondOffset =
}
}
class
TestHarness
extends
StatelessWidget
{
class
TestHarness
extends
StatelessWidget
{
const
TestHarness
({
Key
key
,
this
.
child
,
this
.
height
=
100
})
:
super
(
key:
key
);
const
TestHarness
({
Key
?
key
,
required
this
.
child
,
this
.
height
=
100
})
:
super
(
key:
key
);
final
Widget
child
;
final
Widget
child
;
final
double
height
;
final
double
height
;
...
...
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