Skip to content

Make update() methods take a non-nullable previous #865

Description

@aran

Is your feature request related to a problem? Please describe.

The problem to be solved is that update() methods can't depend on create() having been called, so they have to duplicate code snippets with create. For example:

ChangeNotifierProxyProvider<Input, Output>(
                          create: (context) => Output(...output's parameters...)
                          update: (context, Input input, Output? previous) {
                            previous ??= Output(...output's parameters again...);
                            return previous..updateWithInput(input);
                          }),

Describe the solution you'd like
Make previous non-nullable throughout the API and internally guarantee that create() (or .value or whatever) is called first.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions