未定义命名参数“ child”。尝试将名称更正为现有命名参数的名称

Chimitaed

我有一个简单的对话框窗口小部件,它在Beta通道上的Windows上没有错误的情况下也能正常工作,但是当我在MacBook上拉同一个存储库时,会出现错误。两种环境都在Beta频道上

未定义命名参数“ child”。尝试将名称更正为现有命名参数的名称,或定义名称为'child'的命名参数

我的对话。是什么导致孩子抱怨child: new AlertDialog(

void _showDialog(
      BuildContext context, QRViewController controller, String result) async {
    await showDialog<String>(
      context: context,
      // FIXME: child isn't defined for this function. need to use right params
        child: new AlertDialog(
        contentPadding: const EdgeInsets.all(16.0),
        content: Container(
          height: 400,
          child: Column(
            children: [
              new Row(
                children: [
                  Text(
                    'Please record your body temperature \nin Celsius from the digital reading \non the infrared thermometer',
                  ),
                ],
              ),
              new Row(
                children: <Widget>[
                  new Expanded(
                    child: new TextField(
                      autofocus: true,
                      onChanged: (value) {
                        temp = value;
                      },
                      decoration: new InputDecoration(hintText: 'C'),
                      keyboardType: TextInputType.number,
                      inputFormatters: <TextInputFormatter>[
                        FilteringTextInputFormatter.allow(
                            RegExp(r'^\d+\.?\d*')),
                      ],
                    ),
                  )
                ],
              ),
              Row(
                children: [
                  Padding(
                    padding: const EdgeInsets.all(8.0),
                    child: Image.asset("assets/images/temp_checkin.jpg",
                        height: 250, fit: BoxFit.scaleDown),
                  ),
                ],
              )
            ],
          ),
        ),
        actions: <Widget>[
          new FlatButton(
              child: const Text('CANCEL'),
              onPressed: () {
                _QRViewExampleState.capturedQRCode = false;
                Navigator.pop(context);
              }),
          new FlatButton(
              child: const Text('SUBMIT'),
              onPressed: () {
                Navigator.pop(context);
                if (temp != '' && temp != null) {
                  _temperatureCheckIn(result, temp, context);
                }
                _QRViewExampleState.capturedQRCode = false;
              })
        ],
      ),
    );
  }
提尔·帕特尔

child不推荐使用。您应该builder改用。showDialog文档中已提及

void _showDialog(BuildContext context, QRViewController controller, String result) async {
    await showDialog(
        context: context,
        builder: (context) {
            return AlertDialog();
        },
    );
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在尝试导入类模型的 Fultter 中出现错误“尝试将名称更正为现有命名参数的名称”

未定义的名称“存储”。尝试将名称更正为已定义的名称,或定义名称

尝试导入定义“value”的库,将名称更正为现有 setter 的名称,或定义名为“value”的 setter 或字段

AnimationController未定义命名参数“ vsync”

未定义命名参数'colors'。

未定义命名参数“textStyle”

未定义命名参数“ child”。在Center()构造函数中

Flutter在SweepGradient中未定义命名参数“ colors”

错误:使用ListView时未定义命名参数'children'

Firebase 远程配置:未定义命名参数“到期”

Flutter:未定义具有命名参数“ enabled”的AlertDialog和TextButton

没有 pull_to_refresh 的“未定义命名参数 keyboardDismissBehavior”

Flutter:我正在尝试使用扩展类包装Text小部件,但出现“未定义命名参数'child'的错误”

NameError: 名称“参数”未定义

Javascript:参数未定义?

未定义Javascript参数

变量/参数未定义

可选参数未定义

颤振复制错误:未定义命名参数“id” undefined_named_parameter

未定义命名参数。Flutter 项目因升级版本出错

未定义命名空间前缀android

C++ 未定义的命名空间

命名未定义的变量数

参数编号无效:参数未定义

参数编号无效:参数未定义

有没有办法防止在我的命名参数构造函数中传递未定义?

每当我写“样式”时,我都会收到一个错误命名参数未定义

使用jq将名称/值对的数组转换为具有命名键的对象

Axios路由,未定义的可选参数