customizable_multiselect_field 0.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • new56

customizable_multiselect_field #

A Flutter package that provides a highly customizable multiselect field.

  • Supports multiples data sources with customs label keys and value keys.
  • Includes custumization through the classes CustomizableMultiselectWidgetOptions, CustomizableMultiselectDialogOptions and DataSourceOptions.
  • It's a FormField and contains the default properties of one (onSaved, validator, autovalidate and onChanged).

Usage #

  • Add the package into your dependencies in pubspec.yaml:
dependencies:
  customizable_multiselect_field: 0.0.1
  • Import in your code:
import 'package:customizable_multiselect_field/customizable_multiselect_flutter.dart';

Example #

CustomizableMultiselectField(
    customizableMultiselectWidgetOptions: CustomizableMultiselectWidgetOptions(
    hintText: Text('Please Select a value', style: TextStyle(color: Colors.grey)),
    decoration: InputDecoration(
        labelText: 'Multiselect Sample teste',
    ),
    chipShape: RoundedRectangleBorder(
        side: BorderSide(color: Colors.red, width: 1),
        borderRadius: BorderRadius.circular(16.0),
    ),
    ),
    customizableMultiselectDialogOptions: CustomizableMultiselectDialogOptions(),
    dataSourceList: [
    DataSource<String>(
        dataList: [
        {
            'label': 'Lime',
            'value': 'test1',
        },
        {
            'label': 'Apple',
            'value': 'test2',
        },
        ],
        valueList: fruitListValue,
        options: DataSourceOptions(valueKey: 'value', labelKey: 'label', title: Text('Fruits', style: TextStyle(color: Colors.red), textAlign: TextAlign.start,)),
    ),
    DataSource(
        dataList: [
        {
            'number': 'Chuck',
            'value': 1,
        },
        {
            'number': 'Rump Steak',
            'value': 2,
        },
        ],
        valueList: beefListValue,
        options: DataSourceOptions(valueKey: 'value', labelKey: 'number', title: Text('Beef', style: TextStyle(color: Colors.grey), textAlign: TextAlign.start,)),
    ),
    DataSource<int>(
        dataList: [
        {
            'number': 1,
            'value': 1,
        },
        {
            'number': 2,
            'value': 2,
        },
        ],
        valueList: sectorWithoutFoodListValue,
        options: DataSourceOptions(valueKey: 'value', labelKey: 'number', title: Text('Sectors Without Food', style: TextStyle(color: Colors.brown), textAlign: TextAlign.start,)),
    ),
    DataSource<String>(
        dataList: [
        {
            'key': 'Broccoli',
        },
        {
            'key': 'Cucumber',
        },
        ],
        options: DataSourceOptions(valueKey: 'key', labelKey: 'key', title: Text('Vegetables', style: TextStyle(color: Colors.green), textAlign: TextAlign.start)),
        valueList: vegetablesListValue,
    ),
    DataSource<String>(
        dataList: [
        {
            'key': 'No title',
        },
        ],
        options: DataSourceOptions(valueKey: 'key', labelKey: 'key',),
        valueList: noTitleListValue,
    ),
    ],
    onChanged: ((List<List<dynamic>> value) => print(value)),
    onSaved: ((List<List<dynamic>> newValueList) {
    setState(() {
        valueList = newValueList;
    });
    }),
    validator: ((List<List<dynamic>> value) {
    if(value.every((element) => element.isEmpty))
        return 'Please Select a value!';
    return null;

    })
),

Contributors #

[0.0.1] - 28/06/2020 #

  • First release
    • Supports multiples data sources with customs label keys and value keys.
    • Includes custumization through the classes CustomizableMultiselectWidgetOptions, CustomizableMultiselectDialogOptions and DataSourceOptions.
    • It's a FormField and contains the default properties of one (onSaved, validator, autovalidate and onChanged).

example/lib/main.dart

import 'package:customizable_multiselect_field/customizable_multiselect_flutter.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Customizable MultiselectField'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  final fruitListValue = [
    'test1',
    'test2',
  ];
  final beefListValue = [1, 2, 3];
  final List<int> sectorWithoutFoodListValue = [];
  final vegetablesListValue = ['Broccoli'];
  final noTitleListValue = ['No title'];
  List<List<dynamic>> valueList;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Form(
          key: _formKey,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: CustomizableMultiselectField(
                  customizableMultiselectWidgetOptions: CustomizableMultiselectWidgetOptions(
                    hintText: Text('Please Select a value', style: TextStyle(color: Colors.grey)),
                    decoration: InputDecoration(
                      labelText: 'Multiselect Sample teste',
                    ),
                    chipShape: RoundedRectangleBorder(
                      side: BorderSide(color: Colors.red, width: 1),
                      borderRadius: BorderRadius.circular(40.0),
                    ),
                  ),
                  customizableMultiselectDialogOptions: CustomizableMultiselectDialogOptions(),
                  dataSourceList: [
                    DataSource<String>(
                      dataList: [
                        {
                          'label': 'Lime',
                          'value': 'test1',
                        },
                        {
                          'label': 'Apple',
                          'value': 'test2',
                        },
                      ],
                      valueList: fruitListValue,
                      options: DataSourceOptions(valueKey: 'value', labelKey: 'label', title: Text('Fruits', style: TextStyle(color: Colors.red), textAlign: TextAlign.start,)),
                    ),
                    DataSource(
                      dataList: [
                        {
                          'number': 'Chuck',
                          'value': 1,
                        },
                        {
                          'number': 'Rump Steak',
                          'value': 2,
                        },
                        {
                          'number': 'Neck Steak',
                          'value': 3,
                        },
                      ],
                      valueList: beefListValue,
                      options: DataSourceOptions(valueKey: 'value', labelKey: 'number', title: Text('Beef', style: TextStyle(color: Colors.grey), textAlign: TextAlign.start,)),
                    ),
                    DataSource<int>(
                      dataList: [
                        {
                          'number': 1,
                          'value': 1,
                        },
                        {
                          'number': 2,
                          'value': 2,
                        },
                        {
                          'number': 3,
                          'value': 3,
                        },
                      ],
                      valueList: sectorWithoutFoodListValue,
                      options: DataSourceOptions(valueKey: 'value', labelKey: 'number', title: Text('Sectors Without Food', style: TextStyle(color: Colors.brown), textAlign: TextAlign.start,)),
                    ),
                    DataSource<String>(
                      dataList: [
                        {
                          'key': 'Broccoli',
                        },
                        {
                          'key': 'Cucumber',
                        },
                        {
                          'key': 'Cauliflower',
                        },
                      ],
                      options: DataSourceOptions(valueKey: 'key', labelKey: 'key', title: Text('Vegetables', style: TextStyle(color: Colors.green), textAlign: TextAlign.start)),
                      valueList: vegetablesListValue,
                    ),
                    DataSource<String>(
                      dataList: [
                        {
                          'key': 'No title',
                        },
                      ],
                      options: DataSourceOptions(valueKey: 'key', labelKey: 'key',),
                      valueList: noTitleListValue,
                    ),
                  ],
                  onChanged: ((List<List<dynamic>> value) => print(value)),
                  onSaved: ((List<List<dynamic>> newValueList) {
                    setState(() {
                      valueList = newValueList;
                    });
                  }),
                  validator: ((List<List<dynamic>> value) {
                    if(value.every((element) => element.isEmpty))
                      return 'Please Select a value!';
                    return null;

                  })
                ),
              ),
              SizedBox(height: 16,),
              RaisedButton(
                onPressed: () {
                  if(_formKey.currentState.validate()) {
                    _formKey.currentState.save();
                  }
                },
                child: Text('Save'),
              ),
              SizedBox(height: 16),
              Text(valueList.toString()),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  customizable_multiselect_field: ^0.0.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:customizable_multiselect_field/customizable_multiselect_flutter.dart';
import 'package:customizable_multiselect_field/models/customizable_multiselect_dialog_options.dart';
import 'package:customizable_multiselect_field/models/customizable_multiselect_widget_options.dart';
import 'package:customizable_multiselect_field/models/data_source.dart';
import 'package:customizable_multiselect_field/models/data_source_options.dart';
import 'package:customizable_multiselect_field/utils/extensions/extended-iterable.dart';
import 'package:customizable_multiselect_field/widgets/customizable_multiselect_Field.dart';
import 'package:customizable_multiselect_field/widgets/customizable_multiselect_dialog.dart';
import 'package:customizable_multiselect_field/widgets/customizable_multiselect_widget.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
56
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

Because:

  • customizable_multiselect_field that is a package requiring null.

Health suggestions

Format lib/models/customizable_multiselect_dialog_options.dart.

Run flutter format to format lib/models/customizable_multiselect_dialog_options.dart.

Format lib/models/customizable_multiselect_widget_options.dart.

Run flutter format to format lib/models/customizable_multiselect_widget_options.dart.

Format lib/models/data_source.dart.

Run flutter format to format lib/models/data_source.dart.

Fix additional 5 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/models/data_source_options.dart (Run flutter format to format lib/models/data_source_options.dart.)
  • lib/utils/extensions/extended-iterable.dart (Run flutter format to format lib/utils/extensions/extended-iterable.dart.)
  • lib/widgets/customizable_multiselect_Field.dart (Run flutter format to format lib/widgets/customizable_multiselect_Field.dart.)
  • lib/widgets/customizable_multiselect_dialog.dart (Run flutter format to format lib/widgets/customizable_multiselect_dialog.dart.)
  • lib/widgets/customizable_multiselect_widget.dart (Run flutter format to format lib/widgets/customizable_multiselect_widget.dart.)

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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test