Following the last answer here, i am getting error
error: The element type 'Future' can't be assigned to the list type 'Widget'.
Future<Widget> getImage(String path) async {
try {
await rootBundle.load(path);
return Image.asset(path);
} catch (_) {
return SizedBox.shrink();
}
}
My code looks like this:
child: Column(
children: <Widget>[
Text('Text 1'),
Text('Show below image if exist'),
getImage('fileName'),
],
How to use 'getImage' to return the desired Widget?