dropdownfield 0.0.2

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

dropdownfield #

Custom Flutter Widget for a customizable dropdown field with auto-complete functionality This widget is meant to be used within a Flutter Form

alt text

Installing: #

In your pubspec.yaml, add the following dependency

dependencies:
  dropdownfield: 0.0.2

Example Usage: #

import 'package:dropdownfield/dropdownfield.dart';

    DropDownField(
        value: accountname,
        required: true,
        labelText: 'Account Name *',
        icon: Icon(Icons.account_balance),
        items: accountNames,
        setter: (dynamic newValue) {
            accountname = newValue;
        }
    ),

Features: #

  • Can be used for showing drop-down of suggestions for a form field
  • Provides auto-complete functionality - as the user types, shows all suggestions that match part of the typed in text
  • Provides validation of user-typed value against the list of suggestions by default. Can be turned off with a setting
  • Provides ability to do "mandatory" value check if needed
  • Quick clear icon to clear out typed in value
  • Appearance can be customized to match your application theme
  • Clicking dropdown arrow will automatically close the soft keyboard

License: #

This project is licensed under the BSD License - see the LICENSE file for details

[0.0.1] - 12-Feb-2019

  • Can be used for showing drop-down of suggestions for a form field
  • Provides auto-complete functionality - as the user types, shows all suggestions that match part of the typed in text
  • Provides validation of user-typed value against the list of suggestions by default. Can be turned off with a setting
  • Provides ability to do "mandatory" value check if needed
  • Appearance can be customized to match your application theme
  • Clear icon to quickly clear out typed in value
  • Clicking dropdown arrow will automatically close the soft keyboard

[0.0.2] - 13-Feb-2019

  • Only updated the image and README.md

example/main.dart

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

void main() async {
  runApp(MaterialApp(title: 'MyApp', home: ExampleForm()));
}

class ExampleForm extends StatefulWidget {
  ExampleForm();

  @override
  _ExampleFormState createState() => _ExampleFormState();
}

class _ExampleFormState extends State<ExampleForm> {
  // Create a global key that will uniquely identify the Form widget and allow
  // us to validate the form
  final _formKey = GlobalKey<FormState>();
  Map<String, dynamic> formData;
  List<String> cities = [
    'Bangalore',
    'Chennai',
    'New York',
    'Mumbai',
    'Delhi',
    'Tokyo',
  ];
  List<String> countries = [
    'INDIA',
    'USA',
    'JAPAN',
  ];

  _ExampleFormState() {
    formData = {
      'City': 'Bangalore',
      'Country': 'INDIA',
    };
  }

  @override
  Widget build(BuildContext context) {
    return FutureBuilder(
        future: buildFutures(),
        builder: (BuildContext context, AsyncSnapshot snapshot) {
          switch (snapshot.connectionState) {
            default:
              if (snapshot.hasError) {
                return Text(snapshot.error.toString());
              } else {
                if (snapshot.data != null)
                  return Scaffold(
                      appBar: AppBar(
                        titleSpacing: 5.0,
                        title: Text(
                          'Custom Dropdown Field Example',
                          style: TextStyle(fontSize: 15.0),
                        ),
                        actions: <Widget>[
                          Builder(
                            builder: (BuildContext context) {
                              return IconButton(
                                  icon: const Icon(Icons.check),
                                  iconSize: 20.0,
                                  tooltip: 'Save',
                                  onPressed: () async {
                                    if (_formKey.currentState.validate()) {
                                      _formKey.currentState.save();
                                      _formKey.currentState.save();
                                      showDialog<String>(
                                          context: context,
                                          builder:
                                              (BuildContext dialogContext) =>
                                                  AlertDialog(
                                                    content: Text(
                                                        'Data submitted is \n${formData.toString()}'),
                                                  ));
                                    }
                                  });
                            },
                          )
                        ],
                      ),
                      body: Container(
                        color: Colors.white,
                        constraints: BoxConstraints.expand(),
                        child: Form(
                            key: _formKey,
                            autovalidate: false,
                            child: SingleChildScrollView(
                                child: Column(
                              children: <Widget>[
                                Divider(
                                    height: 10.0,
                                    color: Theme.of(context).primaryColor),
                                DropDownField(
                                    value: formData['City'],
                                    icon: Icon(Icons.location_city),
                                    required: true,
                                    hintText: 'Choose a city',
                                    labelText: 'City *',
                                    items: cities,
                                    strict: false,
                                    setter: (dynamic newValue) {
                                      formData['City'] = newValue;
                                    }),
                                Divider(
                                    height: 10.0,
                                    color: Theme.of(context).primaryColor),
                                DropDownField(
                                    value: formData['Country'],
                                    icon: Icon(Icons.map),
                                    required: false,
                                    hintText: 'Choose a country',
                                    labelText: 'Country',
                                    items: countries,
                                    setter: (dynamic newValue) {
                                      formData['Country'] = newValue;
                                    }),
                              ],
                            ))),
                      ));
                else
                  return LinearProgressIndicator();
              }
          }
        });
  }

  Future<bool> buildFutures() async {
    return true;
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  dropdownfield: ^0.0.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:dropdownfield/dropdownfield.dart';
  
Version Uploaded Documentation Archive
0.0.2 Feb 13, 2019 Go to the documentation of dropdownfield 0.0.2 Download dropdownfield 0.0.2 archive
0.0.1 Feb 12, 2019 Go to the documentation of dropdownfield 0.0.1 Download dropdownfield 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
78
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
84
Overall:
Weighted score of the above. [more]
86
Learn more about scoring.

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

  • Dart: 2.2.0
  • pana: 0.12.14
  • Flutter: 1.4.7

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

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

Analysis of lib/dropdownfield.dart reported 2 hints:

line 103 col 29: The member 'setState' can only be used within instance members of subclasses of 'package:flutter/src/widgets/framework.dart'.

line 262 col 20: Avoid using unnecessary statements.

Maintenance suggestions

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.

The package description is too short. (-6 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.

Dependencies

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
flutter_test