获得未来的最后价值

时间:2019-11-04 16:25:46

标签: flutter dart

enter image description here

我正在做一个扑扑的应用程序进行货币兑换,在调用该函数以打印值时,仅获得所有对象的最后一个值

基本上,这只会得到getvalue的最后一个值,并输入所有值。

class BodyWidgetState extends State<BodyWidget> {
  @override

        Widget build(BuildContext context) {
return Scaffold (
    appBar: AppBar(title: Text(moed)),
    body: ListView(
      children: <Widget> [
        ListTile (
          leading: CircleAvatar(
            backgroundImage: AssetImage('assets/mxn.png'),
          ),
          title: Text('MXN'),
        ),
        getValue(moed,'MXN'),
        ListTile(

          leading: CircleAvatar(
            backgroundImage: AssetImage('assets/eur.png'),
          ),
          title: Text('EUR'),
        ),
        getValue(moed,'EUR'),

         Widget getValue (String b, String c){
      return (
     FutureBuilder<Quote> (
      future : getQuote(b,c),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Center(
              child: Column(
                children: <Widget>[
                  SizedBox(height: 10),
              Text(snapshot.data.coin.toString()),
                ],
              ));
        } else if (snapshot.hasError) {
          return Text("${snapshot.error}");
        }
        return CircularProgressIndicator();
      }));}

0 个答案:

没有答案