In my code, I want to show the floating action button based on condition. That condition is evaluated based on a HTTP call which is async in nature as per flutter. My below code is not returning anything.
Widget _getFAB() {
var Data = GetDetailsFromHTTP();
userJSON.then((Data ) {
if (1 == 2) {
return Container();
} else {
return FloatingActionButton(
backgroundColor: Colors.deepOrange[800],
child: Icon(Icons.add_shopping_cart),
onPressed: null);
}
});
}
Await is also not working since it does not allow return type as widget. How to create a method which waits on async call and returns widget?