fix: Wrapping a const widget with a bloc builder
duck-dev-go opened this issue · comments
Anonymous Dev commented
Description
The bloc vscode extension seems to have a problem. Wrapping a const widget with a bloc builder will move the const to the bloc builder
Steps To Reproduce
Take the following widget
class BalanceWidget extends StatelessWidget {
const BalanceWidget({super.key});
@override
Widget build(BuildContext context) {
return const Text('1000');
}
}
And wrap it with a bloc builder and you get
class BalanceWidget extends StatelessWidget {
const BalanceWidget({super.key});
@override
Widget build(BuildContext context) {
return const BlocBuilder<BalanceCubit, BalanceState>(
builder: (context, state) {
return Text('1000');
},
);
}
}
Which give the following error
Invalid constant value.dart(invalid_constant)
Expected Behavior
I expedited the following
class BalanceWidget extends StatelessWidget {
const BalanceWidget({super.key});
@override
Widget build(BuildContext context) {
return BlocBuilder<BalanceCubit, BalanceState>(
builder: (context, state) {
return const Text('1000');
},
);
}
}