I’m trying to fill in sqflite tables using textfields, but it creates a separate table instead of filling in the various fields
class _InputBarState extends State<InputBar> {
final _controller = TextEditingController();
final _controller1 = TextEditingController();
final _controller2 = TextEditingController();
final _focusNode = FocusNode();
String get text => _controller.text.trim();
String get qnt => _controller1.text.trim();
String get um => _controller2.text.trim();
…
TextField(
controller: _controller,
),
TextField(
controller: _controller1,
),
TextField(
controller: _controller2,
),
IconButton(
color: primaryColor,
padding: const EdgeInsets.only(right: 10),
icon: const Icon(Icons.add),
onPressed: text.isEmpty || um.isEmpty || qnt.isEmpty ? null : () => _onSubmitted(text, um, qnt),
),
…
void _onSubmitted(String text, String qnt, String um) {
if (text.isEmpty || qnt.isEmpty || um.isEmpty) return;
widget.onSubmitted(text);
widget.onSubmitted(qnt);
widget.onSubmitted(um);
_controller.clear();
_controller1.clear();
_controller2.clear();
_focusNode.requestFocus();
}
if I fill in the 3 fields with: 1, 2, 3, I have the attached image as output..
instead it should be a single line like: 1 2 3
Text(item.name + item.qnt + item.um ),
help to solve this problem
2
Answers
with your modification I get this error
immage
}
Your provided code is not enough to clarify the problem. It would be great if you can provide code snippet of the
widget.onSubmitted(text)
callback.But assuming you want to store the text, qnt and um value in a single row, you have to change the callback to something like the following instead of calling it individually with text, qnt, um: