I'm trying to show a ListView but it's not appearing, below is the full code(open the screen with material page route):
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. 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). i want both AppBar and ListView to be visible.
You can't use a TextField as a subtitle in ListTile (with the present implementation).
Issue is Already Open on github: https://github.com/flutter/flutter/issues/18755
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.