'The argument type 'Future<Widget>' can't be assigned to the parameter type 'Widget'.dart
Here I have to use pdfImageFromImageProvider function to stateless widget. So, Is it possible to resolve this issue using stateless widget?
Future<Widget> getWidgetAsync(double size) async {
PdfImage val = await pdfImageFromImageProvider(
pdf: pdf.document,
image: fw.AssetImage('assets/' + iconPath),
);
return Container(
width: size,
height: size,
decoration: BoxDecoration(
color: layoutbg,
shape: BoxShape.circle,
),
child: Image(val),
);
}
Solution 1:[1]
Your method must return Future<Widget>
, as I'm understanding your question's title is your error, its mean that you returning a Widget
not Future<Widget>
. To do that, you should wrap your widget inside the Future like this:
Future<Widget> getWidgetAsync(double size) async {
PdfImage val = await pdfImageFromImageProvider(
pdf: pdf.document,
image: fw.AssetImage('assets/' + iconPath),
);
return Future.value(Container(
width: size,
height: size,
decoration: BoxDecoration(
color: layoutbg,
shape: BoxShape.circle,
),
child: Image(val),
));
Hope this will work.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Babken |