> 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

### インターフェース <a href="#interface" id="interface"></a>

```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)

キーに使える文字は半角英数字と `_` `-` のみです。camelCase（`isPremium` など）を推奨します。詳細は [ユーザー属性情報（setProperties）について](/other/setproperties.md) を参照してください。

### .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 following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nubrick.app/reference/flutter/nubrickuser.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `build a script that syncs our docs to a CMS` lets GitBook tailor the answer to that use case.

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.
