> For the complete documentation index, see [llms.txt](https://docs.nubrick.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nubrick.app/reference/flutter/nubrickuser.md).

# NubrickUser

### インターフェース

```dart
class NubrickUser {
  Future<String?> getId()
  Future<void> setProperties(Map<String, dynamic> properties)
  Future<Map<String, String>?> getProperties()
}
```

### .getId <a href="#id" id="id"></a>

NubrickUser にはデフォルトでUUID形式のユーザーIDがプロパティとして設定されています。ユーザーIDは以下のように取得できます：

```dart
final user = NubrickUser();
final userId = await user.getId();
```

オプションで、カスタムユーザーIDを設定することも可能です：

```dart
await user.setProperties({'userId': '<CUSTOM_USER_ID>'});
```

{% hint style="warning" %}
この値は、エクスペリメントのデータを収集するためにNubrickサーバーに送信されます。そのため、ユーザーIDとしてプライバシーに関わるデータを設定することは推奨されません。
{% endhint %}

### .setProperties <a href="#set" id="set"></a>

{% hint style="info" %}
このプロパティは、

* どのユーザーがエクスペリメントのターゲットとなるかをフィルタリングする
* エクスペリメント内のユーザー毎の動的な変数として表示する

ために使用されます。
{% endhint %}

{% hint style="warning" %}
SDK v0.3.2未満では、カスタムのユーザープロパティはIn-memoryに保存される仕様となっています。アプリ起動時に、都度ユーザーのプロパティをsetしていただく実装が必要です。

SDK v0.3.2では、アプリ内のストレージに保存するよう修正しましたので、一度設定したユーザープロパティは、アプリの再起動後も永続化されます。
{% endhint %}

カスタムのユーザーのプロパティを設定することができます：

```dart
await user.setProperties({'<KEY>': '<VALUE>'});
```

また、 `<VALUE>` は `String`, `bool`, `int`, `double`, `DateTime` をサポートしています。 (SDK >= v0.9.0)

### .getProperties <a href="#comeback" id="comeback"></a>

ユーザーのプロパティを取得することができます：

```dart
final properties = await user.getProperties();
```


---

# 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.nubrick.app/reference/flutter/nubrickuser.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.
