I'm trying to use the multiselect package on pub.dev and i realized that the chip choice is what i'm gonna need, i decided to test out the example given on the latest version, and i basically copy pasted the code (with understanding it ofc) but it keeps giving me this error!
then I even opted to make the "values" of the onTap (List) but it gives error afterwards.
here's my code:
class _MyHomePageState extends State<MyHomePage> {
static List<Animal> _animals = [
Animal(id: 1, name: "Lion"),
Animal(id: 2, name: "Flamingo"),
Animal(id: 3, name: "Hippo"),
................
];
final _items = _animals
.map((animal) => MultiSelectItem<Animal>(animal, animal.name))
.toList();
List<Animal> _selectedAnimals = [];
final _multiSelectKey = GlobalKey<FormFieldState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Container(
child: Column(children: <Widget>[
MultiSelectChipField<Animal>(
items: _items,
initialValue: [_animals[4], _animals[7], _animals[9]],
title: Text("Animals"),
headerColor: Colors.blue.withOpacity(0.5),
decoration: BoxDecoration(
border: Border.all(color: Colors.blue.shade700, width: 1.8),
),
selectedChipColor: Colors.blue.withOpacity(0.5),
selectedTextStyle: TextStyle(color: Colors.blue[800]),
//this is where my error is:
onTap: (values) {
_selectedAnimals = values;
},
),
SizedBox(height: 40),
]),
),
),
);
}
}