textfield_tags
this is a simple widget that allows your users to create tags by entering the tag’s name inside of textfield and make the tags appear in the textfield. after entering the tag, the user can press the spacebar or enter button to save the tag and move on to enter another tag.
compatibility
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0"
getting started
to start using this widget, you will need to first import the package inside your project following the install guide found on flutter.dev.
usage
to use this widget,
import 'package:textfield_tags/textfield_tags.dart';
inside your dart file- call the widget
textfieldtags()
. - the widget takes in three arguments:
tagsstyler
,textfieldstyler
, and a call back function that returns the tags your user enters.
you can investigate the properties oftagsstyler
andtextfieldstyler
for more customizations if you choose to do so.
when you want to use it, call the textfieldtags()
widget as bellow and customize it to your liking
textfieldtags(
textfieldstyler: textfieldstyler(
//these are properties you can tweek for customization
// bool textfieldfilled = false,
// string helpertext = 'enter tags',
// textstyle helperstyle,
// string hinttext = 'got tags?',
// textstyle hintstyle,
// edgeinsets contentpadding,
// color textfieldfilledcolor,
// bool isdense = true,
// bool textfieldenabled = true,
// outlineinputborder textfieldborder = const outlineinputborder(),
// outlineinputborder textfieldfocusedborder,
// outlineinputborder textfielddisabledborder,
// outlineinputborder textfieldenabledborder
),
tagsstyler: tagsstyler(
//these are properties you can tweek for customization
// edgeinsets tagpadding = const edgeinsets.all(4.0),
// edgeinsets tagmargin = const edgeinsets.symmetric(horizontal: 4.0),
// boxdecoration tagdecoration = const boxdecoration(color: color.fromargb(255, 74, 137, 92)),
// textstyle tagtextstyle,
// icon tagcancelicon = const icon(icons.cancel, size: 18.0, color: colors.green)
),
ontag: (tag) {
//this give you the tag entered
//print(tag)
},
)
examples
textfieldtags(
tagsstyler: tagsstyler(
tagtextstyle: textstyle(fontweight: fontweight.bold),
tagdecoration: boxdecoration(color: colors.blue[300], borderradius: borderradius.circular(8.0), ),
tagcancelicon: icon(icons.cancel, size: 18.0, color: colors.blue[900]),
tagpadding: const edgeinsets.all(6.0)
),
ontag: (tag) { print(tag)},
)
textfieldtags(
tagsstyler: tagsstyler(
tagtextstyle: textstyle(fontweight: fontweight.normal),
tagdecoration: boxdecoration(color: colors.blue[300], borderradius: borderradius.circular(0.0), ),
tagcancelicon: icon(icons.cancel, size: 18.0, color: colors.blue[900]),
tagpadding: const edgeinsets.all(6.0)
),
ontag: (tag) { print(tag)},
)
//the colors for this are used from https://flutter-color-picker.herokuapp.com/
textfieldtags(
tagsstyler: tagsstyler(
tagtextstyle: textstyle(fontweight: fontweight.bold, color: colors.white),
tagdecoration: boxdecoration(color: const color.fromargb(255,171,81,81), borderradius: borderradius.circular(8.0), ),
tagcancelicon: icon(icons.cancel, size: 16.0, color: color.fromargb(255,235,214,214)),
tagpadding: const edgeinsets.all(10.0),
),
ontag: (tag) { print(tag)},
)
Comments are closed.