rafaelcb21 rafaelcb21 - 28 days ago 5
Dart Question

Flutter - Keyboard does not appear and does not stay under the chosen field

Keyboard is not working properly with

TextField
.

The code below I put 14
TextField
, but when clicking for example in field 14 the keyboard does not appear and it is not below the
TextField
tapped.

Could you help me with this keyboard problem not showing up and not getting me under the chosen field to be?

enter image description here

import 'package:flutter/material.dart';

void main() {
runApp(new MaterialApp(home: new HomePage()));
}

class HomePage extends StatefulWidget {
@override
HomePageState createState() => new HomePageState();
}

class HomePageState extends State<HomePage> {
final TextEditingController _controller = new TextEditingController();

@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Stack(
children: <Widget>[
new ListView(
shrinkWrap: true,
children: <Widget>[
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 1',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 2',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 3',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 4',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 5',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 6',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 7',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 8',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 9',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 10',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 11',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 12',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 13',
),
),
new TextField(
controller: _controller,
decoration: new InputDecoration(
hintText: 'Type something 14',
),
),
],
)
]
)
);
}
}

Answer Source

You should not have all your text fields sharing the same TextEditingController. Use a separate controller for each one.