flutterintent 1.0.0

  • Readme
  • Changelog
  • Installing
  • 58

flutterintent #

flutterintent helps you to make your navigation easier and readable. It implements the intent pattern of the Android Framework.

Getting Started with the plugin #

1. Add to your pubspec.yaml #

dependencies:
	flutter:
		sdk: flutter
	flutterintent:

2. Import it #

import  'package:flutterintent/flutterintent.dart';

3. Use it #

Send an intent:

FlutterIntent(context:context,name: "/page2")
..startActivity();

Send an intent and attach data:

FlutterIntent(context:context,name: "/page2")
..putExtra("myString","Hello World")
..putObjectExtra("myObject",Car(color: "red")
..startActivity();

Get an intent and the attached data:

This plugin required the usage of the onGenerateRoute attribute of the MaterialApp or CupertinoApp Widget. For getting the intent we send we have to setup the following:

@override
  Widget build(BuildContext context) {
    return MaterialApp(
      onGenerateRoute: (settings)  {
        //Convert settings to flutter intent type
        return FlutterIntentService.fromRouteSettings(settings, (intent) {
            //Do always a null check, because on start the intent is always null
            if(intent == null || intent.name == "/")
              return HomePage();
            if(intent.name == "/page2") {
              //fetch the string which is send with the key "myString"
              var text = intent.getStringExtra("myString"); //Hello World
              return PageTwo(text: text)
            }
        });
      },
    );
  }

Start a widget for getting a result If you want to get a result back from a widget when it's closed you can use startForResult():

//Page 1
FlutterIntent(context: context,name: "/page2")
..startForResult((result,intent,requestCode) {
    if(result == Result.ok && requestCode == 200) {
        print(intent.getStringExtra("hello_world"))
    }
})
..

Set Result and send data back to previous widget:

//Page 2
FlutterIntent.setResult(context: context,result: Result.ok)
..putExtra("hello_world","Hello World")
..finish()
..

Profit! :)

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

Use this package as a library

1. Depend on it

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


dependencies:
  flutterintent: ^1.0.0

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:flutterintent/flutterintent.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
22
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
84
Overall:
Weighted score of the above. [more]
58
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 [flutterintent] that is in a package requiring null.

Health suggestions

Format lib/flutterintent.dart.

Run flutter format to format lib/flutterintent.dart.

Format lib/src/intent.dart.

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

Format lib/src/results.dart.

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

Maintenance suggestions

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 flutterintent.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.

The package description is too short. (-6 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.

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