I created a simple page for a user to update their display name if they don't have one, but for some reason when I click to enter the input data, the keyboard appears and disappears and the page freaks out a bit. I included a gif.
I've used this same code before for email and password inputs. Not sure why it's strange now. Here is my code for the page:
`class AddName extends StatefulWidget {
const AddName({super.key});
@override
State<AddName> createState() => _AddNameState();
}
class _AddNameState extends State<AddName> {
final TextEditingController _firstNameController = TextEditingController();
final TextEditingController _lastNameController = TextEditingController();
final user = FirebaseAuth.instance.currentUser;
final userDoc = FirebaseFirestore.instance.collection('users').doc();
@override
Widget build(BuildContext context) {
return Scaffold(
body: SizedBox(
height: MediaQuery.of(context).size.height,
child: SingleChildScrollView(
child: Column(
children: [
const SizedBox(height: 100),
const Text(
'Please enter your name',
style: TextStyle(
color: Colors.white,
fontSize: 30,
fontWeight: FontWeight.bold,
),
),
const SizedBox(
height: 20,
),
const Text('You must enter your name to use the app'),
const SizedBox(height: 80),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: TextField(
controller: _firstNameController,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
hintText: 'Enter your first name',
hintStyle: TextStyle(color: Colors.white),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
),
),
),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: TextField(
controller: _lastNameController,
style: const TextStyle(color: Colors.white),
decoration: const InputDecoration(
hintText: 'Enter your last name',
hintStyle: TextStyle(color: Colors.white),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white),
),
),
),
),
const SizedBox(height: 100),
ElevatedButton(
onPressed: () async {
userDoc.set({
'displayName':
_firstNameController.text + _lastNameController.text,
});
// Navigator.of(context).pop();
},
child: const Text('Submit'),
),
],
))),
);
}
}
`
My emulator has been strange lately, too. Not sure if that's part of the problem.