IssueRaiser

[RFC] Another take on unified Provider syntax

Hello Riverpod community! I'd like to discuss a second take on the "Simplified Riverpod syntax without code-generation". This is similar to [#4008](https://github.com/rrousselGit/riverpod/issues/4008), but proposes an alternate syntax. Long story short: ## Defining a provider Providers would be defined as plain functions that take a `Ref` argument: ```dart // Equivalent of Provider<Repository> Repository myRepositoryProvider(Ref ref) { return MyRepository(); } // Equivalent of FutureProvider<User> Future<User> fetchUserProvider(Ref ref) { return http.get(...); } // Equivalent of StreamProvider<User> Stream<User> fetchUserProvider(Ref ref) { return firebase.auth... } ``` ## Notifiers There are two possible paths for Notifiers. 1. Stay as similar to today as possible: Use classes Notifiers would instead be classes that extend `Notifier/AsyncNotifier/StreamNotifier`, with an optionally defined constant next to the next ```dart class Counter extends Notifier<int> { // TODO override build as usual } const counterProvider = Counter.new; // Optional class TodoList extends AsyncNotifier<List<Todo>> { // TODO override build as usual } const todoListProvider = TodoList.new; // Optional ``` 2, Fuse providers/notifiers by exposing an `update` method on all providers. We could allow: ```dart int counterProvider(Ref ref) => 0; ... counterProvider.update(ref, (state) => state + 1); ``` > [!NOTE] > For this sake of good coding practices, we'd likely introduce li

Posted by rrousselGit on Apr 29, 2026, 4:08 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.2,000 issues0 comments

github (Software)

[RFC] Another take on unified Provider syntax

rrousselGitApr 29, 2026, 4:08 PM

Hello Riverpod community! I'd like to discuss a second take on the "Simplified Riverpod syntax without code-generation". This is similar to [#4008](https://github.com/rrousselGit/riverpod/issues/4008), but proposes an alternate syntax. Long story short: ## Defining a provider Providers would be defined as plain functions that take a `Ref` argument: ```dart // Equivalent of Provider<Repository> Repository myRepositoryProvider(Ref ref) { return MyRepository(); } // Equivalent of FutureProvider<User> Future<User> fetchUserProvider(Ref ref) { return http.get(...); } // Equivalent of StreamProvider<User> Stream<User> fetchUserProvider(Ref ref) { return firebase.auth... } ``` ## Notifiers There are two possible paths for Notifiers. 1. Stay as similar to today as possible: Use classes Notifiers would instead be classes that extend `Notifier/AsyncNotifier/StreamNotifier`, with an optionally defined constant next to the next ```dart class Counter extends Notifier<int> { // TODO override build as usual } const counterProvider = Counter.new; // Optional class TodoList extends AsyncNotifier<List<Todo>> { // TODO override build as usual } const todoListProvider = TodoList.new; // Optional ``` 2, Fuse providers/notifiers by exposing an `update` method on all providers. We could allow: ```dart int counterProvider(Ref ref) => 0; ... counterProvider.update(ref, (state) => state + 1); ``` > [!NOTE] > For this sake of good coding practices, we'd likely introduce li

Comments (0)

No comments yet. Start the discussion.

Comment on this issue