dynamic_form 0.3.4+2

  • Readme
  • Changelog
  • Example
  • Installing
  • new59

dynamicform #

pub GitHub

create your form with easier way

Getting Started #

  • generate form
  • Pre-existing elements

Installing #

Add the following to your pubspec.yaml file:

dependencies:
	dynamic_form: ^0.3.4+2

Simple Usage #

Creating a basic SimpleDynamicForm

SimpleDynamicForm(
      key: dynamicFormKey,
      groupElements: [
              GroupElement(
                            directionGroup: DirectionGroup.Vertical,
                            textElements: [
                            TextElement(label: "name"),
                            TextElement(
                                 label: "password", typeInput: TypeInput.Password)
                              ],
                             )
                  ],
              );

Declare GlobalKey to get validation,list values of forms #

GlobalKey<SimpleDynamicFormState> dynamicFormKey = GlobalKey<SimpleDynamicFormState>();

validate forms #

dynamicFormKey.currentState.validate()

all values in form #

dynamicFormKey.currentState.recuperateAllValues()

How to skectch your form ? #

textElement is small element in dynamicForm GroupElement is group of TextElement

GroupElement

PropertiesDescription
directionGroupDirection of form (Vertical/Horizontal)
sizeElementssize of each textElement of form When direction Horizontal,sum of values should be egal a 1
textElementsgroup of textElement.
paddingpadding of groups.
decorationdecoration of container groups.
backgroundColorcolor of the container groups.

textElement

PropertiesDescription
typeInputEnumerate to specifie type of TextField.
labeltext label of TextField.
onTapcallback when you click on TextField .
hinttext hint of textField.
errorMsgmessage to show when TextField isn't validate.
labelStylestyle of label TextField
errorStylestyle of error message TextField
hintStylestyle of hint TextFieldcolor
readOnlyenable TextField uneditable
validatorcallback validation of TextField
paddingpadding of TextField

EmailElement #

Pre-exsiting element with check validation of email

Pre-initialized values

extends from TextElement

PropertiesDescription
labeltext label of TextField.
hinttext hint of textField.
errorMsgmessage to show when TextField isn't validate.
labelStylestyle of label TextField
errorStylestyle of error message TextField
hintStylestyle of hint TextFieldcolor
readOnlyenable TextField uneditable
paddingpadding of TextField

PasswordElement #

Pre-exsiting element with check validation of password

Pre-initialized values

show/hide password

extends from TextElement

PropertiesDescription
labeltext label of TextField.
hinttext hint of textField.
errorMsgmessage to show when TextField isn't validate.
labelStylestyle of label TextField
errorStylestyle of error message TextField
hintStylestyle of hint TextFieldcolor
readOnlyenable TextField uneditable
paddingpadding of TextField
enableShowPasswordenable eye icon,make password text visible

NumberElement #

Pre-exsiting element for Number input

Pre-initialized values

enabled digitsOnly

extends from TextElement

PropertiesDescription
labeltext label of TextField.
hinttext hint of textField.
errorMsgmessage to show when TextField isn't validate.
labelStylestyle of label TextField
errorStylestyle of error message TextField
hintStylestyle of hint TextFieldcolor
readOnlyenable TextField uneditable
paddingpadding of TextField
isDigitsenable only digit number

CountryElement #

Pre-exsiting element for Country input

Pre-initialized values

pick country via BottomSheet

show flag of countries

PropertiesDescription
labeltext label of TextField.
initValueInitiale Value to country input.
labelModalSheetTitle of modalSheet
labelSearchModalSheethint search textfield in BottomSheet
countryTextResultenumeration get result of selection countries
showFlagshow flag of countris in modalsheet
paddingpadding of TextField

[0.3.4+2] - version alpha: #

  • fix error

[0.3.4+1] - version alpha: #

  • remove duplicated code
  • fix error

[0.3.4] - version alpha: #

  • add Country TextField
  • add CountryElement

[0.3.2+1] - version alpha: #

  • fix error in NumberElement- change validator

[0.3.2] - version alpha: #

[0.3.1+1] - version alpha: #

  • fix error
  • add numberElement into readme file

[0.3.1] - version alpha: #

  • add NumberElement
  • create pre-existing number textfield

[0.3.0] - version alpha: #

  • add PasswordElement
  • make groupelement inside container
  • customise groupelement design

[0.1.1] - version alpha: #

  • format files
  • fix code errors

[0.1.0] - version alpha: #

  • generate simple form
  • recuperate all values
  • validate form

example/lib/main.dart

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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Dynamic Form Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        backgroundColor: Colors.grey[300],
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Demo"),
        ),
        body: MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    GlobalKey<SimpleDynamicFormState> _globalKey =
        GlobalKey<SimpleDynamicFormState>();
    return SingleChildScrollView(
      child: Column(
        children: <Widget>[
          SimpleDynamicForm(
            key: _globalKey,
            groupElements: [
              GroupElement(
                margin: EdgeInsets.only(bottom: 5.0),
                directionGroup: DirectionGroup.Horizontal,
                sizeElements: [0.3],
                textElements: [
                  TextElement(
                      initValue: "",
                      label: "first name",
                      hint: "first name",
                      validator: (v) {
                        if (v.isEmpty) {
                          return "err";
                        }
                        return null;
                      }),
                  TextElement(label: "last name"),
                ],
              ),
              GroupElement(
                directionGroup: DirectionGroup.Vertical,
                textElements: [
                  NumberElement(
                      label: "phone",
                      validator: (v) {
                        if (v.isEmpty) {
                          return "err";
                        }
                        return null;
                      }),
                  EmailElement(label: "name",initValue: "example@mail.com"),
                  PasswordElement(),
                ],
              ),
              GroupElement(
                directionGroup: DirectionGroup.Vertical,
                textElements: [
                  CountryElement(
                    label: "Pays",
                    labelModalSheet: "Pays",
                    labelSearchModalSheet: "search",
                    initValue: "TUN",
                    countryTextResult: CountryTextResult.countryCode,
                    showFlag: false,
                  ),
                ],
              ),
            ],
          ),
          RaisedButton(
            onPressed: () {
              print(_globalKey.currentState.validate());
              print(_globalKey.currentState.recuperateAllValues());
            },
            child: Text("Validate"),
          )
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  dynamic_form: ^0.3.4+2

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

We analyzed this package on Mar 31, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health issues and suggestions

Document public APIs. (-0.41 points)

146 out of 149 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/src/country_text_field.dart.

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

Format lib/src/element.dart.

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

Format lib/src/simple_dynamic_form.dart.

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

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
flutter 0.0.0
flutter_svg ^0.17.3+1 0.17.3+1
Transitive dependencies
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
meta 1.1.8
path_drawing 0.4.1
path_parsing 0.1.4
petitparser 3.0.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
xml 3.7.0 4.1.0
Dev dependencies
flutter_test