Are there any problems with this use of a Provider instead of a StatefulWidget?

60 Views Asked by At
class Example extends StatelessWidget {
  final List<Widget> children;

  const Example({super.key, required this.children});

  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider<ScrollController>(
      create: (_) => ScrollController(),
      child: ListView(
        controller: context.read<ScrollController>(),
        children: children,
      ),
    );
  }
}

Same with the TextEditingController.

This approach seems more concise to me, but some of my colleagues do not share my views.

0

There are 0 best solutions below