Skip to content

Instantly share code, notes, and snippets.

@nparsons08
Created Dec 11, 2019
Embed
What would you like to do?
// mobile/lib/people.dart:23
@override
Widget build(BuildContext context) {
return FutureBuilder<List>(
future: _users,
builder: (BuildContext context, AsyncSnapshot<List> snapshot) {
if (!snapshot.hasData) {
return Center(child: CircularProgressIndicator());
}
return ListView(
children: snapshot.data
.where((u) => u != widget.account['user'])
.map((u) => ListTile(
title: Text(u),
onTap: () {
showDialog<String>(
context: context,
builder: (BuildContext context) => AlertDialog(content: Text("Click to follow"), actions: [
FlatButton(
child: const Text('Follow'),
onPressed: () async {
await ApiService().follow(widget.account, u);
Navigator.pop(context, "Followed");
},
)
]),
).then<void>((String message) {
// The value passed to Navigator.pop() or null.
if (message != null) {
Scaffold.of(context)
..removeCurrentSnackBar()
..showSnackBar(SnackBar(
content: Text(message),
));
}
});
},
))
.toList(),
);
},
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment