thrio 0.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 67

thrio logo #

Gitter Channel pub package license

中文文档 问题集 QQ 群号码:1014085473

The Navigator for iOS, Android, Flutter.

Version 0.2.2 requires Flutter >= 1.12.0 and Dart >= 2.6.0.

Features #

  • push,pop,popTo,remove native pages or flutter pages from anywhere
  • Get the callback parameters when the push page is popped
  • 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

Getting started #

You should ensure that you add thrio as a dependency in your flutter project.

dependencies:
  thrio: '^0.2.2'

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.

Example Project #

There is a pretty sweet example project in the example folder. Check it out. Otherwise, keep reading to get up and running.

push a page in dart #

ThrioNavigator.push(url: 'flutter1');

ThrioNavigator.push(url: 'native1', params: { '1': {'2': '3'}});

ThrioNavigator.push(url: 'native1', animated:true);

ThrioNavigator.push(
    url: '/biz2/flutter2',
    params: {'1': {'2': '3'}},
    poppedResult: (params) => ThrioLogger.v('/biz2/flutter2 popped: $params'),
);

push a page in iOS #

[ThrioNavigator pushUrl:@"flutter1"];

[ThrioNavigator pushUrl:@"/biz2/flutter2" poppedResult:^(id _Nonnull params) {
    ThrioLogV(@"/biz2/flutter2 popped: %@", params);
}];

push a page in Android #

ThrioNavigator.push(this, "/biz1/flutter1",
        mapOf("k1" to 1),
        false,
        poppedResult = {
            Log.e("Thrio", "native1 popResult call params $it")
        }
)

pop a page in dart #

ThrioNavigator.pop();
// Pop the page without animation
ThrioNavigator.pop(animated: false);
// Pop the page and return parameters
ThrioNavigator.pop(params: 'popped flutter1'),

pop a page in iOS #

[ThrioNavigator pop];
// Pop a page without animation
[ThrioNavigator popAnimated:NO];
// Pop the page and return parameters
[ThrioNavigator popParams:@{@"k1": @3}];

pop a page in Android #

ThrioNavigator.pop(this, params, animated)

popTo a page in dart #


ThrioNavigator.popTo(url: 'flutter1');

ThrioNavigator.popTo(url: 'flutter1', animated: false);

popTo a page in iOS #

[ThrioNavigator popToUrl:@"flutter1"];

[ThrioNavigator popToUrl:@"flutter1" animated:NO];

popTo a page in Android #

ThrioNavigator.popTo(context, url, index)

remove a page in dart #

ThrioNavigator.remove(url: 'flutter1');

ThrioNavigator.remove(url: 'flutter1', animated: true);

remove a page in iOS #

[ThrioNavigator removeUrl:@"flutter1"];

[ThrioNavigator removeUrl:@"flutter1" animated:NO];

remove a page in Android #

ThrioNavigator.remove(context, url, index)

notify a page in dart #

ThrioNavigator.notify(url: 'flutter1', name: 'reload');

notify a page in iOS #

[ThrioNavigator notifyUrl:@"flutter1" name:@"reload"];

notify a page in Android #

ThrioNavigator.notify(url, index, params)

receive page notifications in dart #

NavigatorPageNotify(
      name: 'page1Notify',
      onPageNotify: (params) =>
          ThrioLogger.v('flutter1 receive notify: $params'),
      child: Xxxx());

receive page notifications in iOS #

UIViewController implements the NavigatorPageNotifyProtocol and receives page notifications via onNotify

- (void)onNotify:(NSString *)name params:(id)params {
  ThrioLogV(@"native1 onNotify: %@, %@", name, params);
}

receive page notifications in Android #

Activity implements the OnNotifyListener and receives page notifications via onNotify

class Activity : AppCompatActivity(), OnNotifyListener {
    override fun onNotify(name: String, params: Any?) {
    }
}

0.0.1 #

  • TODO: Describe initial release.

0.1.0 #

  • Fix: Android push always return index.
  • Fix: remove signle_top for Android native Activity.

0.1.1 #

  • Fix: hot restart 导致 pop 失效

0.1.2 #

  • Fix: iOS 下面 Dart 页面通知的 bug

0.1.3 #

  • Fix: Android demo 原生页面和 Flutter 页面转场动画不一致
  • Fix: iOS hidesNavigationBar 设置后原生页面一直生效的 bug

0.1.4 #

  • feat: remove reuse of isInitialRoute
  • fix: Android setSystemUIOverlayStyle 不生效
  • doc: 添加日志开关文档
  • feat: add iOS log switch
  • doc: add push and notify demo
  • fix: pop with parameters does not cover all cases
  • fix: Repeatedly add NavigatorObserverManager
  • fix: crash at UINavigationController.setViewControllers
  • feat: add dart navigator log disable
  • fix: 优化导航栏切换效果

0.1.5 #

  • fix: url 带 . 时引起的冲突,issue #27

0.1.6 #

  • fix: popResult 失败

0.1.7 #

  • fix: Android didn't notify after popTo
  • fix: Android didn't call onPopResult from native pop to flutter

0.1.8 #

  • fix: ios memory leak

0.2.0 #

  • feat: add flutter custom transition builder api.

0.2.1 #

  • fix: crash case on f->n->f .

0.2.2 #

  • fix: iOS index not sync when back gesture.

example/lib/main.dart

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'src/app.dart' as app;

Future<void> main() async {
  FlutterError.onError = (details) async {
    Zone.current.handleUncaughtError(details.exception, details.stack);
  };
  runZoned<void>(app.main);
}

@pragma('vm:entry-point')
Future<void> biz1() async {
  FlutterError.onError = (details) async {
    Zone.current.handleUncaughtError(details.exception, details.stack);
  };
  runZoned<void>(app.biz1);
}

@pragma('vm:entry-point')
Future<void> biz2() async {
  FlutterError.onError = (details) async {
    Zone.current.handleUncaughtError(details.exception, details.stack);
  };
  runZoned<void>(app.biz2);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  thrio: ^0.2.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:thrio/thrio.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Jul 7, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:thrio/thrio.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:thrio/thrio.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:thrio/thrio.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:thrio/thrio.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [thrio] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.1
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test
pedantic ^1.8.0