简体   繁体   English

飞镖,颤抖-未显示ListView

[英]dart, flutter - ListView not showing

I'm trying to show a ListView but it's not appearing, below is the full code(open the screen with material page route): 我正在尝试显示一个ListView,但它没有出现,下面是完整的代码(打开包含材料页面路线的屏幕):

pvc_screen.dart: pvc_screen.dart:

import 'package:flutter/material.dart';

class PVCScreen extends StatefulWidget {
  @override
  _PVCScreenState createState() => _PVCScreenState();
}

class _PVCScreenState extends State<PVCScreen> {
  List<String> currencyPairs = ['EUR/USD', 'GBP/USD', 'USD/JPY'];
  List<String> currencies = ['USD', 'GBP', 'JPY'];

  String currencyPair = 'EUR/USD';
  String askPrice = '';
  String units = '';
  String accountCurrency = 'USD';
  String result = '';

  double dots;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Pip Value Calculator'),
      ),
      body: ListView(children: <Widget>[
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
            title: new Text('Currency Pair'),
            subtitle: DropdownButton(
              value: currencyPair,
              items: <DropdownMenuItem<String>>[
                DropdownMenuItem(
                  value: currencyPairs[0],
                  child: new Text('${currencyPairs[0]}'),
                ),
                DropdownMenuItem(
                  value: currencyPairs[1],
                  child: new Text('${currencyPairs[1]}'),
                ),
                DropdownMenuItem(
                  value: currencyPairs[2],
                  child: new Text('${currencyPairs[2]}'),
                ),
              ],
              onChanged: (String value) {
                setState(() {
                  currencyPair = value;
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
              title: new Text('Ask Price'),
              subtitle: new TextField(
                controller: TextEditingController(text: '$askPrice'),
                decoration: InputDecoration(hintText: '0'),
                onChanged: (String text) {
                  setState(() {
                    askPrice = text;
                  });
                },
              )),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
              title: new Text('Position Size (units)'),
              subtitle: new TextField(
                controller: TextEditingController(text: '$units'),
                decoration: InputDecoration(hintText: '0'),
                onChanged: (String text) {
                  setState(() {
                    units = text;
                  });
                },
              )),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: ListTile(
            title: new Text('Account Currency'),
            subtitle: DropdownButton(
              value: accountCurrency,
              items: <DropdownMenuItem<String>>[
                DropdownMenuItem(
                  value: currencies[0],
                  child: new Text('${currencies[0]}'),
                ),
                DropdownMenuItem(
                  value: currencies[1],
                  child: new Text('${currencies[1]}'),
                ),
                DropdownMenuItem(
                  value: currencies[2],
                  child: new Text('${currencies[2]}'),
                ),
              ],
              onChanged: (String value) {
                setState(() {
                  accountCurrency = value;
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: Center(
            child: MaterialButton(
              child: new Text('Calculate'),
              onPressed: () {
                setState(() {
                  dots = currencyPair.split('/')[1] == 'JPY' ? 0.01 : 0.0001;

                  result = (dots.toInt() / int.parse('$askPrice')).toString();
                });
              },
            ),
          ),
        ),
        Padding(
          padding: const EdgeInsets.all(10.0),
          child: Center(
              child: new Text(
            '\$$result',
            style: TextStyle(fontSize: 24.0),
          )),
        ),
      ]),
    );
  }
}

All the code looks valid in my eyes. 在我看来,所有代码都有效。 code is simple PVCScreen is a StatefulWidget. 代码很简单PVCScreen是一个StatefulWidget。 under it's Build override, there is Scaffold which have AppBar and body, body has a ListView with different item ListTiles, now the problem is AppBar is showing(appearing) but body (ListView) is not showing (hidden). 在其Build覆盖下,有一个拥有AppBar和body的Scaffold,body具有一个具有不同ListTiles项的ListView,现在的问题是AppBar正在显示(显示),但是主体(ListView)没有显示(隐藏)。 i want both AppBar and ListView to be visible. 我希望AppBar和ListView都可见。

You can't use a TextField as a subtitle in ListTile (with the present implementation). 您不能将TextField用作ListTile中的字幕(使用本实现)。

Issue is Already Open on github: https://github.com/flutter/flutter/issues/18755 问题已在github上公开: https : //github.com/flutter/flutter/issues/18755

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM