useState<T> function
Returns a state object whose .value property is initialized to the
passed argument initialState
.
During subsequent re-renders, the .value property of object will always be the most recent value after applying updates.
Implementation
UseStateHook<T> useState<T>(T initialState) {
var useStateHook = useHook();
useStateHook ??= setupHook(UseStateHook<T>._(initialState));
if (useStateHook is! UseStateHook<T>) {
throw Exception(
'Expecting hook of type: $UseStateHook '
'but got: ${useStateHook.runtimeType}. '
'Please make sure your hooks call order is not dynamic.',
);
}
return useStateHook;
}