Coder Social home page Coder Social logo

hxiaoming / flutter_thrio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from foxsofter/flutter_thrio

0.0 1.0 0.0 15.88 MB

flutter_thrio makes it easy and fast to add flutter to existing mobile applications, and provide a simple and consistent navigator APIs.

License: MIT License

Kotlin 17.88% Ruby 0.50% Objective-C 40.64% Dart 18.82% Java 21.92% Swift 0.24%

flutter_thrio's Introduction

thrio logo

Gitter Channel pub package license

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

Flutter SDK 版本是 1.22.x 的,请用 1.0.0 及之后的版本。

The Navigator for iOS, Android, Flutter.

Version 0.5.1 requires Flutter >= 1.12.1 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
  • Supports running multiple entry points

Getting started

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

dependencies:
  thrio: '^0.5.1'

You can also reference the git repo directly if you want:

dependencies:
  thrio:
    git: [email protected]:hellobike/thrio.git
    ref: main

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: '/biz1/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'),
);

push a page in iOS

[ThrioNavigator pushUrl:@"/biz1/flutter1"];

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

push a page in Android

ThrioNavigator.push("/biz1/flutter1",
        mapOf("k1" to 1),
        false,
        poppedResult = {
            Log.e("Thrio", "/biz1/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(params, animated)

popTo a page in dart

ThrioNavigator.popTo(url: '/biz1/flutter1');

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

popTo a page in iOS

[ThrioNavigator popToUrl:@"/biz1/flutter1"];

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

popTo a page in Android

ThrioNavigator.popTo(url, index)

remove a page in dart

ThrioNavigator.remove(url: '/biz1/flutter1');

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

remove a page in iOS

[ThrioNavigator removeUrl:@"/biz1/flutter1"];

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

remove a page in Android

ThrioNavigator.remove(url, index)

notify a page in dart

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

notify a page in iOS

[ThrioNavigator notifyUrl:@"/biz1/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(@"/biz1/native1 onNotify: %@, %@", name, params);
}

receive page notifications in Android

Activity implements the PageNotifyListener and receives page notifications via onNotify

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.