本仓库不再维护,可移步新仓库 https://github.com/flutter-thrio/flutter_thrio
The Navigator
for iOS, Android, Flutter.
Version 0.2.2
requires Flutter >= 1.12.0
and Dart >= 2.6.0
.
push
,pop
,popTo
,remove
native pages or flutter pages from anywhere- Get the callback parameters when the
push
page ispopped
- Send and receive page notifications
- Register observers for the life cycle of pages
- Register observers for the route actions of pages
- Hide native navigation bar for flutter pages
- Supports custom transition animation on the Flutter side
You should ensure that you add thrio
as a dependency in your flutter project.
dependencies:
thrio: '^0.5.0'
You can also reference the git repo directly if you want:
dependencies:
thrio:
git: git@github.com:hellobike/thrio.git
You should then run flutter pub upgrade
or update your packages in IntelliJ.
There is a pretty sweet example project in the example
folder. Check it out. Otherwise, keep reading to get up and running.
ThrioNavigator.push(url: 'flutter1');
ThrioNavigator.push(url: '/biz1/native1', params: { '1': {'2': '3'}});
ThrioNavigator.push(url: '/biz1/native1', animated:true);
ThrioNavigator.push(
url: '/biz2/flutter2',
params: {'1': {'2': '3'}},
poppedResult: (params) => ThrioLogger.v('/biz2/flutter2 popped: $params'),
);
[ThrioNavigator pushUrl:@"flutter1"];
[ThrioNavigator pushUrl:@"/biz2/flutter2" poppedResult:^(id _Nonnull params) {
ThrioLogV(@"/biz2/flutter2 popped: %@", params);
}];
ThrioNavigator.push(this, "/biz1/flutter1",
mapOf("k1" to 1),
false,
poppedResult = {
Log.e("Thrio", "/biz1/native1 popResult call params $it")
}
)
ThrioNavigator.pop();
// Pop the page without animation
ThrioNavigator.pop(animated: false);
// Pop the page and return parameters
ThrioNavigator.pop(params: 'popped flutter1'),
[ThrioNavigator pop];
// Pop a page without animation
[ThrioNavigator popAnimated:NO];
// Pop the page and return parameters
[ThrioNavigator popParams:@{@"k1": @3}];
ThrioNavigator.pop(this, params, animated)
ThrioNavigator.popTo(url: 'flutter1');
ThrioNavigator.popTo(url: 'flutter1', animated: false);
[ThrioNavigator popToUrl:@"flutter1"];
[ThrioNavigator popToUrl:@"flutter1" animated:NO];
ThrioNavigator.popTo(context, url, index)
ThrioNavigator.remove(url: 'flutter1');
ThrioNavigator.remove(url: 'flutter1', animated: true);
[ThrioNavigator removeUrl:@"flutter1"];
[ThrioNavigator removeUrl:@"flutter1" animated:NO];
ThrioNavigator.remove(context, url, index)
ThrioNavigator.notify(url: 'flutter1', name: 'reload');
[ThrioNavigator notifyUrl:@"flutter1" name:@"reload"];
ThrioNavigator.notify(url, index, params)
NavigatorPageNotify(
name: 'page1Notify',
onPageNotify: (params) =>
ThrioLogger.v('flutter1 receive notify: $params'),
child: Xxxx());
UIViewController
implements the NavigatorPageNotifyProtocol
and receives page notifications via onNotify
- (void)onNotify:(NSString *)name params:(id)params {
ThrioLogV(@"/biz1/native1 onNotify: %@, %@", name, params);
}
Activity
implements the OnNotifyListener
and receives page notifications via onNotify
class Activity : AppCompatActivity(), OnNotifyListener {
override fun onNotify(name: String, params: Any?) {
}
}