expansion_form 0.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 62

expansion_form #

Dynamic form with expansion Items. Each item is composed by multiple Options. Item's options can depend on the selected option of another Item.

expansion_form

[0.0.3] - 06/04/2020. #

  • Feature: New method to get selected options from Filtro.

[0.0.2] - 06/04/2020. #

  • Bugfix: Next item doesn't expand automatically if current item has too many options.

[0.0.1] - 05/31/2020. #

  • First version.

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        body: MyWidget(),
      ),
    );
  }
}

class MyWidget extends StatefulWidget {
  @override
  _MyWidgetState createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  GlobalKey<FiltroState> filtroKey;
  var isFormValid = false;

  _onValidationChange(bool value) {
    setState(() {
      isFormValid = value;
    });
  }

  @override
  void initState() {
    filtroKey = GlobalKey<FiltroState>();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Filtro example"),
      ),
      body: Column(
        children: <Widget>[
          Filtro(
            key: filtroKey,
            onValidateChange: _onValidationChange,
            items: [
              FiltroItemModel(
                name: "Estado",
                key: "estado",
                dependents: ["rede"],
                isRequired: true,
                options: [
                  FiltroItemOptionModel(
                    key: "ba",
                    name: "Bahia",
                  ),
                  FiltroItemOptionModel(
                    key: "rj",
                    name: "Rio de Janeiro",
                  ),
                ],
              ),
              FiltroItemModel(
                name: "Rede",
                key: "rede",
                dependents: ["loja"],
                isRequired: true,
                optionsDependency: {
                  "ba": [
                    FiltroItemOptionModel(
                      key: "walmart",
                      name: "Walmart",
                    ),
                    FiltroItemOptionModel(
                      key: "mix_bahia",
                      name: "Mix Bahia",
                    ),
                  ],
                  "rj": [
                    FiltroItemOptionModel(
                      name: "Pão de Açúcar",
                      key: "pao_de_acucar",
                    ),
                    FiltroItemOptionModel(
                      name: "Sonda",
                      key: "sonda",
                    ),
                  ],
                },
              ),
              FiltroItemModel(
                name: "Loja",
                key: "loja",
                isRequired: true,
                optionsDependency: {
                  "walmart": [
                    FiltroItemOptionModel(
                      key: "walmart_1",
                      name: "Walmart 1",
                    ),
                    FiltroItemOptionModel(
                      key: "walmart_2",
                      name: "Walmart 2",
                    ),
                    FiltroItemOptionModel(
                      name: "Mix Bahia 2",
                      key: "mix_bahia_2",
                    ),
                  ],
                  "mix_bahia": [
                    FiltroItemOptionModel(
                      name: "Mix Bahia 1",
                      key: "mix_bahia_1",
                    ),
                    FiltroItemOptionModel(
                      name: "Mix Bahia 2",
                      key: "mix_bahia_2",
                    ),
                  ],
                  "pao_de_acucar": [
                    FiltroItemOptionModel(
                      name: "Pão de Açúcar 1",
                      key: "pao_de_acucar_1",
                    ),
                    FiltroItemOptionModel(
                      name: "Pão de Açúcar 2",
                      key: "pao_de_acucar_2",
                    ),
                  ],
                  "sonda": [
                    FiltroItemOptionModel(
                      name: "Sonda 1",
                      key: "sonda_1",
                    ),
                    FiltroItemOptionModel(
                      name: "Sonda 2",
                      key: "sonda_2",
                    ),
                  ],
                },
              ),
            ],
          ),
          RaisedButton(
            onPressed: isFormValid
                ? () {
                    print(filtroKey.currentState.selectedOptions);
                  }
                : null,
            child: Text("Confirm"),
          ),
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  expansion_form: ^0.0.3

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:expansion_form/expansion_form.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
37
Health:
Code health derived from static analysis. [more]
97
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 [expansion_form] that is in a package requiring null.

Health suggestions

Fix lib/filtro_controller.g.dart. (-1.49 points)

Analysis of lib/filtro_controller.g.dart reported 3 hints:

line 86 col 8: Avoid using braces in interpolation when not needed.

line 87 col 18: Avoid using braces in interpolation when not needed.

line 88 col 12: Avoid using braces in interpolation when not needed.

Fix lib/shared/components/app_expansion_tile.dart. (-1 points)

Analysis of lib/shared/components/app_expansion_tile.dart reported 2 hints:

line 136 col 22: 'subhead' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is subtitle1. This feature was deprecated after v1.13.8..

line 163 col 33: 'subhead' is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is subtitle1. This feature was deprecated after v1.13.8..

Fix lib/shared/models/filtro_item_option_model.g.dart. (-0.50 points)

Analysis of lib/shared/models/filtro_item_option_model.g.dart reported 1 hint:

line 30 col 10: Avoid using braces in interpolation when not needed.

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.7.0 <3.0.0
flutter 0.0.0
flutter_mobx ^1.1.0 1.1.0+1
mobx ^1.2.1 1.2.1+1
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
build_runner ^1.10.0
flutter_test
mobx_codegen ^1.1.0