Coder Social home page Coder Social logo

pdliuw / airoute Goto Github PK

View Code? Open in Web Editor NEW
29.0 2.0 4.0 1.02 MB

*1、Support routing management without context *2、Support 'non-intrusive parameter passing' routing management *3、Airoute that makes you fall in love with routing management

Home Page: https://flutter-app-sample.github.io/

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

Kotlin 0.80% Ruby 11.95% Swift 2.28% Objective-C 0.07% Dart 84.55% HTML 0.35%
flutter route dart flutter-router

airoute's Introduction

Airoute | 爱路由

totem


English Document 中文文档

我们的宗旨是:帮助开发者更加便利开发、切身体会编程之美!

airoute:

pub package

*1、支持无需context的路由管理,

*2、支持‘非侵入式参数传递’的路由管理,

*3、让你爱上路由管理的airoute

Airoute项目中的实战应用flutter sample

效果图

iOS Android
airoute_ios airoute_android
:- :-
macOS web
airoute_macos airoute_web
:- :-

1.安装

使用当前包作为依赖库

1. 依赖此库

在文件 'pubspec.yaml' 中添加

pub package


dependencies:

  airoute: ^version

或以这种方式添加


  # Route package.
  airoute:
    git:
      url: https://github.com/pdliuw/airoute.git

2. 安装此库

你可以通过下面的命令行来安装此库


$ flutter pub get


你也可以通过项目开发工具通过可视化操作来执行上述步骤

3. 导入此库

现在,在你的Dart编辑代码中,你可以使用:


import 'package:airoute/airoute.dart';

2.使用

1.在你的项目入口'main.dart'中配置:

Airoute 全局配置


void main() {
  runApp(
    ///
    /// 配置Airoute
    Airoute.createMaterialApp(
      home: LaunchPage(),
      routes: <String, WidgetBuilder>{
        "/LaunchPage": (_) => LaunchPage(),
        "/SecondPage": (_) => SecondPage(),
      },
    ),
  );
}


2.调用/应用

*1、跳转新页面


              Airoute.pushNamed(routeName: "/routeName");

*2、关闭页面


              Airoute.pop();

*3、跳转新页面,并添加动画


              Airoute.pushNamedWithAnimation(
                  routeName: "/routeName",
                  routePageAnimation: AirouteTransition.Slide);

*4、传递参数、接收参数

传递参数


              Airoute.pushNamed(
                routeName: "/Page",
                argument: "遇见你,我很开心😄😄😄",
              );

传递number参数


              Airoute.pushNamed(
                routeName: "/SecondPage",
                argument: 0,
              );

传递Map参数

              Airoute.pushNamed(
                routeName: "/Page",
                argument: {
                  "account":"this is accont",
                  "password":"this is password ",
                },

传递Array参数

              Airoute.pushNamed(
                routeName: "/Page",
                argument: [
                  "Air",
                  "James",
                  "Lucy",
                  "Tom",
                ],
              );
              

接收参数


class Page extends StatefulWidget with AirArgumentReceiver {

  @override
  State<StatefulWidget> createState() {
    return _PageState();
  }

  @override
  void receive(AirArgument argument) {
    print("收到${argument.argument}参数了,我很开心😄😄😄");
  }
}


*5、路由跳转

pub package


          Airoute.push(
            route: AwesomeMessageRoute(
              awesomeMessage: AwesomeHelper.createAwesome(
                  title: "title", message: "message"),
              theme: null,
              settings: RouteSettings(name: "/messageRouteName"),
            ),
          );

*6、更多用法点击,查看更多

待办

  • 支持: 路由拦截器.

LICENSE

BSD 3-Clause License

Copyright (c) 2020, pdliuw
All rights reserved.

airoute's People

Contributors

nonnonnon avatar pdliuw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

airoute's Issues

how can i implementing this library

could you help me how can i implementing this library on my project?

i get error and i can't resolve that

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Builder:
'package:flutter/src/widgets/navigator.dart': Failed assertion: line 1578 pos 16: 'observer.navigator == null': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

The relevant error-causing widget was: 
  StartupApplication file:///C:/Users/mahdi/AndroidStudioProjects/unlimited_power_pro/lib/main.dart:39:70
When the exception was thrown, this was the stack: 
#2      NavigatorState.didUpdateWidget (package:flutter/src/widgets/navigator.dart:1578:16)
#3      StatefulElement.update (package:flutter/src/widgets/framework.dart:4396:58)
#4      Element.updateChild (package:flutter/src/widgets/framework.dart:2977:15)
#5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4243:16)
#6      Element.rebuild (package:flutter/src/widgets/framework.dart:3947:5)
...

my implemented code:

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  Provider.debugCheckInvalidValueType = null;

  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp, DeviceOrientation.portraitDown]).then((_) {
    runApp(MultiProvider(providers: providers, child: OKToast(child: StartupApplication())));
  });
}

class StartupApplication extends StatefulWidget {
  StartupApplication() {
    Navigation.initRoutes();
  }

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

class _StartupApplicationState extends State<StartupApplication> {
  @override
  Widget build(BuildContext context) {
    return Airoute.createMaterialApp(
      title: Fa.appName,
      theme: ThemeData(
        fontFamily: 'IranSansLight',
        primaryColor: Color(0xFF823A84),
        accentColor: Color(0xFF823A84),
        textTheme: TextTheme(title: TextStyle(fontFamily: 'IranSansLight', color: Colors.black)),
      ),
      home: Directionality(
          textDirection: TextDirection.rtl,
          ),
      routes: <String, AirouteBuilder>{
        "/showDocumentContent": () => ShowDocumentContent(),
      },
    );
  }
}

slide animation direction

is any way to set optional direction for slide animation?

for example from left to right, right to left, top to bottom or bottom to top

setState() or markNeedsBuild() called when widget tree was locked.

i get this error when i try to use Duration

The following assertion was thrown while finalizing the widget tree:
setState() or markNeedsBuild() called when widget tree was locked.

This _ModalScope<dynamic> widget cannot be marked as needing to build because the framework is locked.
The widget on which setState() or markNeedsBuild() was called was: _ModalScope<dynamic>-[LabeledGlobalKey<_ModalScopeState<dynamic>>#a501a]
  state: _ModalScopeState<dynamic>#877b3
When the exception was thrown, this was the stack: 
#0      Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:3901:9)
#1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:3911:6)
#2      State.setState (package:flutter/src/widgets/framework.dart:1168:14)
#3      _ModalScopeState._routeSetState (package:flutter/src/widgets/routes.dart:664:5)
#4      ModalRoute.setState (package:flutter/src/widgets/routes.dart:784:30)

fade effect

is any solution to make fade effect for slide animation?

getting error on using pushNamedWithAnimation

when i pull your repository and try to test i get this error on clicking on main page with optional options;

MaterialButton(
  onPressed: () {
    Airoute.pushNamedWithAnimation(
        routeName: "/SecondPage",
        argument: "遇见你,我很开心😄😄😄",
        routePageAnimation: AirouteTransition.Slide);
  },
  color: Theme.of(context).primaryColor,
  textColor: Colors.white,
  child: Text("跳转下一页"),
),

error


════════ Exception caught by gesture ══════
The following assertion was thrown while handling a gesture:
'package:flutter/src/widgets/routes.dart': Failed assertion: line 130 pos 12: 'duration != null && duration >= Duration.zero': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

When the exception was thrown, this was the stack: 
#2      TransitionRoute.createAnimationController (package:flutter/src/widgets/routes.dart:130:12)
#3      PageRoute.createAnimationController (package:flutter/src/widgets/pages.dart:40:50)
#4      TransitionRoute.install (package:flutter/src/widgets/routes.dart:177:19)
#5      ModalRoute.install (package:flutter/src/widgets/routes.dart:959:11)
#6      NavigatorState.push (package:flutter/src/widgets/navigator.dart:1791:11)
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#2bcf9
  debugOwner: GestureDetector
  state: possible
  won arena
  finalPosition: Offset(195.3, 421.0)
  finalLocalPosition: Offset(61.3, 22.0)
  button: 1
  sent tap down
═══════════════════════════════════════════════

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.