flutter_object_form_field 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 71

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';
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 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health suggestions

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

Analysis of lib/flutter_object_form_field.dart reported 2 hints:

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

line 49 col 20: This function has a return type of 'Widget', but doesn't end with a return statement.

Maintenance suggestions

Package is getting outdated. (-22.74 points)

The package was last published 64 weeks ago.


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 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies