--- title: "User object" slug: "flutter-user-object" description: "Set user attributes, identifiers, opt-ins, custom fields, and login/logout using Insider's User Object and getCurrentUser method." tags: ["flutter user object"] updated: 2026-11-04T13:12:31Z published: 2026-11-04T13:12:31Z canonical: "academy.insiderone.com/flutter-user-object" --- > ## Documentation Index > Fetch the complete documentation index at: https://academy.insiderone.com/llms.txt > Use this file to discover all available pages before exploring further. # User object ## Initialize user object Whenever you initialize Insider SDK, you also initialize a new Insider **user** object. You can set attributes for this object and get this object with **getCurrentUser** method. Insider **user** object represents the current user of your app. It is the main object that you can use for attribution (e.g. age, email, opt-in, etc.). ### Method Signature ```dart FlutterInsiderUser getCurrentUser() ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser(); ``` The values in the method examples are **sample values**. While implementing these methods, you need to replace them with your **own unique variables**. Otherwise, the methods will not function properly, and might cause discrepancies in user unification. --- ## Set email as user identifier This method allows you to set the **user identifier attribute** of your Insider **user** object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web. ### Method Signature ```dart Future addEmail(String email) async ``` ### Method Example ```dart FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers(); identifiers.addEmail("sample@mail.com"); identifiers.addPhoneNumber("+651234567"); identifiers.addUserID("CRM-ID"); await FlutterInsider.Instance.getCurrentUser().login(identifiers); ``` All parameter types are required to be **String.** Phone numbers are required to start with a **+** **(plus)** sign followed by a country code. The country code should start with a number between 1-9.UCD listens to the IRM settings to distinguish your actual identifiers, so setting the email identifier from the SDK doesn't mean that it will be sent as an identifier. --- ## Set phone number as user identifier This method allows you to set the **user identifier attribute** of your Insider **user** object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web. ### Method Signature ```dart Future addPhoneNumber(String phoneNumber) async ``` ### Method Example ```dart FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers(); identifiers.addEmail("sample@mail.com"); identifiers.addPhoneNumber("+651234567"); identifiers.addUserID("CRM-ID"); await FlutterInsider.Instance.getCurrentUser().login(identifiers); ``` All parameter types are required to be **String.** Phone numbers are required to start with a **+** **(plus)** sign followed by a country code. The country code should start with a number between 1-9. --- ## Set user ID as user identifier This method allows you to set the **user identifier attribute** of your Insider **user** object for data unification. With this attribute, you can unify your user data within Insider products and reach this user via different channels such as mobile app and web. ### Method Signature ```dart Future addUserID(String userID) async ``` ### Method Example ```dart FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers(); identifiers.addEmail("sample@mail.com"); identifiers.addPhoneNumber("+651234567"); identifiers.addUserID("CRM-ID"); await FlutterInsider.Instance.getCurrentUser().login(identifiers); ``` All parameter types are required to be **String.** Phone numbers are required to start with a **+** **(plus)** sign followed by a country code. The country code should start with a number between 1-9. --- ## Set name attribute This method allows you to set the **name** attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | name | String | ### Method Signature ```dart Future setName(String name) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setName("name"); ``` --- ## Set surname attribute This method allows you to set the **surname** attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | surname | String | ### Method Signature ```dart Future setSurname(String surname) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setSurname("surname"); ``` --- ## Set gender attribute This method allows you to set the **gender** attribute for your Insider **user** object. You need to pass InsiderGender enum object as a parameter. | Parameter | Enum values | | --- | --- | | gender (InsiderGender enum) | InsiderGenderMale InsiderGenderFemale InsiderGenderOther | ### Method Signature ```dart Future setGender(int gender) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setGender(InsiderGender.OTHER); ``` --- ## Set age attribute This method allows you to set the **age** attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | age | Integer | ### Method Signature ```dart Future setAge(int age) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setAge(23); ``` --- ## Set birthday attribute This method allows you to set the **birthday** attribute for your Insider user object. Data should be set in (YYYY-MM-DD) format. | Parameter | Data Type | | --- | --- | | birthday | Date | ### Method Signature ```dart Future setBirthday(DateTime birthday) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setBirthday(new DateTime.now()); ``` --- ## Select language attribute This method allows you to set the **language** attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | language | String | ### Method Signature ```dart Future setLanguage(String language) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setLanguage("language"); ``` --- ## Set email opt-in attribute This method allows you to set the **email opt-in** (permission) attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | emailOptin | Boolean | ### Method Signature ```dart Future setEmailOptin(bool emailOptin) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setEmailOptin(true); ``` --- ## Set sms opt-in attribute This method allows you to set the **sms** **opt-in** (permission) attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | smsOptin | Boolean | ### Method Signature ```dart Future setSMSOptin(bool smsOptin) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setSMSOptin(true); ``` --- ## Set Whatsapp opt-in attribute This method allows you to set the **whatsapp** **opt-in** (permission) attribute for your Insider **user** object. | Parameter | Data Type | | --- | --- | | whatsAppOptin | Boolean | ### Method Signature ```dart Future setWhatsappOptin(bool whatsappOptin) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setWhatsappOptin(true); ``` --- ## Set push opt-in attribute This method allows you to set the **push** **opt-in** (permission) attribute for your Insider **user** object. If you pass the value as *false*, the respective device will not receive any push notifications unless you set the value to *true*. | Parameter | Data Type | | --- | --- | | pushOptin | Boolean | ### Method Signature ```dart Future setPushOptin(bool pushOptin) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setPushOptin(true); ``` --- ## Set location opt-in attribute This method allows you to set the **location** **opt-in** (permission) attribute for your Insider **user** object. If you pass the value as *false*, the respective device will not be targeted for **Geofence** unless you set the value to *true*. | Parameter | Data Type | | --- | --- | | locationOptin | Boolean | ### Method Signature ```dart Future setLocationOptin(bool locationOptin) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setLocationOptin(true); ``` --- ## Set promotional opt-in attribute This method allows you to set the promotional opt-in (permission) attribute for your Insider user object. It stores the user's consent for promotional marketing messages so that it can be used for App Push targeting. If you never call this method, or if you pass the value as *false*, the user is treated as **not opted-in** and will not be targeted by promotional App Push campaigns. This attribute is stored at the user (profile) level, not per device, so its value applies to every device the user is identified on. The method returns the FlutterInsiderUser object, so it can be chained with the other user attribute setters. | Parameter | Data Type | | --- | --- | | promotionalOptin | Boolean | ### Method Signature ```dart FlutterInsiderUser setPromotionalOptin(bool promotionalOptin) ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setPromotionalOptin(true); ``` --- ## Set login attribute This method allows you to set the **login status** attribute for your Insider **user** object. Once you call this method to assign its value as *true*, you need to call the **logout method** to set it *false*.  ### Method Signature ```dart Future login(FlutterInsiderIdentifiers identifiers) async ``` ### Method Example ```dart FlutterInsiderIdentifiers identifiers = new FlutterInsiderIdentifiers(); identifiers.addEmail("sample@mail.com"); identifiers.addPhoneNumber("+651234567"); identifiers.addUserID("CRM-ID"); await FlutterInsider.Instance.getCurrentUser().login(identifiers); ``` --- ## Set login attribute and wait for the Insider ID This method sets the **login status** attribute like the login method, and returns a Future that resolves to the merged Insider ID. The Future resolves to null if the native SDK does not answer within timeout, which defaults to 10 seconds. This method is available on **flutter_insider 5.5.0** or higher. Use login(identifiers, insiderIDResult: ...) when you want the callback style. For details, see [Awaiting SDK Calls](https://academy.insiderone.com/docs/flutter-awaiting-sdk-calls). ### Method Signature ```dart Future loginAsync( FlutterInsiderIdentifiers identifiers, { Duration timeout = const Duration(seconds: 10), }) ``` ### Method Example ```dart FlutterInsiderIdentifiers identifiers = FlutterInsiderIdentifiers() ..addEmail("sample@mail.com") ..addUserID("CRM-ID"); final insiderID = await FlutterInsider.Instance.getCurrentUser()?.loginAsync(identifiers); ``` --- ## Set logout attribute This method allows you to set the **login status** attribute for your Insider **user** object. Once you call assign *false* for the value for login status, you need to call the **login method** to set it *true*.Starting with **flutter_insider 5.5.0**, this method returns a Future that completes when the native SDK call has returned. For details, see [Awaiting SDK Calls](https://academy.insiderone.com/docs/flutter-await-sdk-calls). ### Method Signature ```dart Future logout() async ``` ### Method Example ```dart await FlutterInsider.Instance.getCurrentUser().logout(); ``` --- ## Set logout-reset attribute This is an alternative logout method for specific use cases. If you're unsure whether it applies to your setup, please contact your account manager. If you don’t have a special requirement, use the default logout method to avoid user-management issues or unexpected MAU increases. This method allows you to set the **login status** attribute for your Insider user object, then **disassociate the user from the current device and generate new IID** for the current device. Also, this method allows you to send additional Identifiers to include in the logout process, all additional identifiers (including the currently logged in user) will be disassociated from the current device. Once you call assign *false* for the value for login status, you need to call the **login method** to set it to *true*. ### Method Signature ```dart void logoutResettingInsiderID( List? additionalIdentifiers, { Function? insiderIDResult }) ``` ### Method Example ```dart // Logout the current user only FlutterInsider.Instance.getCurrentUser().logoutResettingInsiderID(null); // Logout the current user along side additional users FlutterInsiderIdentifiers identifiers = FlutterInsiderIdentifiers() ..addEmail("user@example.com") ..addUserID("user123"); FlutterInsider.Instance.getCurrentUser().logoutResettingInsiderID([identifiers]); ``` --- ## Set logout-reset attribute and wait for the new Insider ID This method works like logoutResettingInsiderID and returns a Future that resolves to the new Insider ID. The Future resolves to null if the native SDK does not answer within timeout, which defaults to 10 seconds. This method is available on **flutter_insider 5.5.0** or higher. For details, see [Awaiting SDK Calls](https://academy.insiderone.com/docs/flutter-awaiting-sdk-calls). ### Method Signature ```dart Future logoutResettingInsiderIDAsync( List? additionalIdentifiers, { Duration timeout = const Duration(seconds: 10), }) ``` ### Method Example ```dart // Logout the current user only final newInsiderID = await FlutterInsider.Instance.getCurrentUser()?.logoutResettingInsiderIDAsync(null); ``` --- ## Set signup event To trigger action for signup of users, you need to call this method **whenever a user sign up to the app.** ### Method Signature ```dart Future signUpConfirmation() async ``` ### Method Example ```dart FlutterInsider.Instance.signUpConfirmation() ``` ## Set locale attribute This method allows you to set the **locale** attribute for your Insider user object. | Parameter | Data Type | | --- | --- | | locale | String | ### Method Signature ```dart Future setLocale(String locale) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setLocale("en_EN"); ``` --- ## Set custom string attribute This method allows you to set the **custom** **string** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | String | ### Method Signature ```dart Future setCustomAttributeWithString(String key, String value) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithString("key", "stringValue"); ``` --- ## Set custom integer attribute This method allows you to set the **custom integer** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | Integer | ### Method Signature ```dart Future setCustomAttributeWithInt(String key, int value) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithInt("key", 10); ``` --- ## Set custom boolean attribute This method allows you to set the **custom boolean** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | Boolean | ### Method Signature ```dart Future setCustomAttributeWithBoolean(String key, bool value) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithBoolean("key", true); ``` --- ## Set custom double attribute This method allows you to set the **custom double** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | Double | ### Method Signature ```dart Future setCustomAttributeWithDouble(String key, double value) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithDouble("key", 10.5); ``` --- ## Set custom date attribute This method allows you to set the **custom date** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | Date object | ### Method Signature ```dart Future setCustomAttributeWithDate(String key, DateTime value) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithDate("key", new DateTime.now()); ``` --- ## Set custom array attribute This method allows you to set the **custom array** **attribute** for your Insider **user** object. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | | value | Array (of string) | ### Method Signature ```dart Future setCustomAttributeWithArray(String key, List value) async ``` ### Method Example ```dart List arr = new List(3); arr[0] = "item1"; arr[1] = "item2"; arr[2] = "item3"; FlutterInsider.Instance.getCurrentUser().setCustomAttributeWithArray("key", arr); ``` --- ## Unset custom attribute This method allows you to unset any **custom** **attribute** of your Insider **user** object. This method will remove the respective the custom attribute of your user for the given key permanently. Your attribute key should be lowercase and should not include any special character, non-Latin character or any space. Otherwise, this attribute will be ignored. You can use underscores. | Parameter | Data Type | | --- | --- | | key | String | ### Method Signature ```dart Future unsetCustomAttribute(String key) async ``` ### Method Example ```dart FlutterInsider.Instance.getCurrentUser().unsetCustomAttribute("key"); ``` --- ## Add objects to a custom attribute Use these methods to add, merge, and remove objects in an [Array of Objects](/docs/array-of-objects-attributes-overview) custom attribute of the current user. Define the attribute in the panel first; see [Create an Array of Objects Attribute](https://academy.insiderone.com/docs/create-an-array-of-objects-attribute). Rules for object values: - Object keys must match ^[a-z][0-9a-z_]*$. Invalid keys are dropped and named in a console warning; the rest of the call is still sent. - An attribute or parameter key that is empty, whitespace-only, or does not match the same pattern is refused with a console warning. - Values can be String, int, double, bool, DateTime, a List or Set of strings or numbers, or a nested Map. - A string longer than 500 characters, a null value, and a NaN or infinite number are dropped and named in a single console warning per call. - A nested map can hold only plain values; a map inside a nested map is dropped with its key and named in the console warning. For example, {'a': {'b': 1}} is sent as is, while in {'a': {'b': {'c': 1}, 'd': 2}} 'b' is dropped and 'a' is sent with 'd' only. - An object that keeps no key is dropped. Call addObjectsToCustomAttribute to add a list of objects to an Array of Objects attribute of the current user. | Parameter | Data Type | Description | | --- | --- | --- | | key | String | Key of the Array of Objects attribute defined in the panel. | | objects | List> | The objects to add. | ### Method Signature ```dart FlutterInsiderUser addObjectsToCustomAttribute( String key, List> objects) ``` ### Method Example ```dart import 'package:flutter_insider/flutter_insider.dart'; FlutterInsider.Instance.getCurrentUser()?.addObjectsToCustomAttribute( 'c_favorite_products', [ {'sku': 'SKU-1', 'qty': 2}, {'sku': 'SKU-2', 'qty': 1}, ], ); ``` An empty list, or a list in which no object keeps a key, is not sent; a console warning says so. --- ## Merge values into matching objects Call mergeObjectsInCustomAttribute to merge value into every object of the attribute that matches match. | Parameter | Data Type | Description | | --- | --- | --- | | key | String | Key of the Array of Objects attribute defined in the panel. | | match | Map | Fields that select the objects to update. | | value | Map | Fields to merge into each matching object. | ### Method Signature ```dart FlutterInsiderUser mergeObjectsInCustomAttribute( String key, Map match, Map value) ``` ### Method Example ```dart import 'package:flutter_insider/flutter_insider.dart'; FlutterInsider.Instance.getCurrentUser()?.mergeObjectsInCustomAttribute( 'c_favorite_products', {'sku': 'SKU-1'}, {'qty': 3}, ); ``` An empty match, or a value that is empty or keeps no key, is refused with a console warning. If any entry of match cannot be sent, the call is refused, so it **never updates** more objects than you meant. --- ## Remove objects from a custom attribute Call removeObjectsFromCustomAttribute with a match to remove the objects of the attribute that match it. Call it with the key only to remove every object. | Parameter | Data Type | Description | | --- | --- | --- | | key | String | Key of the Array of Objects attribute defined in the panel. | | match | Map? | Optional. Fields that select the objects to remove. | ### Method Signature ```dart FlutterInsiderUser removeObjectsFromCustomAttribute(String key, [Map? match]) ``` ### Method Example ```dart import 'package:flutter_insider/flutter_insider.dart'; FlutterInsider.Instance.getCurrentUser()?.removeObjectsFromCustomAttribute( 'c_favorite_products', {'sku': 'SKU-2'}, ); ``` Calling removeObjectsFromCustomAttribute(key) without a match removes every object and **cannot be undone**; a console warning says so. An empty match or an explicit null is refused. If any entry of match cannot be sent, the call is refused, so it **never removes** more objects than you meant. > For troubleshooting, refer to [Why cannot we trigger the login method a second time in an active session](https://academy.insiderone.com/docs/why-cannot-we-trigger-the-login-method-a-second-time-in-an-active-session), [Confusion of attributes among users after login](https://academy.insiderone.com/docs/confusion-of-attributes-among-users-after-login)