[英]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 .这里我必须使用pdfImageFromImageProvider函数来处理无状态小部件。 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),
);
} }
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>
.您的方法必须返回
Future<Widget>
,因为我理解您问题的标题是您的错误,这意味着您返回的是Widget
而不是Future<Widget>
。 To do that, you should wrap your widget inside the Future like this:为此,您应该像这样将小部件包装在 Future 中:
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.希望这会奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.