代码之家  ›  专栏  ›  技术社区  ›  BeniaminoBaggins

颤振反应形式无反应形式方法

  •  0
  • BeniaminoBaggins  · 技术社区  · 4 年前

    我正在尝试禁用中的提交按钮 reactive_forms

    当我执行此代码时:

    import 'package:reactive_forms/reactive_forms.dart';
    final form = ReactiveForm.of(context);
    

    我遇到了这个错误:

    The following NoSuchMethodError was thrown building VpFormElevatedButton(dirty): The getter 'control' was called on null. Receiver: null Tried calling: control
    
    The relevant error-causing widget was VpFormElevatedButton lib/…/logged_out_nickname/logged_out_nick_name_view.dart:68 When the exception was thrown, this was the stack
    #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
    #1      ReactiveForm.of package:reactive_forms/…/widgets/reactive_form.dart:55
    #2      VpFormElevatedButton.build package:vepo/…/buttons/elevated_button_widget.dart:23
    #3      StatelessElement.build package:flutter/…/widgets/framework.dart:4701
    #4      ComponentElement.performRebuild package:flutter/…/widgets/framework.dart:4627 ... ════════════════════════════════════════════════════════════════════════════════
    
    ════════ Exception caught by rendering library ═════════════════════════════════ A RenderFlex overflowed by 99838 pixels on the bottom. The relevant error-causing widget was Column lib/…/logged_out_nickname/logged_out_nick_name_view.dart:65 The specific RenderFlex in question is: RenderFlex#abc1d relayoutBoundary=up1 OVERFLOWING
    

    它认为 ReactiveForm 是一种类型:

    enter image description here

    final form = ReactiveForm.of(context); 是从reactive_forms文档中复制粘贴的。为什么我看到这个运行时异常?

    0 回复  |  直到 4 年前
        1
  •  1
  •   Ferdinand    4 年前

    如果您确定已正确分配变量和 NoSuchMethodError 仍然被扔 getter 'value' was called on null .

    重新启动或重建您的应用程序 热重新加载 不打电话 initState() 这个回调是分配变量的地方,所以试着重建你的应用程序

        2
  •  0
  •   BeniaminoBaggins    4 年前

    我的错。自定义按钮需要位于 ReactiveForm( widget,EG它必须在里面:

    ReactiveForm(
       formGroup: controller.form,
       child: Column(
    

    我的按钮在页面下方,在 重新激活表单( .