navarggen 0.1.1

navarggen #

A source code generator for Flutter route navigation arguments.

Getting Started #

Add the packages to your pubspec.yaml file:

  navarggen: ^[latest version]

  build_runner: ^1.5.2 # Also depend on build_runner if you aren't already.
  navarggen_generator: ^[latest version]

Annotate your Widget class with NavigationArguments:

  'argumentName': ArgumentType,
  'title': String,
  'numbers': 'List<int>', // When you can't pass a Type, you can pass a String. 
class YourPage extends StatefulWidget { //...

Specify the part file for the generator code:

part 'your_widget_file_name.g.dart';

Run the build:

$ flutter pub run build_runner build

...or have it watch for changes:

$ flutter pub run build_runner watch

The output will be the following code in the your_widget_file_name.g.dart file:

class YourPageArgs {
  final ArgumentType argumentName;
  final String title;
  final List<int> numbers;
  YourPageArgs({this.argumentName, this.title, this.numbers});

You can then use it to pass arguments to your route like usual:

  arguments: YourPageArgs({
    argumentName: someObject,
    title: 'Your Title',
    numbers: [0, 1, 2, 3, 4],

Then in YourPage:

YourPageArgs args = ModalRoute.of(context).settings.arguments;

See the example project for a working example.

Use this package as a library

1. Depend on it

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

  navarggen: ^0.1.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:navarggen/navarggen.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 Jan 14, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4

Health issues and suggestions

Document public APIs. (-1 points)

4 out of 4 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/navarggen.dart.

Run dartfmt to format lib/navarggen.dart.

Maintenance issues and suggestions

Provide a file named (-20 points)

Changelog entries help developers follow the progress of your package. See the example generated by stagehand.

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

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0