Skip to content

The Map.update() method

A common requirement when working with maps is to:

  • Update the value if a given key already exists
  • Set the value if it doesn’t

You may be tempted to implement some conditional logic to handle this.

But the update() method offers a simpler way of doing the same thing: 👇

Previous Next
AsyncValue.guard() vs try/catch Riverpod: difference between ref.watch, ref.read, ref.listen

Last update: 18 septembre 2023
Created: 18 septembre 2023