I tried myself and it definitely works with this:
return ItemTags(
// Each ItemTags must contain a Key. Keys allow Flutter to
// uniquely identify widgets.
key: Key(index.toString()),
index: index, // required
title: item,
active: false,
singleItem: true,
customData: index,
textStyle: TextStyle(
fontSize: _fontSize,
),
combine: ItemTagsCombine.withTextBefore,
icon: ItemTagsIcon(
icon: Icons.add,
), // OR null, // OR null,
);
itemBuilder's Tags attribute is a loop so the active property should set to false,
and singleItem to true to avoid multiple selections.
EDIT: It seems that if you set up with singleItem to true, you can't initiate with an item to active, see below in their package.
active: widget.singleItem ? false : widget.active,
It means that it doesn't care about your active property if you set the singleItem to true. So you can't do this.
For me, there are 2 solutions:
Solution 1
You modify by yourself the package, see : https://medium.com/flutter-community/how-to-modify-an-existing-pub-package-to-use-in-your-flutter-project-4e909452ee66
Solution 2
Simulate a tap on the screen to choose the right item which has to be selected
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…