I was trying to add different useState in my page with Flutter hook but i can't find a way to do it by giving them a type first, because of the inital value requested.
i can't initialize my useState with :
QRViewController? controller = useState();
or
final controller = useState<QRViewController>()
or
QRViewController? controller = useState(null);
How can i initialized controller with custom type ?
CodePudding user response:
final ValueNotifier<QRViewController?> controller = useState(null);
Or
final controller = useState<QRViewController?>(null);
You were very close.