【问题标题】:Liquid UI Flutter Button getter _theme was called on nullLiquid UI Flutter Button getter _theme 在 null 上被调用
【发布时间】:2021-03-11 09:23:24
【问题描述】:

我是 Flutter 和 Liquid UI 的新手,我正在尝试构建一个表单,但从 Liquid Ui 文档中获取的示例在我的应用程序中失败,特别是无法插入任何按钮,我收到此错误: 构建 LButtonGroup(dirty) 时引发了以下 NoSuchMethodError: 在 null 上调用了 getter '_theme'。 接收方:空 尝试调用:_theme

相关的导致错误的小部件是: LButtonGroup

这是我的代码:

final _manager = LFormManager();
....

LForm(
                manager: _manager,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: <Widget>[
                    LTextFormField(
                      name: "email", 
                      decoration: const InputDecoration(
                        hintText: 'Enter your email',
                      ),
                      initialValue: 'xyz@xyz.com',
                      validators: [
                    LRequiredValidator(),
                    LEmailValidator(
                        invalidMessage: "Please enter correct email address")
                  ], 
                    ),
                    LButtonGroup(
                      children: [
                        LFlatButton.text(
                          text: 'Left',
                          type: LElementType.dark,
                          onPressed: () {},
                        ),
                        LFlatButton.text(
                          text: 'Middle',
                          type: LElementType.dark,
                          onPressed: () {},
                        ),
                        LFlatButton.text(
                          text: 'Right',
                          type: LElementType.dark,
                          onPressed: () {},
                        ),
                      ],
                    )
                  ],
                ),
              )

我做错了什么?

【问题讨论】:

    标签: forms flutter


    【解决方案1】:

    我知道这有点晚了,但我前段时间遇到了这个问题,这就是我的解决方法。

    LiquidApp包裹你的顶级MaterialApp

    import 'package:liquid_ui/liquid_ui.dart';
    void main() async {
    
    runApp(LiquidApp(materialApp: MaterialApp(home: WelcomePage()));
        
    }
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-05-11
      • 2021-08-11
      • 2020-01-08
      • 2021-12-10
      • 2020-03-24
      • 2021-05-25
      • 2023-03-08
      相关资源
      最近更新 更多