我正在 Flutter 中创建和验证一个动态表单,但是当我更改页面并返回到上一页时,出现错误。我该如何解决



它在发布模式下工作,但在调试模式下出现错误

class UrunHizmetWidget extends StatefulWidget {
int index;
final state = _UrunHizmetWidgetState();
UrunHizmetWidget({Key? key, this.index = 0}) : super(key: key);
@override
State<UrunHizmetWidget> createState() => state;
bool isvalid() => state.validator();
}

**错误信息**

The following assertion was thrown building NotificationListener<KeepAliveNotification>:
The createState function for UrunHizmetWidget returned an old or invalid state instance: UrunHizmetWidget, which is not null, violating the contract for createState.
'package:flutter/src/widgets/framework.dart':
package:flutter/…/widgets/framework.dart:1
Failed assertion: line 4860 pos 7: 'state._widget == null'

我希望这能帮助你解决你的问题

class UrunHizmetWidget extends StatefulWidget  {
int index;
var state = _UrunHizmetWidgetState();

UrunHizmetWidget ({Key key, this.site, this.index=0}) : super(key: key);

@override
State<UrunHizmetWidget> createState(){
return this.state=new __UrunHizmetWidgetState();
};

bool isvalid() => state.validator();
}

相关内容

  • 没有找到相关文章

最新更新