Here i create a DropdownItemMenu which get the element from firebase collection, but it shows me an error
The method 'showSnackBar' isn't defined for the type 'BuildContext'
Container(
margin: EdgeInsets.only(left: 16, right: 16),
height: MediaQuery.of(context).size.height * 0.10,
child: Card(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: DropdownButton<String>(
isExpanded: false,
style: TextStyle(
fontSize: 14, color: Colors.blueGrey),
icon: const Icon(Icons.keyboard_arrow_down),
underline: Container(color: Colors.transparent),
onChanged: (serieValue) {
final snackBar = SnackBar(
content: Text(
'Série selectionnée est $serieValue',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: Color(0xff11b719)),
));
Scaffold.of(context.showSnackBar(snackBar));
setState(() {
selectedIndexSerie = serieValue;
});
},
value: selectedIndexSerie,
hint: Text(
'Selectionner une série',
style: TextStyle(
fontWeight: FontWeight.bold,
fontSize: 14,
color: Color(0xff11b719)),
),
items: series,
),
),
),
);
You misplaced a ')' -->
Scaffold.of(context).showSnackBar(snackBar);
Also, showSnackBar is deprecated, consider using ScaffoldMessenger
ScaffoldMessenger.of(context).showSnackBar(snackBar);
That's your line of code: "Scaffold.of(context.showSnackBar(snackBar));" You have to put the capital 'S'; would look like this: "Scaffold.of(context.showSnackBar(SnackBar));"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.