【问题标题】:'Missing Focus scope.' Using input text“缺少焦点范围。”使用输入文本
【发布时间】:2017-08-02 20:32:42
【问题描述】:

我尝试使用 Flutter 构建一个表单,我有自己的 StatefulWidget,它返回一个带有 2 个输入的表单(我也尝试使用 TextField)和一个 DropdownButton。

当我执行第二个输入时显示此错误:'缺少焦点范围。'

代码:

import 'package:flutter/material.dart';

class ContactFormView extends StatefulWidget {

  @override
  CreateFormViewState createState() => new CreateFormViewState();

}

class CreateFormViewState extends State<ContactFormView> {

  GlobalKey<FormState> _formKey = new GlobalKey<FormState>();

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      body: new Form(
          key: _formKey,
          child: new Column(
              children: <Widget>[
                new Input(
                    labelText: 'First Name',
                    onChanged: (InputValue value) {
                      // Logic here
                    }
                ),
                new Input(
                    labelText: 'Last Name',
                    onChanged: (InputValue value) {
                      // Logic here
                    }
                ),
                new RaisedButton(
                    child: new Text('SUBMIT'),
                    onPressed: () {
                      // Logic here
                    },
                )
              ]
          )
      )
    );
  }

}

【问题讨论】:

  • 嗨!你能添加一些来源吗?这可能会帮助我们帮助您。谢谢!
  • 哦,是的,没问题
  • 用最新的 Flutter 版本做了测试(Framework revision 9adf1bf1b6 (3 hours ago), 2017-03-22 10:38:00, Engine revision 6b9eda4a40)。无法使用上述代码重现该行为。

标签: dart flutter


【解决方案1】:

最后,问题在下次更新时得到解决。现在,您可以毫无问题地使用此小部件。 https://docs.flutter.io/flutter/widgets/Form-class.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-22
    • 2021-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多