18

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?

xdevco
  • 181
  • 1
  • 6

6 Answers6

12

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

Sait Banazili
  • 1,263
  • 2
  • 12
  • 27
8

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

Kevin
  • 1,883
  • 16
  • 23
  • Thanks for the additional input. I used awaik's solution of switching to the beta channel and it worked. I then went to work on stuff elsewhere in my app. When I came back to the form 10 days later, my problem was back. I switched to another simulator and that fixed the problem this time. I upvoted both answers b/c they both worked... unfortunately, I am a newbie and my votes don't count yet. – xdevco Oct 18 '19 at 12:10
  • 1
    Closing the simulator and reopening it (the same one) also solves the issue for me. It seems to happen when I keep the simulator open for days, like 3 or 4 days. – ncuillery Jun 25 '20 at 19:31
2

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

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

awaik
  • 10,143
  • 2
  • 44
  • 50
  • I am not sure how you ever figured that out, but it solved my problem. Thank you!! – xdevco Oct 08 '19 at 03:23
  • Welcome :) It was easy - my app was worked perfect and after I updated have broken. So, the reason was in Flutter engine itself. In this case we can downgrade version or try out beta channel, on which, likely, developers already fixed that bug. – awaik Oct 08 '19 at 17:57
  • switched to beta but the problem is still there :/ – kashlo Dec 06 '19 at 23:36
  • Can you make flutter doctor -v and check Flutter version please? In new versions it should work even on stable Channel. – awaik Dec 07 '19 at 03:40
0

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.

GraSim
  • 3,830
  • 1
  • 29
  • 35
0

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;
});
zackygaurav
  • 4,369
  • 5
  • 26
  • 40