I want to return a picture using retrofit for my flutter application but on the build Widget I got this error : **This expression has a type of ‘void’ so its value can’t be used.
**
this is my code:
class MyApp extends StatelessWidget {
const MyApp({super.key});
Future<void> getData() async {
final dio = Dio();
final client = ApiService(dio);
final response = await client.downloadFile();
WidgetsFlutterBinding.ensureInitialized();
runApp(MaterialApp(
home: Scaffold(
body: Center(
child: Image.memory(response.response.data),
),
),
));
}
@override
Widget build(BuildContext context) {
return FutureBuilder<void>(
future: getData(),
builder: (context, AsyncSnapshot<void> snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data);
} else {
return CircularProgressIndicator();
}
}
);
}
}
I want to return the getData() content.
2
Answers
Not sure if it works but maybe you can try this:
Try this once I think this will work for you: