flutter_object_form_field 1.0.1

  • README.md
  • Example
  • Installing
  • Versions
  • 76

flutter_object_form_field #

Working with TextFormField is nice until you want to work with something other than String. For example, if you want invoke date timer picker, you have to create a focus node, listen for focus, show the dialog when needed. If you do not want to use some special object to store the selected value, you will end up with parsing the data before save just because TextFormField only works with String.

This library provides ObjectFormField<T> that works much better for these cases. You provide it with a function that turns your object into String and a picker async function that returns newly picked object (DateTime from date picker).

Usage #

To use this plugin, add flutter_object_form_field as a dependency in your pubspec.yaml file.

Examples #

  objectToString: (emotion) => emotion?.name,
  pickValue: (oldEmotion) async {
    // returns an emotion object
    return await Navigator.push(
            builder: (context) => EmotionsPage()));
  decoration: InputDecoration(labelText: 'Emotion'),
  validator: (value) {
    if (value == null) {
      return 'You have to pick an emotion';

    if (value.name == 'Sadness') {
      return 'Show me your smile!';
  // can use some kind of formatter
  objectToString: (dateTime) => dateTime?.toString(),
  pickValue: (oldDate) async {
    return await showDatePicker(
      context: context,
      initialDate: DateTime.now(),
      firstDate: DateTime(1900),
      lastDate: DateTime(2100),
  decoration: InputDecoration(labelText: 'Date'),
  validator: (value) {
    if (value == null) {
      return 'You have to select date';

Contribution and Support #

Contributions are welcome!
If you want to contribute code please create a PR
If you find a bug or want a feature, please fill an issue

[1.0.1] - 01.11.2018

  • Minor bug fix

[1.0.0] - 01.11.2018

  • No changes

[0.0.1] - 01.11.2018

  • Initial implementation


Example #

The example consists of two fields - one with custom object Emotion and the other with DateTime object.

Have a look at lib/main.dart.

Use this package as a library

1. Depend on it

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

  flutter_object_form_field: ^1.0.1

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:flutter_object_form_field/flutter_object_form_field.dart';
Version Uploaded Documentation Archive
1.0.1 Nov 1, 2018 Go to the documentation of flutter_object_form_field 1.0.1 Download flutter_object_form_field 1.0.1 archive
1.0.0 Nov 1, 2018 Go to the documentation of flutter_object_form_field 1.0.0 Download flutter_object_form_field 1.0.0 archive
0.0.1 Nov 1, 2018 Go to the documentation of flutter_object_form_field 0.0.1 Download flutter_object_form_field 0.0.1 archive
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 Jun 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.1
  • pana: 0.12.17
  • Flutter: 1.5.4-hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/flutter_object_form_field.dart. (-0.50 points)

Analysis of lib/flutter_object_form_field.dart reported 1 hint:

line 9 col 9: The class 'Future' was not exported from 'dart:core' until version 2.1, but this code is required to be able to run on earlier versions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies