Asset Profile Operations
This example shows:
- Create an Asset: Create a new asset with a custom ID, name, description, and attributes. The created asset ID is stored in the
assetTracking
object. - Bind an Asset ID: Bind an existing asset ID to the current session. This action associates the current session with a specific asset.
- Update Current Asset Profile: Update the profile of the current asset. Change the name, description, and attributes of the asset.
- Retrieve Asset Detail of Current Asset ID: Retrieve detailed information about the current asset, such as its ID, name, description, and attributes.
For all code examples, refer to Asset Tracking Flutter Code Examples
asset_profile_screen.dart view source
Here are the code highlights for each of the four functionalities:
Create an Asset: assetTracking.createAsset(profile: profile)
- This functionality is implemented within the
onPressed
callback of the "Create New Asset" button. - It creates a new
AssetProfile
object with a custom ID, name, description, and empty attributes. - The
createAsset
method of theassetTracking
object is called to create the asset. - If the operation is successful (result.success), the asset ID is stored (assetId = result.data), and a success message is displayed. Otherwise, an error message is shown.
Bind an Asset ID: assetTracking.bindAsset(customId: assetId)
- This functionality is implemented within the
onPressed
callback of the "Bind Asset" button. - It calls the
bindAsset
method of the assetTracking object to bind the current asset ID. - If the operation is successful (assetResult.success), a success message is displayed. Otherwise, an error message is shown.
Update Current Asset Profile: assetTracking.updateAsset(assetProfile: assetProfile)
- This functionality is implemented within the
onPressed
callback of the "Update Asset Info" button. - It creates a new
AssetProfile
object with updated information (name, description, and attributes). - The
updateAsset
method of theassetTracking
object is called to update the asset profile. - If the operation is successful (assetDetail.success), a success message is displayed. Otherwise, an error message is shown.
Retrieve Asset Detail of Current Asset ID: assetTracking.getAssetDetail()
- This functionality is implemented within the
onPressed
callback of the "Get Asset Detail" button. - It calls the
getAssetDetail
method of theassetTracking
object to retrieve detailed information about the current asset. - If the operation is successful (assetDetail.success), the retrieved information is stored in
assetDetailInfo
and displayed on the screen. Otherwise, an error message is shown.