Я пытаюсь создать dropdownButtonFormField со списком значений объектов из базы данных sqflite. Я дошел до того, что элементы списка будут отображаться, но когда я нажму на один из них, он выдаст ошибку ![The error](https://i.stack.imgur.com/M119G.jpg)
class Test extends StatefulWidget {
@override
_TestState createState() => _TestState();
}
class _TestState extends State<Test> {
Section currentSection;
@override
Widget build(BuildContext context) {
final sectionsProvider = Provider.of<SectionsProvider>(context);
return Scaffold(
body: Container(
padding: EdgeInsets.all(15),
child: FutureBuilder<List<Section>>(
future: sectionsProvider.getSections(),
builder: (BuildContext context,AsyncSnapshot<List<Section>> snapshot){
if(!snapshot.hasData){
return Text('Loading...');
}else{
return DropdownButtonFormField<Section>(
//decoration: inputDecoration.copyWith(hintText: currentSection.title),
//value: currentSection,
items: snapshot.data.map((section){
return DropdownMenuItem<Section>(
value: section,
child: Row(
children: [
Icon(
Icons.brightness_1,
size: 15,
color: Color(section.color),
),
SizedBox(width: 20,),
Text(section.title),
],
),
);
},
).toList(),
isExpanded: false,
isDense: true,
onChanged: (value){
setState(() {
currentSection = value;
});
},
);
}
},
),
),
);
}
}