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

Overview

thrio logo

pub package license

中文文档 英文文档 问题集 原仓库不再维护,代码已经很老了

最近版本更新会很快,主要是增加新特性,涉及到混合栈的稳定性的问题应该不多,可放心升级,发现问题加 QQ 群号码:1014085473,我会尽快解决。

不打算好好看看源码的使用者可以放弃这个库了,因为很多设定是比较死的,而我本人不打算花时间写太多文档

优势

  1. 稳定性、通用性在部分项目中得到验证,有用户反馈,将整个 app 的路由方案全部切换到后,崩溃率降低显著
  2. 内存占用方面,thrio 在连续打开 Flutter 页面的内存占用方面从一开始就碾压主流的 Flutter 混合栈,更进一步的,避开原理层面带来的内存优势,这里有个对比,也说明 thrio 在内存占用上的优异表现,传送门
  3. 支持 FlutterEngine 的复用,还支持 FlutterViewControllerFlutterActivity 的复用,这保证了 Flutter 混合栈框架在内存占用上是最优解
  4. 在 3 情形下,支持 跨栈路由 的能力,这是目前唯一能做到的 Flutter混合栈开源框架
  5. 在 3 情形下,除了提供 pushpop,也提供了 removepopTo 的能力,目前唯一能做到的 Flutter混合栈开源框架
  6. 在 3 情形下,提供页面通知的能力,组合 pushpop 的路由传参能力,可以让状态参数在页面间传递,省去很多 channel 通讯的必要
  7. 在 3 情形下,页面传参支持Json对象类型,单引擎下纯 Flutter 开发支持直接传递对象类型
  8. 在 3 情形下,支持完整的页面生命周期
  9. 在 3 情形下,支持完整的路由周期,兼容使用 FlutterNavigator 来打开对话框等弹窗
  10. 在 3 情形下,支持多引擎模式,可以在一个原生 App 中运行多份 Flutter 代码,目前唯一能做到的 Flutter 混合栈开源框架
  11. 在 3 情形下,解决 iOS 和 Android 上的侧滑返回手势冲突
  12. iOS 上自动隐藏 Flutter 页面的导航栏
  13. 额外的支持三端统一的模块化方式,更好的与路由API配合

劣势

  1. 在 iOS 上不支持 present,技术上完全可以实现,甚至使用者可以通过传参的方式在 builder 中自己 present,但为了 API 设计上统一,作者选择不支持 present,demo 中其实是有 present 的示例的,建议 present 的时候外套一个 UINavigationController,可以保证不管何时 push 时 API 都是有效的,flutter_thrio 是支持多 UINavigationController 的,有一点需要注意的是,如果多个 UINavigationController 内嵌于 UITabBar 中时,要注意无法同时将多个 FlutterViewController 呈现,不支持是因为支持的话无法进行引擎复用。
  2. 在 Android 上不支持 Fragment,原因是复杂性无法解决,作者目前不能够保证提供一个通用稳定的版本。

入门

  1. clone thrio 的源码,查看 demo,并运行起来
  2. 通过 pub 引入 thrio,建议采用 1.0.0 之后的版本,之前的版本支持1.22.x之前的Flutter SDK,但不建议继续采用这些老版本的 SDK,还是尽快升级到新版
  3. 模仿 thrio demo 中的源码,在现有工程上加入相关代码
  4. 不要继承 Flutter SDK 中的一些类,比如 FlutterViewControllerFlutterActivityFlutterAppDelegate
  5. 不要调用 GeneratedPluginRegistrantregisterWithRegistry 方法了,因为框架会自动调用
  6. url 至少保持两段

最后

  1. 技术没有好与不好,使用在适合的场景才是最好的。

  2. Flutter 在 客户端的适用场景会越来越广,个人比较看好。

  3. 目前在移动端,一个好的 Flutter 混合栈框架是必须的,让你可以在大多数的页面上采用 Flutter 来开发从而达到提效的目的,少数涉及到 Flutter 不能很好支持的页面上继续使用原生开发,从而规避的 Flutter 的坑。

  4. 如果所开发的是一个全新的 App,以后也不会涉及到老的代码的复用,或者不会涉及到 Flutter 支持不够良好的一些技术上的坑,确实可以考虑纯 Flutter。

  5. 但4的情形极少,所以大部分的 Flutter 在引入的时候,都应该考虑以 Flutter 混合栈的方式进行,坑不是用来踩的,而是绕道而过。

Comments
  • flutter侧白屏 Failed to create platform view rendering surface

    flutter侧白屏 Failed to create platform view rendering surface

    Describe the bug platform_view.cc(81):Failed to create platform view rendering surface swift 项目,native侧 跳转flutter,跳转过去后,界面渲染不出来(白屏),点击界面,上面的按钮可以正常显示,flutter监视器 上可以正常看到按钮大小位置(swift项目,你们demo项目正常,对比了代码木有找到原因,flutter侧代码完全用demo里面的,猜测是native侧的问题)

    Expected behavior

    Flutter Doctor

    OS & Device

    • Device:   真机,模拟器
    • OS: ios14
    • Version:2.0.11
    • flutter ver:2.2.3
    • swift :5.3

    Error logs platform_view.cc(81):Failed to create platform view rendering surface

    opened by wanghao522 12
  • hello,创建 swift 版的 ios 项目时遇到问题

    hello,创建 swift 版的 ios 项目时遇到问题

    我在 example 目录下使用 flutter create -i swift . 重新创建 ios 项目之后,AppDelegate 中的代码是否可以转为 swift 版?

     
        [ThrioModule init:[MainModule new]];
    
        UINavigationController *nvc = [[NavigatorNavigationController alloc] initWithUrl:@"/biz1/flutter1" params:nil];
        self.window.rootViewController = nvc;
        [self.window makeKeyAndVisible];
    
    

    如果可以转 swift,那应该怎样转呢?谢谢!!

    opened by hw20101101 12
  • ios 无法跳转到flutter端 一直转圈 显示 hot restart

    ios 无法跳转到flutter端 一直转圈 显示 hot restart

    Describe the bug example 下载下来在xcode运行 一直显示转圈

    To Reproduce 在xcode真机14.3运行 无法正常显示页面

    Expected behavior 控制台没有报错

    Flutter Doctor no issure

    OS & Device

    • Device: iPhoneXR
    • OS: ios 14.3
    • flutter 2.0.1

    Error logs 无 error log

    opened by SnailLife 8
  • thrio/navigator/PageRoutes.kt: (225, 34): Unresolved reference: removeLast

    thrio/navigator/PageRoutes.kt: (225, 34): Unresolved reference: removeLast

    Describe the bug 在 vs code 上面新建 flutter 项目之后,添加 thrio 2.0.11 依赖,然后在 荣耀v10 上面运行报错。

    To Reproduce Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior 在手机上正常运行 flutter 项目

    Flutter Doctor

    [✓] Flutter (Channel stable, 2.2.1, on Mac OS X 10.15.7 19H15 darwin-x64, locale zh-Hans-CN)
    [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
        ✗ Android license status unknown.
          Run `flutter doctor --android-licenses` to accept the SDK licenses.
          See https://flutter.dev/docs/get-started/install/macos#android-setup for more details.
    [✓] Xcode - develop for iOS and macOS
    [✓] Chrome - develop for the web
    [✓] Android Studio (version 4.1)
    [✓] VS Code (version 1.56.2)
    

    OS & Device

    • Device: 荣耀v10
    • OS: android 10
    • Version EMUI 10.0.0

    Error logs

    Launching lib/main.dart on BKL AL20 in debug mode...
    lib/main.dart:1
    e: /Users/xxx/Documents/xxx/flutter/.pub-cache/hosted/pub.flutter-io.cn/thrio-
    2.0.11/android/src/main/kotlin/com/hellobike/flutter/thrio/navigator/PageRoutes.kt: (225, 34): 
    Unresolved reference: removeLast
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':thrio:compileDebugKotlin'.
    > Compilation error. See log for more details
    
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
    Run with --scan to get full insights.
    
    * Get more help at https://help.gradle.org
    
    BUILD FAILED in 10s
    Exception: Gradle task assembleDebug failed with exit code 1
    Exited (sigterm)
    
    
    opened by hw20101101 7
  • thrio 维护公告

    thrio 维护公告

    2.1.x版本之后,不再维护 not nullsafety 分支,如可能还是尽快升级到 nullsafety 吧

    本项目 API 已经稳定,不太可能出现 break change,当前稳定版本 2.0. x,当 x 是偶数时表示支持 Flutter 2.0 不带 nullsafety,当 x 是奇数时表示支持 Flutter 2.0 带 nullsafety。

    thrio 是个人项目,目前是我一人在维护,原仓库不再更新。

    最近遇到被问到与其它开源库对比的比较尖锐的一些问题,有时候我是不太想回答的,说多了有拆台嫌疑。

    可以理解,很多人还是想得到更多信息来判断是否应不应该使用 thrio,我的几条建议如下:

    1. 看自己的需求,满足自己需求是前提
    2. 看代码质量,这是最主要的一点
    3. 自己多测测,可以的话看看稳定性如何
    4. 可参考下 issue 数量和 star 数量比,未解决 issue 数量等
    5. 看代码更新频次

    最后还是说一句:thrio 是目前唯一支持 Flutter 混合栈跨栈路由的开源库,这句话从 thrio 开源至今一直都是有效的,等将来出现具备Flutter 混合栈跨栈路由的开源库,我再来改掉。

    跨栈路由:无需关注页面类型是 iOS、Android 还是 Flutter,都一样具备完整的路由能力,调用者打开一个页面,接收该页面的回调,接收该页面的页面通知,即使将来其页面类型变更也无所谓。

    opened by foxsofter 6
  • hello,请问应该怎样设置这个 thrio 项目的  launch image 呢?

    hello,请问应该怎样设置这个 thrio 项目的 launch image 呢?

    我在 iOS 原生中设置了 launch image,但是 App 启动的时候 launch image 一闪而过,然后会显示几秒钟的空白界面。

    请问怎样才能将这几秒钟的空白界面替换为 launch image 呢?

    我照着一些网上的教程试了,无效, demo 链接:https://github.com/hw20101101/thrio_demo

    谢谢!!

    opened by hw20101101 4
  •  如何设置多引擎

    如何设置多引擎

    Describe the bug 想要看看多引擎如何实现 打开 MainApp 中 您注释掉的句子 ThrioModule.init( MainModule, this, true)。 但是报错,找不到engindId

    To Reproduce

    ThrioModule.init( MainModule, this, true)

    Flutter Doctor Flutter 1.22.4

    OS & Device Android 10 Error logs

    E/AndroidRuntime(11476): FATAL EXCEPTION: main E/AndroidRuntime(11476): Process: com.hellobike.thrio_example, PID: 11476 E/AndroidRuntime(11476): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hellobike.thrio_example/io.flutter.embedding.android.ThrioActivity}: java.lang.IllegalStateException: The requested cached FlutterEngine did not exist in the FlutterEngineCache: 'biz1'

    opened by kelciej 3
  • [feat] Flutter端生成代码框架

    [feat] Flutter端生成代码框架

    虽然是混合栈框架,但引入后建议能用 Flutter 实现的都用 Flutter 实现,兼容原生路由栈只是为了复用既有功能和将来可能依赖的外部原生代码,所以本框架的重心之后会放在 Flutter 端的开发体验。

    通过 yaml 文件来配置 Flutter 所有页面的路径,类似如下:

    app:
      order:
        home:
        list:
        detail:
        handle:
          home:
          result:
      waybill:
        home:
        list:
        detail:
        handle:
          home:
          result:
    

    根据该配置,生成模块化的 Flutter 代码框架。实际使用时,url 末尾的 home 可以省略掉。

    opened by foxsofter 3
  • android example报错

    android example报错

    如图,android example报错 image e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (9, 8): Unresolved reference: kotlinx e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (14, 9): Unresolved reference: tv_native e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (14, 19): Variable expected e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (16, 9): Unresolved reference: btn_10 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (34, 9): Unresolved reference: btn_11 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (40, 9): Unresolved reference: btn_12 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (52, 9): Unresolved reference: btn_13 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (58, 9): Unresolved reference: btn_20 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (71, 9): Unresolved reference: btn_21 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (75, 9): Unresolved reference: btn_22 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (88, 9): Unresolved reference: btn_23 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (92, 9): Unresolved reference: btn_3 e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (113, 17): Unresolved reference: tv_native e: /Users/zhebian/Desktop/testCode/flutter_thrio/example/android/app/src/main/kotlin/com/hellobike/thrio_example/Native1Activity.kt: (113, 27): Variable expected

    opened by Yahiko7 2
  • android example跑不起来

    android example跑不起来

    如图所示 image

    报错信息: Could not determine the dependencies of task ':thrio:compileDebugKotlin'.

    Could not resolve all files for configuration ':thrio:debugRuntimeClasspath'. Could not find io.flutter:flutter_embedding_debug:1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed. Searched in the following locations: - https://dl.google.com/dl/android/maven2/io/flutter/flutter_embedding_debug/1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed/flutter_embedding_debug-1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed.pom - https://jcenter.bintray.com/io/flutter/flutter_embedding_debug/1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed/flutter_embedding_debug-1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed.pom - https://mirrors.cloud.tencent.com/flutter/download.flutter.io/io/flutter/flutter_embedding_debug/1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed/flutter_embedding_debug-1.0.0-2f0af3715217a0c2ada72c717d4ed9178d68f6ed.pom Required by: project :thrio

    Possible solution:

    • Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
    opened by Yahiko7 2
  • 启动Demo 闪退

    启动Demo 闪退

    Describe the bug A clear and concise description of what the bug is.

    To Reproduce Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior A clear and concise description of what you expected to happen.

    Flutter Doctor Run the flutter doctor -v command and post the log.

    OS & Device

    • Device: [e.g. iPhone6]
    • OS: [e.g. iOS8.1]
    • Version [e.g. 22]

    Error logs Add logs about the problem here.

    FlutterEngine not ready

    opened by Alvin917 1
Owner
null
A routing package that lets you navigate through guarded page stacks and URLs using the Router and Navigator's Pages API, aka "Navigator 2.0".

A Flutter package to help you handle your application routing and synchronize it with browser URL. Beamer uses the power of Router and implements all

Sandro Lovnički 485 Jan 7, 2023
Flutter makes it easy and fast to build beautiful apps for mobile and beyond

Flutter is Google's SDK for crafting beautiful, fast user experiences for mobile, web, and desktop from a single codebase. Flutter works with existing

Flutter 148.2k Jan 8, 2023
A mobile client for the public apis repository, 1400+ free apis to use able to be navigated through your phone :)

Public APIs mobile app Your assistant app that will help you discover and pick the next API for your next development project What it contains, you sa

Gwhyyy 4 Dec 25, 2022
Easy nav - A simple wrapper around flutter navigator, dialogs and snackbar to do those things without context

EasyNav Just a simple wrapper around flutter navigator, dialogs and snackbar to

Abdul Shakoor 2 Feb 26, 2022
Flutter Image add drag sort, Image add drag sort, support click event, delete, add, long press drag sort.

flutter_image_add_drag_sort Flutter Image add drag sort, Image add drag sort, support click event, delete, add, long press drag sort, support video fi

null 5 Jun 23, 2020
Consistent design with Flutter Theme

Consistent design with Flutter Theme Source code for the "Consistent design with Flutter Theme" DartPad workshop by Anna Leushchenko ??‍?? ?? ?? ????

Anna (Domashych) Leushchenko 8 Oct 31, 2022
Flutter themes consistent with GitHub's Primer style guidelines

primer_flutter Flutter themes consistent with Primer style guidelines DISCLAIMER: This project is not affiliated with the Primer or GitHub organizatio

Reuben Turner 6 Aug 24, 2022
Scouter is a package which was made following the goal to provide a NestJS-like experience to Dart Developers that want to develop Rest APIS

Scouter is a package which was made following the goal to provide a NestJS-like experience to Dart Developers that want to develop Rest APIS Features

Vinicius Amélio 3 Sep 12, 2022
⚒️ A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart.

⚒️ Dart CLI Utilities A monorepo containing a collection of packages that provide useful functionality for building CLI applications in Dart. Document

Invertase 14 Oct 17, 2022
Add easily to your app an introduction screen to provide informations to new users

IntroductionScreen Introduction screen allow you to have a screen at launcher for example, where you can explain your app. This Widget is very customi

Jean-Charles Moussé 484 Jan 6, 2023
FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts

中文文档 中文介绍 Release Note v3.0-preview.17 PS: Before updating the beta version, please read the CHANGELOG to see if there are any BREAKING CHANGE Flutter

Alibaba 6.3k Dec 30, 2022
Trying out Flutter for desktop Web app development as an alternative to SPA frameworks (such as React and Angular) by recreating one of the pages of an existing CV Management web app

HTML Renderer Demo CanvasKit Renderer Demo Reddit discussion This repo contains a PoC of using Flutter as a traditional SPA framework for creating a d

Maxim Saplin 20 Oct 11, 2022
Tencent Cloud Chat: Samples of integratation Flutter SDK to an existing app.

Tencent Cloud Chat Integrate In-App Chat and Call to your existing applications. Samples of integration Flutter SDK to an existing app. This directory

Tencent Cloud 4 Nov 24, 2022
A modified version of the existing checkbox with the shape of a circle instead of a rounded rectangle!

A modified version of the existing checkbox with the shape of a circle instead of a rounded rectangle!

Mash Ibtesum 53 Oct 24, 2022
This project is a rebuild of the existing movie colony https://github.com/debbsefe/Movie-Colony. Here's also a link to the figma file https://www.figma.com/file/XpLFNEsROiN1z6lwnNHMrU/Movie-app?node-id=2956%3A10161

Tvfiy Generated by the Very Good CLI ?? A Very Good Project created by Very Good CLI. Getting Started ?? This project contains 3 flavors: development

Eferha Mamus 3 Nov 12, 2022
A wrapper around Navigator 2.0 and Router/Pages to make their use a easier.

APS Navigator - App Pagination System This library is just a wrapper around Navigator 2.0 and Router/Pages API that tries to make their use easier: ??

Guilherme Silva 14 Oct 17, 2022
FlutterNavigator is a dart library for dealing with the Navigator API without a build context

FlutterNavigator is a dart library for dealing with the Navigator API without a build context. This package wraps the NavigatorKey and provides a cleaner service for navigating without context in your flutter application.

Luke Moody 10 Oct 1, 2022
Aplicação para aula sobre Scaffold, Drawer e Navigator

scaffold_class A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started i

Deyvid J. Lira 7 Dec 27, 2022
A Flutter sensor plugin which provide easy access to the Pitch and Roll on Android and iOS devices.

Flutter Aeyrium Sensor Plugin Aeyrium Sensor Plugin A Flutter sensor plugin which provide easy access to the Pitch and Roll on Android and iOS devices

Aeyrium 58 Nov 3, 2022