maxilozoz_box 0.0.1

maxilozoz_box #

A new Flutter package project.

Getting Started #

This project is a starting point for a Dart package, a library module containing code that can be shared easily across multiple Flutter or Dart projects.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

测试 #

flutter test test/[*].dart

文档 #

启动 #

    import 'package:maxilozoz_box/application.dart';
    final Application app = new Application();;

路由 #

    import 'package:maxilozoz_box/modules/route/route.dart';

    MinRoute route = app.make('route');

    route.add('/', () => DemoPage());

    route.add('/page/:id', (Map data) => RegExpDemoPage(id: int.parse(data['id'])));

如果带参, 函数类型必须带有实参, 不然匹配不到

路由中间件 #

    import 'package:maxilozoz_box/modules/route/routeMiddleware.dart';
    class TestMiddleware {
        RouteMiddlewareFilterItem filter(RouteSettings settings){
            //    ok 过滤结果 如果为假 则会停止其余中间件
            //    settings 如需要重新定向路由, 需要设置新的name
            RouteMiddlewareFilterItem item = RouteMiddlewareFilterItem(ok: true, settings: settings);
            // auth is false, to auth
            bool auth = false;
            if(!auth) {
                item.settings = settings.copyWith(name: '/auth/login');
                item.ok = false;
            return item;

    route.routeMiddleware.add('auth', TestMiddleware());

    //添加一个路径为/path的路由 并设置`auth`中间件
    //访问/path会直接定向到/auth/logi页面 因为`auth`中间件因判断没有登陆修改了路由
    route.add('/path', (){}, middlewares: ['auth']);

配置参数 #


    //设置当前环境`http_connect_timeout` 默认设置生产环境
        'http_connect_timeout': 500

        'http_connect_timeout': 500
    }, dev: true);

        'http_connect_timeout': 500
    }, dev: false);


参考 Dio 3.0.1

    import 'package:maxilozoz_box/modules/http/http.dart';
    Http http = app.make('http');

日志 #

    List<String> logs = app.log(key: 'key');

    app.log(key: 'key', logStr: '...');

    //限制日志存储长度, 会自动剔除老日志
    app.log(key: 'key', logStr: '...', limit: 200);

其他 #

依赖注入 #

    //加入 utils 依赖, 每次获取到的依赖相同
    app.bind('utils', (Application app, dynamic params){
        return (){

    //关闭分享依赖 每次获取的依赖不同
    app.bind('utils', (Application app, dynamic params){
        return (){
    }, share: true);

    //获取 utils 依赖

    //对于分享的依赖, 可以设置 force 强制产生新的依赖
    app.make('utils', force: true);

    //获取依赖可以传递参数 对于不分享的依赖每次可以取得不同的特性
    app.make('utils', params: {
        'key': 'value'

    app.bind('utils', (Application app, dynamic params){
        return (){
            //可以获取其他依赖 自动解决依赖关系!
            print('utils' + app.make('other'));
    }, share: true);

服务提供者 #

    import 'package:maxilozoz_box/application.dart';

    class TestServiceProvider {
        String get name {
            return 'test';

        void register(Application app){
            app.bind('test', (Application app, dynamic params) {
                return "test";

        //暂时无用 留空即可
        void boot(Application app){}

[0.0.1] - 19/10/23

  • di & service provider & config & route & http & log

Use this package as a library

1. Depend on it

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

  maxilozoz_box: ^0.0.1

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:maxilozoz_box/application.dart';
import 'package:maxilozoz_box/di.dart';
import 'package:maxilozoz_box/modules/config/config.dart';
import 'package:maxilozoz_box/modules/config/config_provider.dart';
import 'package:maxilozoz_box/modules/http/http.dart';
import 'package:maxilozoz_box/modules/http/http_provider.dart';
import 'package:maxilozoz_box/modules/http/log.dart';
import 'package:maxilozoz_box/modules/http/rap.dart';
import 'package:maxilozoz_box/modules/http/rap_utils.dart';
import 'package:maxilozoz_box/modules/log/log.dart';
import 'package:maxilozoz_box/modules/log/log_provider.dart';
import 'package:maxilozoz_box/modules/route/route.dart';
import 'package:maxilozoz_box/modules/route/routeMiddleware.dart';
import 'package:maxilozoz_box/modules/route/route_provider.dart';
import 'package:maxilozoz_box/service_provider.dart';
import 'package:maxilozoz_box/supports/func.dart';
import 'package:maxilozoz_box/supports/storeHelper.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Health issues and suggestions

Document public APIs. (-0.66 points)

170 out of 172 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/application.dart.

Run flutter format to format lib/application.dart.

Format lib/di.dart.

Run flutter format to format lib/di.dart.

Format lib/modules/config/config.dart.

Run flutter format to format lib/modules/config/config.dart.

Fix additional 14 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/modules/config/config_provider.dart (Run flutter format to format lib/modules/config/config_provider.dart.)
  • lib/modules/http/http.dart (Run flutter format to format lib/modules/http/http.dart.)
  • lib/modules/http/http_provider.dart (Run flutter format to format lib/modules/http/http_provider.dart.)
  • lib/modules/http/log.dart (Run flutter format to format lib/modules/http/log.dart.)
  • lib/modules/http/rap.dart (Run flutter format to format lib/modules/http/rap.dart.)
  • lib/modules/http/rap_utils.dart (Run flutter format to format lib/modules/http/rap_utils.dart.)
  • lib/modules/log/log.dart (Run flutter format to format lib/modules/log/log.dart.)
  • lib/modules/log/log_provider.dart (Run flutter format to format lib/modules/log/log_provider.dart.)
  • lib/modules/route/route.dart (Run flutter format to format lib/modules/route/route.dart.)
  • lib/modules/route/routeMiddleware.dart (Run flutter format to format lib/modules/route/routeMiddleware.dart.)
  • lib/modules/route/route_provider.dart (Run flutter format to format lib/modules/route/route_provider.dart.)
  • lib/service_provider.dart (Run flutter format to format lib/service_provider.dart.)
  • lib/supports/func.dart (Run flutter format to format lib/supports/func.dart.)
  • lib/supports/storeHelper.dart (Run flutter format to format lib/supports/storeHelper.dart.)

Maintenance issues and suggestions

Support latest dependencies. (-20 points)

The version constraint in pubspec.yaml does not support the latest published versions for 2 dependencies (flutter_mobx, mobx).

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.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and maxilozoz_box.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.

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.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
dio ^3.0.1 3.0.8
flutter 0.0.0
flutter_mobx ^0.3.3 0.3.4+3 1.0.1
mobx ^0.3.8 0.3.10 1.0.2
shared_preferences ^0.5.3+4 0.5.6+1
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
flutter_web_plugins 0.0.0
http_parser 3.1.3
meta 1.1.8
path 1.6.4
shared_preferences_macos 0.0.1+5
shared_preferences_platform_interface 1.0.1
shared_preferences_web 0.1.2+3
sky_engine 0.0.99
source_span 1.6.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner ^1.3.1
mobx_codegen ^0.3.9