I get this error 'type 'Future' is not a subtype of type 'ApplicationMeta'. I create a payment function. payment function type is future<List>. This function returns installedUpiapps in the list. I need to pass an argument to appWidget. But I get this error 'type 'Future' is not a subtype of type 'ApplicationMeta'.
import 'package:flutter/material.dart';
import 'package:upi_pay/upi_pay.dart';
class Homes extends StatelessWidget {
payment() async {
var appMetaList = await UpiPay.getInstalledUpiApplications();
return appMetaList;
}
Widget appWidget(ApplicationMeta appMeta) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
appMeta.iconImage(48), // Logo
Container(
margin: EdgeInsets.only(top: 4),
alignment: Alignment.center,
child: Text(
appMeta.upiApplication.getAppName(),
textAlign: TextAlign.center,
),
),
],
);
}
@override
Widget build(BuildContext context) {
ApplicationMeta as = payment();
return appWidget(as);
}
}
Once you add a return type to
payment
method you should see a compilation error.payment
isasync
, so it returns aFuture
. In order to build a widget with it, you have to use aFutureBuilder
as described here https://api.flutter.dev/flutter/widgets/FutureBuilder-class.htmlAs for displaying a List of
ApplicationMeta
, have a look on these: