Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
2ef3870f
Commit
2ef3870f
authored
Feb 20, 2020
by
justin
Committed by
GitHub
Feb 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #601 from Vadaski/master
remove useless code in boost_page_route
parents
969ea9fd
11869d5e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
130 additions
and
26 deletions
+130
-26
lib/container/boost_page_route.dart
lib/container/boost_page_route.dart
+3
-26
test/lib/unit/boost_page_route_test.dart
test/lib/unit/boost_page_route_test.dart
+127
-0
No files found.
lib/container/boost_page_route.dart
View file @
2ef3870f
...
...
@@ -21,6 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
import
'package:flutter/widgets.dart'
;
import
'package:flutter/material.dart'
;
...
...
@@ -36,23 +37,14 @@ class BoostPageRoute<T> extends MaterialPageRoute<T> {
final
Set
<
VoidCallback
>
backPressedListeners
=
Set
<
VoidCallback
>();
@override
Widget
buildTransitions
(
BuildContext
context
,
Animation
<
double
>
animation
,
Animation
<
double
>
secondaryAnimation
,
Widget
child
)
{
return
super
.
buildTransitions
(
context
,
animation
,
secondaryAnimation
,
child
);
}
BoostPageRoute
(
{
Key
stubKey
,
this
.
pageName
,
{
this
.
pageName
,
this
.
params
,
this
.
uniqueId
,
this
.
animated
,
this
.
builder
,
this
.
settings
})
:
super
(
builder:
(
BuildContext
context
)
=>
Stub
(
stubKey
,
builder
(
context
)),
settings:
settings
);
:
super
(
builder:
builder
,
settings:
settings
);
static
BoostPageRoute
<
T
>
of
<
T
>(
BuildContext
context
)
{
final
Route
<
T
>
route
=
ModalRoute
.
of
(
context
);
...
...
@@ -72,18 +64,3 @@ class BoostPageRoute<T> extends MaterialPageRoute<T> {
}
}
}
@immutable
class
Stub
extends
StatefulWidget
{
final
Widget
child
;
const
Stub
(
Key
key
,
this
.
child
)
:
super
(
key:
key
);
@override
_StubState
createState
()
=>
_StubState
();
}
class
_StubState
extends
State
<
Stub
>
{
@override
Widget
build
(
BuildContext
context
)
=>
widget
.
child
;
}
test/lib/unit/boost_page_route_test.dart
View file @
2ef3870f
...
...
@@ -44,4 +44,131 @@ void main() {
expect
(
find
.
text
(
'Page 1'
),
findsNothing
);
expect
(
find
.
text
(
'Page 2'
),
isOnstage
);
});
group
(
'Try to get the BoostPageRoute in the ancestor node'
,
()
{
testWidgets
(
'obtain BoostPageRoute through the `BoostPageRoute.of(context)` method'
,
(
WidgetTester
tester
)
async
{
var
boostPageRoute
;
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
boostPageRoute
=
BoostPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
of
(
context
);
},
);
},
),
);
return
boostPageRoute
;
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
// The route obtained from the ancestor node through the `of` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect
(
boostPageRoute
,
boostPageRouteFindByOfMethod
);
});
testWidgets
(
'try to find BoostPageRoute through the `BoostPageRoute.of(context)` method, '
'but it doesn
\'
t exist, the method should throw an Exception'
,
(
WidgetTester
tester
)
async
{
var
contextCache
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
(
settings:
settings
,
builder:
(
context
)
=>
Builder
(
builder:
(
context
)
=>
FloatingActionButton
(
onPressed:
()
{
contextCache
=
context
;
},
),
),
);
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
expect
(()
=>
BoostPageRoute
.
of
(
contextCache
),
throwsException
);
});
testWidgets
(
'obtain BoostPageRoute through the `BoostPageRoute.tryOf(context)` method'
,
(
WidgetTester
tester
)
async
{
var
boostPageRoute
;
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
boostPageRoute
=
BoostPageRoute
<
void
>(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
tryOf
(
context
);
},
);
},
),
);
return
boostPageRoute
;
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
// The route obtained from the ancestor node through the `tryOf` method should be the same BoostPageRoute
// as the originally created BoostPageRoute
expect
(
boostPageRoute
,
boostPageRouteFindByOfMethod
);
});
});
testWidgets
(
'try to find BoostPageRoute through the `BoostPageRoute.tryOf(context)` method, '
'but it doesn
\'
t exist, the method should return null'
,
(
WidgetTester
tester
)
async
{
var
boostPageRouteFindByOfMethod
;
await
tester
.
pumpWidget
(
MaterialApp
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
(
settings:
settings
,
builder:
(
BuildContext
context
)
=>
Builder
(
builder:
(
context
)
{
return
FloatingActionButton
(
onPressed:
()
{
boostPageRouteFindByOfMethod
=
BoostPageRoute
.
tryOf
(
context
);
},
);
},
),
);
},
),
);
await
tester
.
tap
(
find
.
byType
(
FloatingActionButton
));
expect
(
boostPageRouteFindByOfMethod
,
null
);
});
}
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