> For the complete documentation index, see [llms.txt](https://helio-junior.gitbook.io/vuex4flutter/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://helio-junior.gitbook.io/vuex4flutter/the-store/mutations.md).

# Mutations

## Defining a mutation

```dart
class UpdateMessageMutation extends Mutation {
  @override
  String get name => 'changeMessage'; // if you don't override it will be the name of class: 'UpdateMessageMutation' 

  @override
  void call(Map<String, dynamic> state, payload) {
    state['message'] = payload;
  }
}
```

{% hint style="warning" %}
All mutations should be sync, if you need to perform async operations you must use an action
{% endhint %}

## Registering the mutation on Store

```dart
class MyStore extends Store {
  MyStore() : super(
    Module(
      state: {
        'message': 'A message',
      },
      mutations: [
        UpdateMessageMutation(),
      ],
    ),
  );
}
```

## Commiting a change

```dart
store.commit('/changeMessage', 'New message');
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://helio-junior.gitbook.io/vuex4flutter/the-store/mutations.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
