-5
List<ApplicationMeta> apps = [];
@override
void initState() {
 UpiPay.getInstalledUpiApplications().then((value) {
  setState(() {
    this.apps = value;
    print('successfully append');
  });
}).catchError((e) {
  print('im in error part');
});
super.initState();
}

这个程序是关于 getupiapplications 的。getInstalledUpiApplications() 函数返回“列表”,但我已转换为 ApplicationMeta。我有错误。

4

2 回答 2

0

感谢您的回复它的工作,但我面临另一个问题。我得到空值。这是我的代码

import 'package:flutter/material.dart';
import 'package:upi_pay/upi_pay.dart';

class Homes extends StatefulWidget {
 @override
 _HomesState createState() => _HomesState();
 }

  class _HomesState extends State<Homes> {
    List<ApplicationMeta> apps = [];

 @override
 void initState() {
   super.initState();
   UpiPay.getInstalledUpiApplications().then((value) {
   setState(() {
    this.apps = value;
    print('completed');
    });
    });
   }


  Widget cons() {
   return Container(
  color: Colors.black,
  child: Stack(children: [
    ListView.builder(
        itemCount: apps.length,
        itemBuilder: (buildContext, int i) {
          print(apps[i]);
          return apps[i].iconImage(48);
        })
     ]),
     );
    }

 @override
  Widget build(BuildContext context) {
  return cons();
  }
  }
于 2021-06-16T07:36:21.257 回答
0
apps.forEach((app) => {
//do whatever with app
print(app.name); //or whatever
})

在上面的代码中, forEachapp的类型ApplicationMeta会让你遍历appList中的每一个apps。您的问题不清楚,但似乎您想遍历.List

于 2021-06-16T05:51:47.663 回答