I am using flutter_riverpod
package.
I want to convert ConsumerWidget
to ConsumerStatefulWidget
.
However, it took me a lot of time to do it like this:
class Widget extends ConsumerWidget {
const Widget({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
return …;
}
}
ref
)class Widget extends ConsumerWidget {
const Widget({super.key});
@override
Widget build(BuildContext context) {
return …;
}
}
ConsumerWidget
to StatelessWidget
)class Widget extends StatelessWidget {
const Widget({super.key});
@override
Widget build(BuildContext context) {
return …;
}
}
Convert to StatefulWidget
action)class Widget extends StatefulWidget {
const Widget({super.key});
@override
State<Widget> createState() => _WidgetState();
}
class _WidgetState extends State<Widget> {
@override
Widget build(BuildContext context) {
return …;
}
}
Consumer
word)class Widget extends ConsumerStatefulWidget {
const Widget({super.key});
@override
ConsumerState<Widget> createState() => _WidgetState();
}
class _WidgetState extends ConsumerState<Widget> {
@override
Widget build(BuildContext context) {
return …;
}
}
As you can see, I need to use 5 steps to do it. Is there a faster way?
Feel free to leave a comment if you need more information.
How to convert ConsumerWidget
to ConsumerStatefulWidget
more easily? I would appreciate any help. Thank you in advance!
Please consider using riverpod_lint package for your Riverpod projects. It auto converts your StatelessWidget to ConsumerWidget, etc. Also Riverpod extension for VSCode should be installed in your editor.