flutter_boost 1.12.13

  • Readme
  • Changelog
  • Example
  • Installing
  • 93

Build Status pub package codecov


中文文档 中文介绍

Release Note #

Please checkout the release note for the latest 0.1.64 to see changes 0.1.64 release note

FlutterBoost #

A next-generation Flutter-Native hybrid solution. FlutterBoost is a Flutter plugin which enables hybrid integration of Flutter for your existing native apps with minimum efforts.The philosophy of FlutterBoost is to use Flutter as easy as using a WebView. Managing Native pages and Flutter pages at the same time is non-trivial in an existing App. FlutterBoost takes care of page resolution for you. The only thing you need to care about is the name of the page(usually could be an URL). 

Prerequisites #

You need to add Flutter to your project before moving on.The version of the flutter SDK requires v1.9.1+hotfixes, or it will compile error.

boost version description #

Flutter Boost VersionSupport Flutter SDK VersionDescriptionSupport AndroidX?
0.1.501.5.4-hotfixesandroid if other flutter versions or branches will compile incorrectly.No
0.1.51-0.1.591.5.4-hotfixesbugfix for 0.1.50.No
0.1.601.9.1-hotfixesAndroid does not support andriodx if other flutter branches will compile incorrectly.No
0.1.61-0.1.691.9.1-hotfixesbugfix for 0.1.60.No
0.1.631.9.1-hotfixesIf other branches will compile incorrectly. Synchronize with the 0.1.60 code, and bugfix also merge to this branch.No
1.9.1+21.9.1-hotfixesRename the version number and start supporting androidx by defaultYes
1.12.131.12.13-hotfixessupporting androidxYes
Flutter Boost branchSupport Flutter SDK VersionDescriptionSupport AndroidX?
v1.9.1-hotfixes1.9.1-hotfixesfor androidxYes
task/task_v1.9.1_support_hotfixes1.9.1-hotfixesfor supportNO
v1.12.13-hotfixes1.12.13-hotfixesfor androidxYes
task/task_v1.12.13_support_hotfixes1.12.13-hotfixesfor supportNO

Getting Started #

Add a dependency in you Flutter project. #

Open you pubspec.yaml and add the following line to dependencies:

androidx branch

flutter_boost:
    git:
        url: 'https://github.com/alibaba/flutter_boost.git'
        ref: ' 1.12.13'

support branch

flutter_boost:
    git:
        url: 'https://github.com/alibaba/flutter_boost.git'
        ref: 'task/task_v1.12.13_support_hotfixes'

Boost Integration #

Please see the boost example for details.

FAQ #

please read this document: FAQ

License #

This project is licensed under the MIT License - see the LICENSE.md file for details

Problem feedback group( dingding group) #

关于我们 #

阿里巴巴-闲鱼技术是国内最早也是最大规模线上运行Flutter的团队。

我们在公众号中为你精选了Flutter独家干货,全面而深入。

内容包括:Flutter的接入、规模化应用、引擎探秘、工程体系、创新技术等教程和开源信息。

架构/服务端/客户端/前端/算法/质量工程师 在公众号中投递简历,名额不限哦

欢迎来闲鱼做一个好奇、幸福、有影响力的程序员,简历投递:tino.wjf@alibaba-inc.com

订阅地址

For English

1.12.13 #

Supported Flutter sdk 1.12.13

1.9.1+2 #

Rename the version number and start supporting androidx by default, Based on the flutter 1.9.1 - hotfixs。 fixed bugs

0.1.66 #

Fixed bugs

0.1.64 #

Fixed bugs

0.1.63 #

android: Fixed bugs

iOS: no change

0.1.61 #

android: Fixed bugs

iOS: no change

0.1.60 #

A better implementation to support Flutter v1.9.1+hotfixes

Change the content android:

  1. based on the v1.9.1+hotfixes branch of flutter
  2. Solve major bugs, such as page parameter passing
  3. Support platformview
  4. Support androidx branch :feature/flutter_1.9_androidx_upgrade
  5. Resolve memory leaks
  6. Rewrite part of the code
  7. API changes
  8. Improved demo and added many demo cases

ios:

1.based on the v1.9.1+hotfixes branch of flutter 2.bugfixed

0.1.5 #

The main changes are as following:

  1. The new version do the page jump (URL route) based on the inherited FlutterViewController or Activity. The jump procedure will create new instance of FlutterView, while the old version just reuse the underlying FlutterView
  2. Avoiding keeping and reusing the FlutterView, there is no screenshot and complex attach&detach logical any more. As a result, memory is saved and black or white-screen issue occured in old version all are solved.
  3. This version also solved the app life cycle observation issue, we recommend you to use ContainerLifeCycle observer to listen the app enter background or foreground notification instead of WidgetBinding.
  4. We did some code refactoring, the main logic became more straightforward.

0.0.1 #

  • TODO: Describe initial release.

API changes #

From the point of API changes, we did some refactoring as following:

iOS API changes

  1. FlutterBoostPlugin's startFlutterWithPlatform function change its parameter from FlutterViewController to Engine

Before change

FlutterBoostPlugin
- (void)startFlutterWithPlatform:(id<FLBPlatform>)platform onStart:(void (^)(FlutterViewController *))callback;

After change

FlutterBoostPlugin2
- (void)startFlutterWithPlatform:(id<FLB2Platform>)platform
                         onStart:(void (^)(id<FlutterBinaryMessenger,
                                           FlutterTextureRegistry,
                                           FlutterPluginRegistry> engine))callback;

  1. FLBPlatform protocol removed flutterCanPop、accessibilityEnable and added entryForDart Before change:
@protocol FLBPlatform <NSObject>
@optional
//Whether to enable accessibility support. Default value is Yes.
- (BOOL)accessibilityEnable;
// flutter模块是否还可以pop
- (void)flutterCanPop:(BOOL)canpop;
@required
- (void)openPage:(NSString *)name
          params:(NSDictionary *)params
        animated:(BOOL)animated
      completion:(void (^)(BOOL finished))completion;
- (void)closePage:(NSString *)uid
         animated:(BOOL)animated
           params:(NSDictionary *)params
       completion:(void (^)(BOOL finished))completion;
@end

After change:

@protocol FLB2Platform <NSObject>
@optional
- (NSString *)entryForDart;
    
@required
- (void)open:(NSString *)url
   urlParams:(NSDictionary *)urlParams
        exts:(NSDictionary *)exts
      completion:(void (^)(BOOL finished))completion;
- (void)close:(NSString *)uid
       result:(NSDictionary *)result
         exts:(NSDictionary *)exts
   completion:(void (^)(BOOL finished))completion;
@end

Android API changes

Android mainly changed the IPlatform interface and its implementation. It removed following APIs:

Activity getMainActivity();
boolean startActivity(Context context,String url,int requestCode);
Map getSettings();

And added following APIs:

void registerPlugins(PluginRegistry registry) 方法
void openContainer(Context context,String url,Map<String,Object> urlParams,int requestCode,Map<String,Object> exts);
void closeContainer(IContainerRecord record, Map<String,Object> result, Map<String,Object> exts);
IFlutterEngineProvider engineProvider();
int whenEngineStart();

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_boost/flutter_boost.dart';
import 'simple_page_widgets.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

    FlutterBoost.singleton.registerPageBuilders({
      'embeded': (pageName, params, _)=>EmbededFirstRouteWidget(),
      'first': (pageName, params, _) => FirstRouteWidget(),
      'second': (pageName, params, _) => SecondRouteWidget(),
      'tab': (pageName, params, _) => TabRouteWidget(),
      'platformView': (pageName, params, _) => PlatformRouteWidget(),
      'flutterFragment': (pageName, params, _) => FragmentRouteWidget(params),
      ///可以在native层通过 getContainerParams 来传递参数
      'flutterPage': (pageName, params, _) {
        print("flutterPage params:$params");

        return FlutterRouteWidget(params:params);
      },
    });
    FlutterBoost.singleton.addBoostNavigatorObserver(TestBoostNavigatorObserver());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Boost example',
        builder: FlutterBoost.init(postPush: _onRoutePushed),
        home: Container(
            color:Colors.white
        ));
  }

  void _onRoutePushed(
      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");
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_boost: ^1.12.13

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:flutter_boost/flutter_boost.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
86
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
93
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/container/boost_container.dart. (-1.49 points)

Analysis of lib/container/boost_container.dart reported 3 hints:

line 174 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 215 col 3: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

line 222 col 5: The class 'Future' wasn't exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test
mockito 4.1.1
pedantic ^1.8.0