我想做一个匀光(乘法)表...并希望从TexteditingController中获取用户的输入,但我无法从文本编辑控制器中获取整数值。期待是否有人会调查它,
TextEditingController num = TextEditingController();
void table() {
print('enter the number $num');
for (var i = 1; i <= 10; i++) {
print('$num*$i = ${num * i}'); //<error>(The operator '*' isn't defined for the type,,'')
}
}
Scaffold(
body: Column(
children: [
TextFormField(
controller: TextEditingController(),
),
Container(
height: 400,
width: 400,
decoration: BoxDecoration(
color: Colors.black,
borderRadius: BorderRadius.circular(20),
),
child: ElevatedButton(
onPressed: table,
child: Text('')),
),
],
));
}
}
1条答案
按热度按时间tzdcorbm1#
该错误源于您直接访问TextEditingController而不是获取它所包含的文本。
正确答案是: