Нажатие на TextField в alertDialog приводит к сбою моего приложения

Я пытаюсь показать TextField в AlertDialog, но мое приложение вылетает, когда я пытаюсь нажать на TextField.

Вот мой код:

        Future<void> _showDialog(BuildContext context) async {
    return showDialog<void>(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: const Text('AlertDialog Title'),
          content: Directionality(
            textDirection: TextDirection.rtl,
            child: Obx(
              () => SingleChildScrollView(
                child: ListBody(
                  children: <Widget>[
                    buildRateRow(
                        label: 'punctuality',
                        dropDownValue: controller.punctualityDDValue),
                    TextField(
                      controller: controller.reviewController..text = 'hello',
                      autofocus: false,
                      maxLength: 255,
                      decoration: new InputDecoration(hintText: ' ... '),
                    ),
                  ],
                ),
              ),
            ),
          ),
          actions: <Widget>[
            ElevatedButton(
              child: const Text('rate'),
              onPressed: () {
                controller.subRateTeacher(
                    teacherId: '${controller.teacher.value.id!}');
                Navigator.of(context).pop();
              },
            ),
            TextButton(
              child: const Text('cancel'),
              onPressed: () {
                Navigator.of(context).pop();
              },
            ),
          ],
        );
      },
    );
  }

выпадающий список работает без проблем. также, когда я нажимаю кнопку, я получаю текст в TextField.

Сообщение об ошибке

  • W/IInputConnectionWrapper (7294): getExtractedText для неактивного InputConnection

  • W/IInputConnectionWrapper (7294): getTextBeforeCursor для неактивного InputConnection

  • W/IInputConnectionWrapper (7294): getExtractedText для неактивного InputConnection

  • W/IInputConnectionWrapper (7294): getTextBeforeCursor для неактивного InputConnection

  • E/SpannableStringBuilder(7294): диапазоны SPAN_EXCLUSIVE_EXCLUSIVE не могут иметь нулевую длину

  • I/chatty ( 7294): uid=10582(com.example.blog) идентичные 2 строки

  • E/SpannableStringBuilder(7294): диапазоны SPAN_EXCLUSIVE_EXCLUSIVE не могут иметь нулевую длину

  • D/ForceDarkHelper (7294):updateByCheckExcludeList: pkg: com.example.blog активность: com.example.blog.MainActivity@10f2b63

  • D/EgretLoader(7294): EgretLoader(контекстный контекст)

  • D/EgretLoader(7294): контекст не является активностью

  • D/ForceDarkHelper (7294):updateByCheckExcludeList: pkg: com.example.blog активность: com.example.blog.MainActivity@10f2b63

  • D/AndroidRuntime (7294): завершение работы виртуальной машины

  • E/AndroidRuntime (7294): НЕИСПРАВНОЕ ИСКЛЮЧЕНИЕ: основной

  • E/AndroidRuntime (7294): Процесс: com.example.blog, PID: 7294

  • E/AndroidRuntime (7294): java.lang.NullPointerException: попытка чтения из поля «android.view.WindowManager$LayoutParamsandroid.view.ViewRootImpl.mWindowAttributes» по ссылке на нулевой объект

  • E/AndroidRuntime (7294): в android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:1626)

  • E/AndroidRuntime (7294): в android.view.inputmethod.InputMethodManager.checkFocus(InputMethodManager.java:1870)

  • E/AndroidRuntime (7294): в android.view.inputmethod.InputMethodManager.isActive(InputMethodManager.java:1184)

  • E/AndroidRuntime (7294): в io.flutter.plugins.webviewflutter.InputAwareWebView$1.run(InputAwareWebView.java:195)

  • E/AndroidRuntime(7294): в android.os.Handler.handleCallback(Handler.java:914) E/AndroidRuntime(7294): в android.os.Handler.dispatchMessage(Handler.java:100)

  • E/AndroidRuntime (7294): в android.os.Looper.loop(Looper.java:225)

  • E/AndroidRuntime (7294): в android.app.ActivityThread.main(ActivityThread.java:7564)

  • E/AndroidRuntime (7294): в java.lang.reflect.Method.invoke (собственный метод)

  • E/AndroidRuntime (7294): в com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)

  • E/AndroidRuntime (7294): в com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)

  • D/OOMEventManagerFK (7294): checkEventAndDumpForJE: 0

  • I/Process (7294): Отправка сигнала. PID: 7294 SIG: 9

    Потеряно соединение с устройством.

0 ответов

Другие вопросы по тегам