I’ve got this simple Homepage
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Row(
children: [
MyDrawer(),
selectWindow(),
],
),
),
);
}
and
class MyDrawer extends ConsumerStatefulWidget {
MyDrawer({super.key});
@override
ConsumerState createState() {
return _MyDrawerState();
}
}
class _MyDrawerState extends ConsumerState<MyDrawer> {
@override
Widget build(BuildContext context) {
final myProvider = ref.watch(myProviderProvider);
return Drawer(
shape: const ContinuousRectangleBorder(),
width: 300,
child: Text(
myProvider.length.toString(),
style: const TextStyle(fontSize: 24),
),
);
}
my IDE suggests that i use const in these spots
const MyDrawer({super.key});
and
body: Center(
child: Row(
children: [
//HERE
const MyDrawer(),
selectWindow(),
],
),
),
but when I do add the const as suggested the state does not changes when the myProvider.length changes. I have to manually refresh so the length change appears.
Am I doing anything wrong or the IDE suggests something wrong?