skip to Main Content

I have been working on a Flutter project for my college work. In my project there is a create project page, where the user is supposed to enter some details including the project name to proceed with the creation. But whenever I try to enter some text using a TextField, the application takes me back to the home screen. Please see the following demonstration for reference

Demonstration

Container(
                margin: EdgeInsets.only(
                  left: 24 / 360 * ScreenConstants.screenWidth,
                  top: 25 / 360 * ScreenConstants.screenWidth,
                ),
                alignment: Alignment.centerLeft,
                child: Text(
                  "Project Name",
                  style: Theme.of(context).textTheme.titleMedium,
                  textAlign: TextAlign.left,
                ),
              ),
              InkWell(
                onTap: () {
                  _projectNameFocusNode.requestFocus();
                },
                child: TextFormField(
                  focusNode: _projectNameFocusNode,
                  controller: _projectNameController,
                  // Rest of your TextFormField configuration
                ),
              )
            ],

This is the code in question. I have tried using InkWell as above, GestureDetector, and TextField by itself. But whatever I do, the error keeps repeating itself.

Can you guys help me figure out what’s going on here? Thanks a lot!

[Edit 1] This is the logs I get as the control flows outside the page

I/ImeTracker( 9719): com.example.kaptur_alpha_v1:31b874ef: onRequestShow at ORIGIN_CLIENT_SHOW_SOFT_INPUT reason SHOW_SOFT_INPUT
D/InputMethodManager( 9719): showSoftInput() view=io.flutter.embedding.android.FlutterView{a6c6e42 VFE...... .F...... 0,0-1080,2154 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
D/InsetsController( 9719): show(ime(), fromIme=true)
D/EGL_emulation( 9719): app_time_stats: avg=42.17ms min=29.73ms max=57.70ms count=24
D/EGL_emulation( 9719): app_time_stats: avg=468.49ms min=1.20ms max=13982.47ms count=30

2

Answers


  1. Try removing the Inkwell widget. You don’t have to request focus when you tap on a textfield. When you tap on a texfield, the focus of the textfield is automatically focused.
    Maybe that is causing the error

    Login or Signup to reply.
  2. I was facing a similar issue then I checked Flutter Inspector and saw that I was accidentally pushing the previous page over and over again, which makes you think that the current page is popping. I suggest you to check your navigation stack for a similar bug.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search