> For the complete documentation index, see [llms.txt](https://docs.ep.mburger.cloud/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ep.mburger.cloud/flutter-docs/messages/initialization.md).

# Initialization

To initialize the SDK you have to add `MBMessages` to the array of plugins of `MBurger`.

```dart
MBManager.shared.apiToken = 'YOUR_API_TOKEN';
MBManager.shared.plugins = [MBMessages()];
```

To show in app message correctly you have to embed your main widget in a `MBMessagesBuilder` like this:

```dart
@override
Widget build(BuildContext context) {
return MaterialApp(
  ...
    home: MBMessagesBuilder(
      child: Scaffold(
        ...
      ),
    ),
  );
}
```

Why? To present in app messages `MBMessages` uses the `showDialog` function that needs a `BuildContext`. Embedding your main `Scaffold` in a `MBMessagesBuilder` let the SDK know always what context to use to show in app messages.

### Initialize MBMessages with parameters

You can set a couples of parameters when initializing the `MBMessages` plugin:

```dart
MBMessages messagesPlugin = MBMessages(
  messagesDelay: 1,
  automaticallyCheckMessagesAtStartup: true,
  debug: false,
  themeForMessage: (message) => MBInAppMessageTheme(),
  onButtonPressed: (button) => _buttonPressed(button),
);
```

* **messagesDelay**: it's the time after which the messages will be displayed once fetched
* **automaticallyCheckMessagesAtStartup**: if the plugin should automatically check messages at startup. By default it's true.
* **debug**: if this is set to `true`, all the message returned by the server will be displayed, if this is set to `false` a message will appear only once for app installation. This is `false` by default
* **themeForMessage**: a function to provide a message theme (colors and fonts) for in app messages.
* **onButtonPressed**: a callback called when a button of an in app message iis pressed.


---

# 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, and the optional `goal` query parameter:

```
GET https://docs.ep.mburger.cloud/flutter-docs/messages/initialization.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
