You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I comment out the first hook, dispose prints exactly the last hook,
Is the logic correct here, or is there something wrong with the way I defined hook
To Reproduce
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
void main() {
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends HookWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
// final one = useDemo(1);
final two = useDemo(2);
final three = useDemo(3);
return const Scaffold(
body: Center(
child: Text('Hello World!'),
),
);
}
}
T useDemo<T>(T value) {
return use(_DemoHook(value));
}
class _DemoHook<T> extends Hook<T> {
const _DemoHook(this.value);
final T value;
@override
_DemoHookState<T> createState() => _DemoHookState();
}
class _DemoHookState<T> extends HookState<T, _DemoHook<T>> {
late T value = hook.value;
@override
void initHook() {
super.initHook();
print('initHook');
print('$value');
}
@override
T build(BuildContext context) => value;
@override
void dispose() {
print('dispose');
print('$value');
super.dispose();
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
When I comment out the first hook, dispose prints exactly the last hook,
Is the logic correct here, or is there something wrong with the way I defined hook
To Reproduce
The text was updated successfully, but these errors were encountered: