It works in release mode but I get an error in debug mode
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();
}
**Error Message **
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'
CodePudding user response:
I hope this could help you to solve your problem
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();
}