'Flutter: How to rebuild using Riverpod within showModalBottomSheet

@override
  Widget build(BuildContext context, WidgetRef ref) {
    final provider = counterNotifierProviders(Counter.initialize());
    final counter = ref.watch(provider);
  
  return Scaffold(
    body: ElevatedButton(
      onPressed: () => showModalBottomSheet<void>(
        context: context,
          builder: (context) {
            return Column(
              children: [
                Text(counter.count),
                TextButton(child: 'Add' onPressed: () => ref.read(provider.notifier).add()),
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Text(counter.count) is not updated. But, I know counter.count was updating from log.

How I can resolve that problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source