material_tag_editor 0.0.4

Flutter Android iOS web

A simple tag editor for inputing tags. This is design to act and feel similar the standard Material TextField as much as possible.

Material Tag Editor #

A simple tag editor for inputing tags.

image

Usage #

Add the package to pubspec.yaml

dependencies:
  material_tag_editor: x.x.x

Import it

import 'package:material_tag_editor/tag_editor.dart';

Use the widget

TagEditor(
  length: values.length,
  delimeters: [',', ' '],
  hasAddButton: true,
  inputDecoration: const InputDecoration(
    border: InputBorder.none,
    hintText: 'Hint Text...',
  ),
  onTagChanged: (newValue) {
    setState(() {
      values.add(newValue);
    });
  },
  tagBuilder: (context, index) => _Chip(
    index: index,
    label: values[index],
    onDeleted: onDelete,
  ),
)

It is possible to build the tag from your own widget, but it is recommended that Material Chip is used

class _Chip extends StatelessWidget {
  const _Chip({
    @required this.label,
    @required this.onDeleted,
    @required this.index,
  });

  final String label;
  final ValueChanged<int> onDeleted;
  final int index;

  @override
  Widget build(BuildContext context) {
    return Chip(
      labelPadding: const EdgeInsets.only(left: 8.0),
      label: Text(label),
      deleteIcon: Icon(
        Icons.close,
        size: 18,
      ),
      onDeleted: () {
        onDeleted(index);
      },
    );
  }
}
16
likes
110
pub points
74%
popularity

A simple tag editor for inputing tags. This is design to act and feel similar the standard Material TextField as much as possible.

Repository (GitHub)
View/report issues

Documentation

API reference

Uploader

clay864649@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on material_tag_editor