hello there, I made a Future method and used that in a FutureBuilder but for some reason I end in a endless loop:
Future<Map<String, String>> fetchGroups() async {
_parseObject = ParseObject("wecar_groups", wcs.user.client);
var list = await wcs.user.get('groups');
setState(() {
groupIds = list.cast<String>();
});
groupIds.forEach((String val) async {
var group = await _parseObject.fetch(val);
groupNames.addAll({val: Group.fromJson(group['group']).name});
});
}
final selectGroup = FutureBuilder(
future: fetchGroups(),
builder: (context, snapshot) {
if(snapshot.connectionState == ConnectionState.done){
return Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Expanded(
flex: 5,
child: InputDecorator(
baseStyle: Theme.of(context).textTheme.title,
decoration: const InputDecoration(
labelText: 'Gruppen',
),
child: DropdownButton<String>(
value: _card.group,
hint: Text("Wählen Sie eine Gruppe aus:"),
//style: style,
isDense: false,
onChanged: (String newValue) {
setState(() {
_card.group = newValue;
});
},
items: groupIds.map((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(groupNames[value]),
);
}).toList(),
),
),
),
Expanded(
flex: 1,
child: IconButton(
icon: Icon(Icons.add_circle_outline),
onPressed: null,
)),
],
);
} else {
print(snapshot);
return CircularProgressIndicator();
}
},
);the connectionstate is all the time in waiting
No any search results
You already invited:
1 Answers
aaron
Upvotes from: