'Use Type with Flutter Hooks
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 ?
Solution 1:[1]
final ValueNotifier<QRViewController?> controller = useState(null);
Or
final controller = useState<QRViewController?>(null);
You were very close.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Jacobs |
