Closed joshuajennysibbu closed 3 years ago
The build
method runs synchronously. Your call to payment
is returning a Future
, not a List<ApplicationMeta>
. Please go through Flutter concepts and design your workflow such that the Future
returned by payment
method is completed and has returned the expected List<ApplicationMeta>
variable for the build
method to use to render your expected UI.
Looking at your usage/design in the above code, you can use FutureBuilder
(see https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html) to get that going. That is by no means the only way to achieve that; but probably the most natural to Flutter apps.
Closing this bug with this.
The
build
method runs synchronously. Your call topayment
is returning aFuture
, not aList<ApplicationMeta>
. Please go through Flutter concepts and design your workflow such that theFuture
returned bypayment
method is completed and has returned the expectedList<ApplicationMeta>
variable for thebuild
method to use to render your expected UI.Looking at your usage/design in the above code, you can use
FutureBuilder
(see https://api.flutter.dev/flutter/widgets/FutureBuilder-class.html) to get that going. That is by no means the only way to achieve that; but probably the most natural to Flutter apps.Closing this bug with this.
Actually, forget to rename the title. My problem is UpiPay.getInstalledUpiApplications() return null. It does not show installed UPI apps.
It's very confusing with iterations of the problem statement changing. Please post the whole code and stack trace for clarity. Also, see if your problem matches #25 and comment here.
import 'package:flutter/material.dart';
import 'package:upi_pay/upi_pay.dart';
class Homes extends StatelessWidget {
Future<List<ApplicationMeta>> payment() async {
final List<ApplicationMeta> appMetaList =
await UpiPay.getInstalledUpiApplications();
return appMetaList;
}
Widget appWidget(appMeta) {
ApplicationMeta aps = appMeta;
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
aps.iconImage(48), // Logo
Container(
margin: EdgeInsets.only(top: 4),
alignment: Alignment.center,
child: Text(
aps.upiApplication.getAppName(),
textAlign: TextAlign.center,
),
),
],
);
}
@override
Widget build(BuildContext context) {
List<ApplicationMeta> vas;
Future<List<ApplicationMeta>> as = payment();
as.then((value) => () {
vas = value;
});
return appWidget(vas);
}
}
This is my code.. I get this exception: the getter 'upiApplication' was called on null. Receiver: null Tried calling: upiApplication upiApplication return null.
As per my earlier comment, please rectify your code using FutureBuilder
or an equivalent mechanism. You are getting this exception because variable aps
is accessed in the build
method call before your future has completed to populate aps
with a valid non-null list.
UpiPay.getInstalledUpiApplications().then((upiApps) {
setState(() {
this.upiApps = upiApps;
});
});
print(upiApps);
super.initState();
Even this code returns a null list
You are printing the upiApps
app outside the then
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning null
@vaibhavcs99 can you try to run the example app in my fork https://github.com/reeteshranjan/upi_pay and let us know if you see any applications there?
Also, which UPI payment apps have you configured with the bank account linked on your phone?
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning null
Yes, it still returns null.
@vaibhavcs99 can you try to run the example app in my fork https://github.com/reeteshranjan/upi_pay and let us know if you see any applications there?
Also, which UPI payment apps have you configured with the bank account linked on your phone?
It again return null.
@vaibhavcs99 can you try to run the example app in my fork https://github.com/reeteshranjan/upi_pay and let us know if you see any applications there? Also, which UPI payment apps have you configured with the bank account linked on your phone?
It again return null.
My comment mentioned two things: 1) run the example app and share observations, and 2) specify the payment apps configured to the point of setting up your bank account. Could you provide an answer accordingly?
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning nullYes, it still returns null.
Please share your changed code.
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning nullYes, it still returns null.
Please share your changed code.
class Payment extends StatefulWidget {
@override
_PaymentState createState() => _PaymentState();
}
class _PaymentState extends State<Payment> {
List<ApplicationMeta> apps;
void initState() {
super.initState();
getListOfApps();
}
Future<List<ApplicationMeta>> getListOfApps() async {
final applications = await UpiPay.getInstalledUpiApplications();
print(applications);
return applications;
}
@override
Widget build(BuildContext context) {
return Container();
}
}
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning nullYes, it still returns null.
Please share your changed code.
class Payment extends StatefulWidget { @override _PaymentState createState() => _PaymentState(); } class _PaymentState extends State<Payment> { List<ApplicationMeta> apps; void initState() { super.initState(); getListOfApps(); } Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; } @override Widget build(BuildContext context) { return Container(); } }
Thanks! Please share the following:
@joshuajennysibbu For future context, please adhere to the issue template when raising a bug or feature request. It saves us from asking for information in iterative steps.
You are printing the
upiApps
app outside thethen
block. Please look at promises/futures concepts and reopen once you have done the right workflow at your end and still things don't work.
Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; }
Even this is returning nullYes, it still returns null.
Please share your changed code.
class Payment extends StatefulWidget { @override _PaymentState createState() => _PaymentState(); } class _PaymentState extends State<Payment> { List<ApplicationMeta> apps; void initState() { super.initState(); getListOfApps(); } Future<List<ApplicationMeta>> getListOfApps() async { final applications = await UpiPay.getInstalledUpiApplications(); print(applications); return applications; } @override Widget build(BuildContext context) { return Container(); } }
Thanks! Please share the following:
- upi_pay package version used in your pubspec.yaml
- The UPI payment apps installed on your phone, that you have configured with your bank account.
- Your mobile phone OS and version.
@joshuajennysibbu
null
response. This version of upi_pay uses null safety syntax and returns a non-nullable List<ApplicationMeta>
. So I would like to assume that you may be getting an empty list, which probably you are referring to as null
.getInstalledUpiApplications
API to understand why you are not seeing your configured apps. Also see https://github.com/drenther/upi_pay#upi-apps-functional-status-dynamics, and APPS.md
file for more detailed information.Is https://github.com/drenther/upi_pay/issues/38 relevant and important for you?
If yes, could you please respond to my twitter thread with UPI and NPCI handles included in your response asking how these must be solved and how it helps you? https://twitter.com/reeteshr08/status/1488746633068089345
@vaibhavcs99 @joshuajennysibbu
}
] });
getInstalledUpiApplications return null value.