route_ani_observer 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

route_ani_observer #

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.

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

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

void main() => runApp(
  RouteAniObserverProvider(
    child: App()
  )
);

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'routeAniObserve',
      home: Home(),
      routes: {
        'home': (_) => Home(),
        'test1': (_) => Test1(),
        'test2': (_) => Test2()
      },
    );
  }
}

class Home extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return HomeState();
  }
}

class HomeState extends State<Home> {

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
      color: Colors.red,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            child: Text('返回',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          Text('home',
            style: TextStyle(
              color: Colors.white,
              decoration: TextDecoration.none
            )
          ),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('test1');
            },
            child: Text('test1',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
          ),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('test2');
            },
            child: Text('test2',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
          ),
        ],
      ),
    );
  }
}

class Test1 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Test1State();
  }
}

class Test1State extends State<Test1> with RouteAniCompleteMixin, RouteAniListenerMixin {

  @override
  onRouteAniComplete() {
    print('routeAniCompleteHandler- test1');
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
      color: Colors.blue,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            child: Text('返回',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          Text('test1', style: TextStyle(
            color: Colors.white,
            decoration: TextDecoration.none
          )),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('home');
            },
            child: Text('返回到home',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
          ),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('test2');
            },
            child: Text('到test2',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
          ),
        ],
      ),
    );
  }
}

class Test2 extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Test2State();
  }
}

class Test2State extends State<Test2> with RouteAniCompleteMixin, RouteAniListenerMixin {

  @override
  onRouteAniComplete() {
    print('routeAniCompleteHandler- test2');
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: MediaQuery.of(context).padding.top),
      color: Colors.green,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          RaisedButton(
            child: Text('返回',
              style: TextStyle(
                color: Colors.white,
                decoration: TextDecoration.none
              )
            ),
            onPressed: () {
              Navigator.of(context).pop();
            },
          ),
          Text('test2',
            style: TextStyle(
              color: Colors.white,
              decoration: TextDecoration.none
            )),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('home');
            },
            child: Text('返回到home', style: TextStyle(
              color: Colors.white,
              decoration: TextDecoration.none
            )),
          ),
          RaisedButton(
            onPressed: () {
              Navigator.of(context).pushNamed('test1');
            },
            child: Text('到test1', style: TextStyle(
              color: Colors.white,
              decoration: TextDecoration.none
            )),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


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

We analyzed this package on Jul 2, 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 [route_ani_observer] that is in a package requiring null.

Health suggestions

Fix lib/src/route_ani_manage.dart. (-1 points)

Analysis of lib/src/route_ani_manage.dart reported 2 hints:

line 26 col 11: The member 'controller' can only be used within instance members of subclasses of 'package:flutter/src/widgets/routes.dart'.

line 48 col 13: The member 'controller' can only be used within instance members of subclasses of 'package:flutter/src/widgets/routes.dart'.

Fix lib/src/route_ani_observer_provider.dart. (-1 points)

Analysis of lib/src/route_ani_observer_provider.dart reported 2 hints:

line 4 col 7: This class (or a class that this class inherits from) is marked as '@immutable', but one or more of its instance fields aren't final: RouteAniObserverProvider.routeAniManage

line 14 col 21: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix lib/src/route_ani_listener_mixin.dart. (-0.50 points)

Analysis of lib/src/route_ani_listener_mixin.dart reported 1 hint:

line 6 col 8: Unused import: 'dart:async'.

Format lib/src/route_complete_mixin.dart.

Run flutter format to format lib/src/route_complete_mixin.dart.

Maintenance suggestions

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
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test