在这里,我创建了一个 DropdownItemMenu,它从 firebase 集合中获取元素,但它显示了一个错误
\n\n\n未为类型“BuildContext”定义方法“showSnackBar”
\n
Container(\n margin: EdgeInsets.only(left: 16, right: 16),\n height: MediaQuery.of(context).size.height * 0.10,\n child: Card(\n child: Padding(\n padding: const EdgeInsets.all(8.0),\n child: DropdownButton<String>(\n isExpanded: false,\n style: TextStyle(\n fontSize: 14, color: Colors.blueGrey),\n icon: const Icon(Icons.keyboard_arrow_down),\n underline: Container(color: Colors.transparent),\n onChanged: (serieValue) {\n final snackBar = SnackBar(\n content: Text(\n 'S\xc3\xa9rie selectionn\xc3\xa9e est $serieValue',\n style: TextStyle(\n fontWeight: FontWeight.bold,\n fontSize: 14,\n color: Color(0xff11b719)),\n ));\n Scaffold.of(context.showSnackBar(snackBar));\n\n\n setState(() {\n selectedIndexSerie = serieValue;\n });\n },\n value: selectedIndexSerie,\n hint: Text(\n 'Selectionner une s\xc3\xa9rie',\n style: …Run Code Online (Sandbox Code Playgroud)