引发了另一个异常:执行平台检查Flutter网站时,'ErrorSummary'的实例

问题描述 投票:1回答:1

我有底部导航栏,可在两个屏幕BookingsScreenOpeningTimesScreen之间切换。我的问题是OpeningTimesScreen UI第一次无法正确加载。如果再次点击其图标,或者如果我先选择BookingsScreen,然后再选择它,它确实会加载。由于完整的UI包含28个文本字段和14个开关,因此我只是将其缩减为仅一个文本字段并进行了一些测试。似乎问题出在三元内部声明的文本字段,我在应用程序在Web和平板电脑上运行时要做的事情。

如果我将文本字段声明为Column的直接子UI正确构建。

TextField(
                keyboardType: TextInputType.numberWithOptions(),
                controller: monMorOp,
                onChanged: (value) {
                  monMorOp.text = validateTimeFormat(value);
                },
              ),

如果我在扩展的小部件UI中声明它,仍会正确构建。

Expanded(
                flex: 1,
                child: TextField(
                  keyboardType: TextInputType.numberWithOptions(),
                  controller: monMorOp,
                  onChanged: (value) {
                    monMorOp.text = validateTimeFormat(value);
                  },
                ),
              ),

如果我在没有签入的情况下声明它,则平台UI仍可正确构建。

Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  mainAxisSize: MainAxisSize.max,
                  //title row
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Monday'),
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: TextField(
                        keyboardType: TextInputType.numberWithOptions(),
                        controller: monMorOp,
                        onChanged: (value) {
                          monMorOp.text = validateTimeFormat(value);
                        },
                      ),
                    ),
                  ],
                ),
              ),

[当我执行平台检查时,仅在第一次加载时出现错误和灰屏。一旦再次点击BottomNavigationBar图标,它就会很好地加载。

Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  mainAxisSize: MainAxisSize.max,
                  //title row
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Monday'),
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: Platform.isIOS
                          ? CupertinoTextField(
                              keyboardType: TextInputType.numberWithOptions(),
                              controller: monMorOp,
                              onChanged: (value) {
                                monMorOp.text = validateTimeFormat(value);
                              },
                            )
                          : TextField(
                              keyboardType: TextInputType.numberWithOptions(),
                              controller: monMorOp,
                              onChanged: (value) {
                                monMorOp.text = validateTimeFormat(value);
                              },
                            ),
                    ),

在Chrome控制台中,我看到Another exception was thrown: Instance of 'ErrorSummary'js_primitives.dart:47链接。

单击它会打开一个带有此选项卡的标签:

Could not load content for org-dartlang-sdk:///lib/_internal/js_runtime/lib/js_primitives.dart (HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)

..应用启动时我也遇到另一个错误,我不知道它们是否相关。]

favicon.ico:1 GET http://localhost:5000/favicon.ico 404 (Not Found)

我可以检查什么原因?一如既往,非常感谢您的时间和帮助。

我也把整个课程都放了:

class OpeningTimesScreen extends StatefulWidget {
  final FixitUser user;
  final LatLng coordinates;
  final String cityDb;
  final String regionDb;
  final String countryDb;
  const OpeningTimesScreen(
      {Key key,
      @required this.user,
      @required this.coordinates,
      @required this.cityDb,
      @required this.regionDb,
      @required this.countryDb})
      : super(key: key);

  @override
  _OpeningTimesScreenState createState() => _OpeningTimesScreenState();
}

// TODO expanded causes error : Another exception was thrown: Instance of 'ErrorSummary'
class _OpeningTimesScreenState extends State<OpeningTimesScreen> {
  TextEditingController monMorOp = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return BlocProvider<OpeningTimesBloc>(
      lazy: false,
      create: (BuildContext context) =>
          OpeningTimesBloc()..add(LoadOpeningTimes(widget.user)),
      child: BlocConsumer<OpeningTimesBloc, OpeningTimesState>(
        listener: (BuildContext context, OpeningTimesState state) {},
        builder: (context, state) => Container(
          color: Colors.black54,
          padding: EdgeInsets.symmetric(horizontal: 100, vertical: 50),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.stretch,
            children: <Widget>[
              //                                                              TODO titles
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  mainAxisSize: MainAxisSize.max,
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Text(
                        '',
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Opening'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Closing'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 1,
                      child: Text(
                        AppLocalizations.instance.text('Active'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 40,
                    ),
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Opening'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Closing'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 1,
                      child: Text(
                        AppLocalizations.instance.text('Active'),
                        textAlign: TextAlign.center,
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                  ],
                ),
              ),

              // TODO UI builds without a problem
//              TextField(
//                keyboardType: TextInputType.numberWithOptions(),
//                controller: monMorOp,
//                onChanged: (value) {
//                  monMorOp.text = validateTimeFormat(value);
//                },
//              ),

              // TODO UI builds without a problem
//              Expanded(
//                flex: 1,
//                child: TextField(
//                  keyboardType: TextInputType.numberWithOptions(),
//                  controller: monMorOp,
//                  onChanged: (value) {
//                    monMorOp.text = validateTimeFormat(value);
//                  },
//                ),
//              ),
              // TODO UI builds without a problem
              //                                                              TODO monday
//              Expanded(
//                flex: 1,
//                child: Row(
//                  mainAxisAlignment: MainAxisAlignment.center,
//                  mainAxisSize: MainAxisSize.max,
//                  //title row
//                  children: <Widget>[
//                    Expanded(
//                      flex: 2,
//                      child: Text(
//                        AppLocalizations.instance.text('Monday'),
//                        style: TextStyle(color: Colors.white, fontSize: 20),
//                      ),
//                    ),
//                    SizedBox(
//                      width: 20,
//                    ),
//                    Expanded(
//                      flex: 2,
//                      child: TextField(
//                        keyboardType: TextInputType.numberWithOptions(),
//                        controller: monMorOp,
//                        onChanged: (value) {
//                          monMorOp.text = validateTimeFormat(value);
//                        },
//                      ),
//                    ),
//                  ],
//                ),
//              ),

              // TODO UI build problem
              //                                                              TODO monday
              Expanded(
                flex: 1,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  mainAxisSize: MainAxisSize.max,
                  //title row
                  children: <Widget>[
                    Expanded(
                      flex: 2,
                      child: Text(
                        AppLocalizations.instance.text('Monday'),
                        style: TextStyle(color: Colors.white, fontSize: 20),
                      ),
                    ),
                    SizedBox(
                      width: 20,
                    ),
                    Expanded(
                      flex: 2,
                      child: Platform.isIOS
                          ? CupertinoTextField(
                              keyboardType: TextInputType.numberWithOptions(),
                              controller: monMorOp,
                              onChanged: (value) {
                                monMorOp.text = validateTimeFormat(value);
                              },
                            )
                          : TextField(
                              keyboardType: TextInputType.numberWithOptions(),
                              controller: monMorOp,
                              onChanged: (value) {
                                monMorOp.text = validateTimeFormat(value);
                              },
                            ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
    

我有底部导航栏,可在两个屏幕BookingsScreen和OpeningTimesScreen之间切换。我的问题是,OpeningTimesScreen UI第一次无法正确加载。如果点击...,它会加载...

flutter-web
1个回答
0
投票

发现问题。

© www.soinside.com 2019 - 2024. All rights reserved.