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
5f4b3a8d
Commit
5f4b3a8d
authored
Jan 13, 2020
by
yangwu.jia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
NavObserver bugfixed
parent
756e7638
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
36 additions
and
81 deletions
+36
-81
example/lib/main.dart
example/lib/main.dart
+20
-0
lib/container/boost_container.dart
lib/container/boost_container.dart
+14
-28
lib/container/container_manager.dart
lib/container/container_manager.dart
+0
-51
lib/flutter_boost.dart
lib/flutter_boost.dart
+2
-2
No files found.
example/lib/main.dart
View file @
5f4b3a8d
...
...
@@ -29,6 +29,7 @@ class _MyAppState extends State<MyApp> {
return
FlutterRouteWidget
(
params:
params
);
},
});
FlutterBoost
.
singleton
.
addBoostNavigatorObserver
(
TestBoostNavigatorObserver
());
}
@override
...
...
@@ -45,3 +46,22 @@ class _MyAppState extends State<MyApp> {
String
pageName
,
String
uniqueId
,
Map
params
,
Route
route
,
Future
_
)
{
}
}
class
TestBoostNavigatorObserver
extends
NavigatorObserver
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didPush"
);
}
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didPop"
);
}
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
print
(
"flutterboost#didRemove"
);
}
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
print
(
"flutterboost#didReplace"
);
}
}
lib/container/boost_container.dart
View file @
5f4b3a8d
...
...
@@ -155,14 +155,11 @@ class BoostContainerState extends NavigatorState {
@override
void
didUpdateWidget
(
Navigator
oldWidget
)
{
super
.
didUpdateWidget
(
oldWidget
);
findContainerNavigatorObserver
(
oldWidget
)?.
removeBoostNavigatorObserver
(
FlutterBoost
.
containerManager
.
navigatorObserver
);
}
@override
void
dispose
()
{
findContainerNavigatorObserver
(
widget
)?.
removeBoostNavigatorObserver
(
FlutterBoost
.
containerManager
.
navigatorObserver
);
routerHistory
.
clear
();
super
.
dispose
();
}
...
...
@@ -261,63 +258,52 @@ class ContainerElement extends StatefulElement {
}
class
ContainerNavigatorObserver
extends
NavigatorObserver
{
BoostNavigatorObserver
observer
;
final
Set
<
BoostNavigatorObserver
>
_
boostObservers
=
Set
<
Boost
NavigatorObserver
>();
static
final
Set
<
NavigatorObserver
>
boostObservers
=
Set
<
NavigatorObserver
>();
ContainerNavigatorObserver
();
factory
ContainerNavigatorObserver
.
bindContainerManager
()
=>
ContainerNavigatorObserver
()
..
addBoostNavigatorObserver
(
FlutterBoost
.
containerManager
.
navigatorObserver
);
ContainerNavigatorObserver
();
VoidCallback
addBoostNavigatorObserver
(
Boost
NavigatorObserver
observer
)
{
_
boostObservers
.
add
(
observer
);
VoidCallback
addBoostNavigatorObserver
(
NavigatorObserver
observer
)
{
boostObservers
.
add
(
observer
);
return
()
=>
_
boostObservers
.
remove
(
observer
);
return
()
=>
boostObservers
.
remove
(
observer
);
}
void
removeBoostNavigatorObserver
(
Boost
NavigatorObserver
observer
)
{
_
boostObservers
.
remove
(
observer
);
void
removeBoostNavigatorObserver
(
NavigatorObserver
observer
)
{
boostObservers
.
remove
(
observer
);
}
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
for
(
BoostNavigatorObserver
observer
in
_
boostObservers
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
observer
.
didPush
(
route
,
previousRoute
);
}
}
@override
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
for
(
BoostNavigatorObserver
observer
in
_
boostObservers
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
observer
.
didPop
(
route
,
previousRoute
);
}
}
@override
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
for
(
BoostNavigatorObserver
observer
in
_
boostObservers
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
observer
.
didRemove
(
route
,
previousRoute
);
}
}
@override
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
for
(
BoostNavigatorObserver
observer
in
_
boostObservers
)
{
for
(
NavigatorObserver
observer
in
boostObservers
)
{
observer
.
didReplace
(
newRoute:
newRoute
,
oldRoute:
oldRoute
);
}
}
}
class
BoostNavigatorObserver
{
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{}
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{}
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{}
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{}
}
lib/container/container_manager.dart
View file @
5f4b3a8d
...
...
@@ -62,8 +62,6 @@ class BoostContainerManager extends StatefulWidget {
class
ContainerManagerState
extends
State
<
BoostContainerManager
>
{
final
GlobalKey
<
OverlayState
>
_overlayKey
=
GlobalKey
<
OverlayState
>();
final
List
<
BoostContainer
>
_offstage
=
<
BoostContainer
>[];
final
ManagerNavigatorObserver
_navigatorObserver
=
ManagerNavigatorObserver
();
List
<
_ContainerOverlayEntry
>
_leastEntries
;
...
...
@@ -78,7 +76,6 @@ class ContainerManagerState extends State<BoostContainerManager> {
bool
get
foreground
=>
_foreground
;
ManagerNavigatorObserver
get
navigatorObserver
=>
_navigatorObserver
;
//Number of containers.
int
get
containerCounts
=>
_offstage
.
length
;
...
...
@@ -347,51 +344,3 @@ class _ContainerOverlayEntry extends OverlayEntry {
}
}
class
ManagerNavigatorObserver
extends
BoostNavigatorObserver
{
BoostNavigatorObserver
observer
;
final
Set
<
BoostNavigatorObserver
>
_boostObservers
=
Set
<
BoostNavigatorObserver
>();
VoidCallback
addBoostNavigatorObserver
(
BoostNavigatorObserver
observer
)
{
_boostObservers
.
add
(
observer
);
return
()
=>
_boostObservers
.
remove
(
observer
);
}
void
removeBoostNavigatorObserver
(
BoostNavigatorObserver
observer
)
{
_boostObservers
.
remove
(
observer
);
}
@override
void
didPush
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
Logger
.
log
(
'ManagerNavigatorObserver didPush'
);
for
(
BoostNavigatorObserver
observer
in
_boostObservers
)
{
observer
.
didPush
(
route
,
previousRoute
);
}
}
@override
void
didPop
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
Logger
.
log
(
'ManagerNavigatorObserver didPop'
);
for
(
BoostNavigatorObserver
observer
in
_boostObservers
)
{
observer
.
didPop
(
route
,
previousRoute
);
}
}
@override
void
didRemove
(
Route
<
dynamic
>
route
,
Route
<
dynamic
>
previousRoute
)
{
Logger
.
log
(
'ManagerNavigatorObserver didRemove'
);
for
(
BoostNavigatorObserver
observer
in
_boostObservers
)
{
observer
.
didRemove
(
route
,
previousRoute
);
}
}
@override
void
didReplace
({
Route
<
dynamic
>
newRoute
,
Route
<
dynamic
>
oldRoute
})
{
Logger
.
log
(
'ManagerNavigatorObserver didReplace'
);
for
(
BoostNavigatorObserver
observer
in
_boostObservers
)
{
observer
.
didReplace
(
newRoute:
newRoute
,
oldRoute:
oldRoute
);
}
}
}
lib/flutter_boost.dart
View file @
5f4b3a8d
...
...
@@ -189,8 +189,8 @@ class FlutterBoost {
_observersHolder
.
addObserver
<
BoostContainerLifeCycleObserver
>(
observer
);
///register callbacks for Navigators push & pop
VoidCallback
addBoostNavigatorObserver
(
Boost
NavigatorObserver
observer
)
=>
_observersHolder
.
addObserver
<
BoostNavigatorObserver
>
(
observer
);
void
addBoostNavigatorObserver
(
NavigatorObserver
observer
)
=>
ContainerNavigatorObserver
.
boostObservers
.
add
(
observer
);
}
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