Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter_tags

with flutter tags you can create selectable or input tags that automatically adapt to the screen width

create beautiful tags quickly and easily.

installing

add this to your package’s pubspec.yaml file:

dependencies:
  flutter_tags: "^0.4.9+1"

demo

simple usage


import 'package:flutter_tags/flutter_tags.dart';
.
.
.
list _items;
double _fontsize = 14;

@override
void initstate(){
    super.initstate();
    // if you store data on a local database (sqflite), then you could do something like this
    model().getitems().then((items){
            _items = items;
        });
}

@override
widget build(buildcontext context) {
    return tags(
      key:_tagstatekey,
      textfield: tagstextfield(
        textstyle: textstyle(fontsize: _fontsize),
        constraintsuggestion: true, suggestions: [],
        //width: double.infinity, padding: edgeinsets.symmetric(horizontal: 10),
        onsubmitted: (string str) {
          // add item to the data source.
          setstate(() {
              // required
            _items.add(str);
          });
        },
      ),
      itemcount: _items.length, // required
      itembuilder: (int index){          
            final item = _items[index];
    
            return itemtags(
                  // each itemtags must contain a key. keys allow flutter to
                  // uniquely identify widgets.
                  key: key(index.tostring()),
                  index: index, // required
                  title: item.title,
                  active: item.active,
                  customdata: item.customdata,
                  textstyle: textstyle( fontsize: _fontsize, ),
                  combine: itemtagscombine.withtextbefore,
                  image: itemtagsimage(
                    image: assetimage("img.jpg") // or networkimage("https://...image.png")
                  ), // or null,
                  icon: itemtagsicon(
                    icon: icons.add,
                  ), // or null,
                  removebutton: itemtagsremovebutton(
                    onremoved: (){
                        // remove the item from the data source.
                        setstate(() {
                            // required
                            _items.removeat(index);
                        });
                        //required
                        return true;
                    },
                  ), // or null,
                  onpressed: (item) => print(item),
                  onlongpressed: (item) => print(item),
            );
    
      },
    );    
}

final globalkey<tagsstate> _tagstatekey = globalkey<tagsstate>();
// allows you to get a list of all the itemtags
_getallitem(){
    list<item> lst = _tagstatekey.currentstate?.getallitem;
    if(lst!=null)
        lst.where((a) => a.active==true).foreach( ( a) => print(a.title));        
}

wrapped widget example

you are free to wrap itemtags () inside another widget

tags(  
      itemcount: items.length, 
      itembuilder: (int index){ 
          return tooltip(
          message: item.title,
          child:itemtags(
            title:item.title,
          )
          );
      },
    );    

tags() parameters

propname description default value
columns possibility to set number of columns when necessary null
itemcount tag number to display required
symmetry ability to view and scroll tags horizontally false
horizontalscroll offset drawer width 0.4
heighthorizontalscroll height for horizontalscroll to set to display tags correctly 60
spacing horizontal space between the tags 6
runspacing vertical space between the tags 14
alignment horizontal wrapalignment wrapalignment.center
runalignment vertical wrapalignment wrapalignment.center
direction direction of the itemtags axis.horizontal
verticaldirection iterate item from the lower to the upper direction or vice versa verticaldirection.down
textdirection text direction of the itemtags textdirection.ltr
itembuilder tag generator
textfield add textfield tagstextfiled()

itemtags() parameters

  • indexrequired
  • titlerequired
  • textscalefactorcustom textscalefactor
  • activebool value (default true)
  • pressenabledactive onpress tag ( default true)
  • customdatapossibility to add any custom value in customdata field, you can retrieve this later. a good example: store an id from firestore document.
  • textstyletextstyle()
  • alignmentmainaxisalignment ( default mainaxisalignment.center)
  • combine – * ability to combine text, icons, images in different ways ( default itemtagscombine.imageoriconortext)*
  • iconitemtagsicon()
  • imageitemtagsimage()
  • removebuttonitemtagsremovebutton()
  • borderradiusborderradius
  • bordercustom border-side
  • paddingdefault edgeinsets.symmetric(horizontal: 7, vertical: 5)
  • elevationdefault 5
  • singleitemdefault false
  • textoverflowdefault textoverflow.fade
  • textcolordefault colors.black
  • textactivecolordefault colors.white
  • colordefault colors.white
  • activecolordefault colors.bluegrey
  • highlightcolor
  • splashcolor
  • colorshowduplicatedefault colors.red
  • onpressedcallback
  • onlongpressedcallback
  • onremovedcallback

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.