fluro_plus 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • new48

Fluro_Plus项目简介 #

Fluro_Plus主要对Fluro进行二次包装,采用Bundle来进行页面间传递的信使,还对Navigate进行了包装,提供常见的操作方式,更加方便使用和项目集成,目前只是在初学阶段,欢迎指点

使用说明

引入依赖
fluro_plus:
    git: https://github.com/OSpoon/fluro_plus.git
构建项目路由
/// 继承FluroPlusPageRouters
/// 重写generatorRoutes方法
/// 使用FluroPlusPageRouter对象来进行定义
/// 使用Bundle进行页面间数据传输
/// 解释:内部仍沿用Fluro的传参数方式,
///      所有fluro传参的限制还是会存在,
///      中文编码已在Bundle中的putString增加开关
class Routers extends FluroPlusPageRouters {
  static String home = "/home";
  static String one_page = "/one_page";
  static String two_page = "/two_page";

  @override
  List<FluroPlusPageRouter> generatorRoutes() {
    return [
      FluroPlusPageRouter(
          path: home,
          widgetFunc: (Bundle bundle) {
            return HomePage();
          }),
      FluroPlusPageRouter(
          path: one_page,
          widgetFunc: (Bundle bundle) {
            return NewOnePage(
              bundle: bundle,
            );
          })
    ];
  }
}
初始化路由
MyApp() {
  FluroPlusApp.setupRoutes(Routers());
}

MaterialApp(
  onGenerateRoute: FluroPlusApp.router.generator,
);
页面接收
class NewOnePage extends StatefulWidget {

  /// 通过Bundle传参
  final Bundle bundle;

  const NewOnePage({Key key, this.bundle}) : super(key: key);

  @override
  _NewOnePageState createState() => _NewOnePageState();
}

class _NewOnePageState extends State<NewOnePage> {
  @override
  Widget build(BuildContext context) {
    print('bundle  >>>>::: ${widget.bundle.runtimeType}');
    return Scaffold(
      appBar: AppBar(
        title: Text("演示NewOnePage页"),
      ),
      body: Container(
        child: Center(
          child: Column(
            children: <Widget>[
              Text('name ${widget.bundle.getString('name')}'),
              Text('yname ${widget.bundle.getString('yname')}'),
              Text('desc ${widget.bundle.getString('desc')}'),
              Text('age ${widget.bundle.getInt('age')}'),
              Text('sex ${widget.bundle.getBool('sex')}'),
              Text('language ${widget.bundle.getList('language')?.first}'),
              Text('height ${widget.bundle.getDouble('height')}'),
            ],
          ),
        ),
      ),
    );
  }
}
API使用
/// 简单跳转
RaisedButton(
  child: Text('简单跳转'),
  onPressed: () {
    FluroPlusNavigate.goto(context, Routers.one_page);
  }),

/// 简单跳转+转场动画
RaisedButton(
  child: Text('简单跳转+转场动画'),
  onPressed: () {
    FluroPlusNavigate.goto(context, Routers.one_page,
        transitionType: TransitionType.inFromBottom);
  }),

/// 简单跳转+跳转后销毁当前页面
RaisedButton(
  child: Text('简单跳转+跳转后销毁当前页面'),
  onPressed: () {
    FluroPlusNavigate.goto(context, Routers.one_page,
        replace: true);
  }),

/// 简单跳转+携带参数
RaisedButton(
  child: Text('简单跳转+携带参数'),
  onPressed: () {
    Bundle bundle = Bundle()
      ..putString('name', name, isComponent: true)
      ..putString('yname', yname)
      ..putString('desc', desc, isComponent: true)
      ..putBool('sex', sex)
      ..putInt('age', age)
      ..putList('language', language)
      ..putDouble('height', height);
    FluroPlusNavigate.goto(context, Routers.one_page,
        bundle: bundle);
  }),

/// 简单跳转+携带参数+接收返回结果
RaisedButton(
  child: Text('简单跳转+携带参数+接收返回结果'),
  onPressed: () {
    Bundle bundle = Bundle()
      ..putString('name', name, isComponent: true)
      ..putString('yname', yname);
    FluroPlusNavigate.gotoWithResult(context, Routers.one_page,
        bundle: bundle, function: (result) {
      print('result ::: ${result}');
    });
  }),

Fluro_Plus源码地址,部分代码来自网络搜索来的案例,并注释了来源,如有未标明了请联系我一下。

[0.0.5] #

  • 主要按照检测进行修正
  • 添加MIT License

[0.0.4] #

  • 主要按照检测进行修正

[0.0.3] #

  • 主要按照检测进行修正

[0.0.2] #

  • 主要按照检测进行修正

[0.0.1] #

  • 完成初版

example/main.dart

import 'package:fluro_plus/fluro_plus.dart';
import 'package:flutter/material.dart';

import 'page/home_page.dart';
import 'routers.dart';

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

class MyApp extends StatelessWidget {
  MyApp() {
    FluroPlusApp.setupRoutes(Routers());
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: FluroPlusApp.router.generator,
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: HomePage(),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  fluro_plus: ^0.0.5

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

We analyzed this package on Jul 9, 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 not compatible with SDK dart

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

Maintenance suggestions

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.6.0 <3.0.0
fluro ^1.6.3 1.6.3
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