18
votes

I have a Flutter app that is functioning properly in all respects except when I select a TextField (or TextFormField). When I select the TextField, the cursor blinks in the TextField, but I can't type anything AND all other buttons like the floatingActionButton and the back button in the AppBar quit working. Essentially, the app appears to be frozen, but I don't get any error messages.

After numerous attempts to fix the problem in two different pages that contain FocusNodes and TextEditingControllers, I went back to square one by incorporating a new page with code straight from Flutter's website, but the TextField in this barebones code still locks up the app.

import 'package:flutter/material.dart';

class EventDetailForm extends StatefulWidget {
  static const String routeName = "/events/event-detail-form";
  @override
  _EventDetailFormState createState() => _EventDetailFormState();
}

class _EventDetailFormState extends State<EventDetailForm> {
  final myController = TextEditingController();
  @override
  void dispose() {
    myController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Event Detail')),
      body: Padding(
          padding: const EdgeInsets.all(16),
          child: TextField(
            controller: myController,
          )),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          return showDialog(
              context: context,
              builder: (context) {
                return AlertDialog(
                  content: Text(myController.text),
                );
              });
        },
        child: Icon(Icons.text_fields),
      ),
    );
  }
}

Unfortunately, I am not getting any error messages. The cursor just blinks in the TextField and everything else loses function and I have to quit and restart. I am not sure what else I should be considering. Does anyone have any ideas on what might be causing this?

6

6 Answers

11
votes

Simulator -> Device -> Erase All Content And Settings works for me.

8
votes

Had same problem when I upgraded Xcode to ios 13.1. I switched to a different simulator, and the problem went away.

2
votes

This maybe late, but it happened to me too just today. I also changed the channel to beta but unfortunately did not work too. Apparently what worked for me is when I restarted the simulator after I put back the channel to stable.

1
votes

I had the same bug, solved by switching to the beta channel of Flutter. In your terminal use

flutter channel beta
flutter upgrade

About channels you can read here https://github.com/flutter/flutter/wiki/Flutter-build-release-channels

0
votes

I did not change channel, a simple flutter upgrade was enough to fix this problem. I also closed Android Studio and all simulators and when I restarted, the problem was gone.

0
votes

I think I am late to the party but the issue still exists in 2021.

I tried all the solutions but couldn't fix it. Whatever I was typing in TextField or TextFormField or autocomplete_textfield, the characters were not visible.

I fixed it by opening the Widget as a showGeneralDialog() instead of using Navigator.of(...). Here is the sample code.

await showGeneralDialog(
    barrierColor: AppStyle.primaryColor.withOpacity(0.3),
    transitionBuilder: (context, a1, a2, widget) {
      return Transform.scale(
        scale: a1.value,
        child: Opacity(opacity: a1.value, child: WidgetScreenToOpen()),
      );
    },
    transitionDuration: Duration(milliseconds: 500),
    barrierDismissible: true,
    barrierLabel: 'Label',
    context: context,
    pageBuilder: (context, animation1, animation2) {
      return Container();
    }).then((result) {
  return result;
});