I want to show list of data when i choose from dropdown, but still error LateInitializationError: Field 'listTanaman' has not been initialized. i just initialize the variable and don't assign value to the variable.
i'm initialize the varibale like this
List<Komoditas>? listTanaman;
and assign in this dropdown
DropdownButton(
value: dropdownValue,
items: snapshot.data!.docs
.map((DocumentSnapshot doc) {
return DropdownMenuItem(
value: doc.id,
child: Container(
decoration: BoxDecoration(
borderRadius:
BorderRadius.circular(5)),
height: 100,
padding: const EdgeInsets.all(10),
child: Text(doc.get('nama')),
),
);
}).toList(),
onChanged: (newValue) {
setState(() {
dropdownValue = newValue.toString();
kategori = snapshot.data!.docs
.where((newValue) => true)
.first
.get('nama');
});
db
.collection('kategori')
.doc(dropdownValue)
.collection(kategori!)
.snapshots()
.map((event) => listTanaman);
}),
anyone know where is my fault ?
