magpie 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 42

magpie SDK #

magpie SDK是一个flutter plugin,内部已为开发者集成了flutter engine等相关必要库,native开发同学无需安装flutter SDK; magpie SDK还内置包装了FlutterBoost路由及页面生命周期管理功能,新增了native与dart侧常用的一些通信能力, 提供协议动态注册等常用功能。
(A Native-Futter hybrid development solution. Native developers do not need to install FlutterSDK. This Flutter plugin provides general capabilities such as routing management and dynamic protocol registration.)

目录结构 #

-  lib
-  ios      - source         Magpie iOS SDK 源码 , 可通过Pod集成
            - flutter        Flutter Engine , 可通过Pod集成
            - lib            Magpie iOS SDK 静态库,可通过Pod集成
            - lib_project    Magpie iOS SDK静态库编译工程
            - product        iOS debug demo app.framework 
-  android                   Magpie android SDK源码,可通过gradle集成
-  example  - android        android 示例工程 
            - ios            iOS 示例工程
            - lib            Dart 示例工程
                    
             

magpie SDK版本说明 #

magpei SDK基于v1.12.13-hotfixes 如果你是native开发同学,那么可以不用安装flutter SDK,magpie内部已集成flutter engine等相关必要库

安装 #

Dart代码的集成和使用 #

Dart集成Magpie Plugin详见这里。

iOS代码集成和使用 #

iOS集成Magpie SDK详见这里。

Android代码集成和使用 #

Android集成Magpie SDK详见这里。

Examples #

更详细的使用例子请参考example

LICENSE #

BSD 3-Clause "New" or "Revised" License

问题反馈 #

关于我们 #

致谢 #

我们在页面栈管理和路由功能上直接使用了FlutterBoost。FlutterBoost经历过长期的实践检验,提供的能力满足了我们这方面的所有需求。感谢FlutterBoost提供了这么优秀的能力。

0.0.3 #

native交互新增支持返回future

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:magpie/magpie.dart';
import 'package:magpie/pub_plugins/flutter_boost/support/logger.dart';
import 'simple_page_widgets.dart';
import 'package:magpie/magpie_bridge.dart';

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    Magpie.singleton.registerPageBuilders({
      'flutterFragment': (pageName, params, _) =>
          FragmentRouteWidget(params),
      'flutterPage': (pageName, params, _) {
        print("flutterPage params:$params");
        return FlutterRouteWidget(params:params);
      },
    });
    //
    MagpieBridge.singleton.addDataListener((name, params) async {
      var a = "来自Dart的数据 Name = $name , Key = ${params.keys.first}";
      return a;
    });

    MagpieBridge.singleton.addNativeActionListener('EventTest',
        (name, params) async {
      var a = "来自Dart的Event $name key = " + params.keys.first;
      return a;
    });
  }

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

  void _onRoutePushed(
      String pageName, String uniqueId, Map params, Route route, Future _) {}
}

class FragmentRouteWidget extends StatelessWidget {
  final Map params;

  FragmentRouteWidget(this.params);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('This is a flutter fragment'),
      ),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Container(
            margin: const EdgeInsets.only(top: 20.0),
            child: Text(
              params['tag'] ?? '',
              style: TextStyle(fontSize: 28.0, color: Colors.red),
            ),
            alignment: AlignmentDirectional.center,
          ),
          //Expanded(child: Container()),
          InkWell(
            child: Container(
                padding: const EdgeInsets.all(8.0),
                margin: const EdgeInsets.all(8.0),
                decoration: BoxDecoration(
                  color: Color(0xFFF59A23),
                  borderRadius: BorderRadius.all(Radius.circular(5.0)),
                ),
                child: Text(
                  'open flutter page',
                  style: TextStyle(fontSize: 18.0, color: Colors.black),
                )),
            onTap: () => Magpie.singleton.open("sample://flutterPage"),
          ),
          InkWell(
            child: Container(
                padding: const EdgeInsets.all(8.0),
                margin: const EdgeInsets.all(8.0),
                decoration: BoxDecoration(
                  color: Color(0xFFF59A23),
                  borderRadius: BorderRadius.all(Radius.circular(5.0)),
                ),
                child: Text(
                  'open native page',
                  style: TextStyle(fontSize: 18.0, color: Colors.black),
                )),
            onTap: () =>
                Magpie.singleton.open("native://nativePage",
                  urlParams: {"query": {"aaa": "bbb"}}, exts:{"exts":"hello"}).then((result){
                  assert(result == null || result is Map);
                  Map params = result;
                  if(params == null){
                    params = Map();
                  }
                  Logger.log("哈哈哈哈哈"+params.toString());
                }),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  magpie: ^0.0.3

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:magpie/magpie.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
24
Health:
Code health derived from static analysis. [more]
66
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
50
Overall:
Weighted score of the above. [more]
42
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Health issues and suggestions

Fix lib/pub_plugins/flutter_boost/container/boost_container.dart. (-26.86 points)

Analysis of lib/pub_plugins/flutter_boost/container/boost_container.dart failed with 1 error, 5 hints, including:

line 204 col 14: A value of type 'void' can't be returned from method 'pop' because it has a return type of 'bool'.

line 102 col 17: 'ancestorStateOfType' is deprecated and shouldn't be used. Use findAncestorStateOfType instead. This feature was deprecated after v1.12.1..

line 102 col 43: 'TypeMatcher' is deprecated and shouldn't be used. TypeMatcher has been deprecated because it is no longer used in framework(only in deprecated methods). This feature was deprecated after v1.12.1..

line 108 col 17: 'ancestorStateOfType' is deprecated and shouldn't be used. Use findAncestorStateOfType instead. This feature was deprecated after v1.12.1..

line 108 col 43: 'TypeMatcher' is deprecated and shouldn't be used. TypeMatcher has been deprecated because it is no longer used in framework(only in deprecated methods). This feature was deprecated after v1.12.1..

Fix lib/magpie.dart. (-4.89 points)

Analysis of lib/magpie.dart reported 10 hints, including:

line 22 col 1: Prefer using /// for doc comments.

line 28 col 1: Prefer using /// for doc comments.

line 34 col 1: Prefer using /// for doc comments.

line 54 col 3: Prefer using /// for doc comments.

line 65 col 3: Prefer using /// for doc comments.

Fix lib/magpie_bridge.dart. (-2.96 points)

Analysis of lib/magpie_bridge.dart reported 6 hints, including:

line 50 col 13: This function has a return type of 'Future

line 59 col 13: This function has a return type of 'Future

line 67 col 13: This function has a return type of 'Future

line 76 col 13: This function has a return type of 'Future

line 86 col 13: This function has a return type of 'Future

Fix additional 6 files with analysis or formatting issues. (-2.49 points)

Additional issues in the following files:

  • lib/pub_plugins/flutter_boost/container/container_manager.dart (4 hints)
  • lib/pub_plugins/flutter_boost/container/container_coordinator.dart (1 hint)
  • lib/pub_plugins/flutter_boost/channel/boost_channel.dart (Run flutter format to format lib/pub_plugins/flutter_boost/channel/boost_channel.dart.)
  • lib/pub_plugins/flutter_boost/container/boost_page_route.dart (Run flutter format to format lib/pub_plugins/flutter_boost/container/boost_page_route.dart.)
  • lib/pub_plugins/flutter_boost/flutter_boost.dart (Run flutter format to format lib/pub_plugins/flutter_boost/flutter_boost.dart.)
  • lib/pub_plugins/flutter_boost/support/logger.dart (Run flutter format to format lib/pub_plugins/flutter_boost/support/logger.dart.)

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test