xform 0.1.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 74

XForm #

Flutter forms with superpowers. #

Simplifies form creation and management. Simply create form fields and the xform will take care of the rest. Moving to the next field on enter, keyboard type based on field type, validation, multipage forms, etc.

Supported Fields #

  • XTextField - Your usual text field
  • XDateField - Text field with a date picker
  • XSelectField - Dropdown selection box
  • XCheckbox - Checkbox returning true or false values
  • XCheckboxGroup - Grouped checkboxes returning an array of the selected values
  • XRadioGroup - Grouped radio buttons

Quick Start #

  • Add the XForm widget to a stateful widget
  • Add XFields as children, each page wrapped in a ListView.
  • Add a submit function to handle the data on submission.

Example #

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

void main() => runApp(MaterialApp(
      home: Scaffold(
          appBar: AppBar(title: const Text('XForm')), body: FormWidget()),
    ));

class FormWidget extends StatefulWidget {
  @override
  _FormWidgetState createState() => _FormWidgetState();
}

class _FormWidgetState extends State<FormWidget> {
  _submit(formData) {
    print(formData);
  }
  
  @override
  Widget build(BuildContext context) {  
    return Padding(
      padding: const EdgeInsets.all(8.0),
      child: XForm(submit: _submit, children: <Widget>[
        ListView(children: <Widget>[
          XTextField(
            name: "name",
            label: "Name",
            required: true,
          ),
          XTextField(
            name: "email",
            label: "Email Address",
            type: FieldType.email,
          ),
        ]),
      ]),
    );
  }
}

[0.1.2] - 29 Jan 2019

  • Fixed Form display on long forms to not overlap buttons
  • Added support for checkbox, checkboxgroup and radiogroup
  • Changed default values from string to dynamic

[0.1.1] - 17 Jan 2019

  • Fixed bug in date field default values

[0.1.0] - 16 Jan 2019

  • Added styling options to fields
  • Added required option to select field
  • Updated date field to also take keyboard input
  • Updated readme

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:xform/xform.dart';
import 'dart:async';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  GlobalKey scaffoldKey = GlobalKey();
  @override
  Widget build(BuildContext context) {
    Future _submit(Map<String, dynamic> formData) async {
      List<Widget> children = [];
      formData.forEach((key, value) {
        children.add(Text("$key: ${value.toString()} ${value.runtimeType}"));
      });
      showDialog(
        context: scaffoldKey.currentState.context,
        builder: (BuildContext context) {
          return AlertDialog(
            title: Text("Form Data"),
            content: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                children: children),
            actions: <Widget>[
              FlatButton(
                child: Text("Close"),
                onPressed: () {
                  Navigator.of(context).pop();
                },
              ),
            ],
          );
        },
      );
    }

    return MaterialApp(
      home: Scaffold(
        key: scaffoldKey,
        appBar: AppBar(
          title: const Text('XForm'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: XForm(submit: _submit, children: <Widget>[
            ListView(children: <Widget>[
              XTextField(
                name: "name",
                label: "Name",
                required: true,
              ),
              XTextField(
                name: "number",
                label: "Number",
                type: FieldType.numeric,
              ),
              XTextField(
                name: "email",
                label: "Email Address",
                type: FieldType.email,
              ),
              XTextField(
                name: "password",
                label: "Password",
                type: FieldType.password,
              ),
            ]),
            ListView(children: <Widget>[
              XCheckbox(
                name: "agree",
                label: "I agree",
                defaultValue: true,
              ),
              XRadioGroup(
                name: 'radios',
                selected: "male",
                options: [
                  Option(name: "Male", value: "male"),
                  Option(name: "Female", value: "female"),
                ],
              ),
              XCheckboxGroup(
                name: 'favourite',
                label: 'Favourite Food',
                selected: ["cake"],
                options: [
                  Option(name: "Cake", value: "cake"),
                  Option(name: "Candy", value: "candy"),
                ],
              ),
            ]),
            ListView(children: <Widget>[
              XDateField(
                name: "date",
                label: "Date of Birth",
                defaultValue: DateTime.now(),
              ),
              XSelectField(
                name: "options",
                label: "Options",
                required: true,
                options: [Option(name: "Name", value: "value")],
              )
            ]),
          ]),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  xform: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:xform/xform.dart';
  
Version Uploaded Documentation Archive
0.1.2 Jan 29, 2019 Go to the documentation of xform 0.1.2 Download xform 0.1.2 archive
0.1.1 Jan 17, 2019 Go to the documentation of xform 0.1.1 Download xform 0.1.1 archive
0.1.0 Jan 16, 2019 Go to the documentation of xform 0.1.0 Download xform 0.1.0 archive
0.0.1 Jan 14, 2019 Go to the documentation of xform 0.0.1 Download xform 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
49
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]
74
Learn more about scoring.

We analyzed this package on Feb 20, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13+1
  • Flutter: 1.2.1

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
intl ^0.15.7 0.15.7
validate ^1.7.0 1.7.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
path 1.6.2
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test