Contacts
Sets contacts listener
Set the contact listener, and the result is returned through the data stream contactEveStm, which is returned as a ContactListenBean object.
_blePlugin.contactEveStm.listen(
(ContactListenBean event) {
/// Do something with new state,for example:
setState(() {
switch (event.type) {
case ContactListenType.savedSuccess:
_savedSuccess = event.savedSuccess!;
break;
case ContactListenType.savedFail:
_savedFail = event.savedFail!;
break;
default:
break;
}
});
});
Callback Description(event):
ContactListenBean:
callback value | callback value type | callback value description |
---|---|---|
type | int | Get the corresponding return value according to type, where type is the value corresponding to ContactListenType. |
savedSuccess | int | The return value of the success of saving the contact; |
savedFail | int | The return value of the failure to save the contact |
ContactListenType:
type | value | value description |
---|---|---|
savedSuccess | 1 | Set contacts successfully |
savedFail | 2 | Failed to set contacts |
Sets contacts with avatar listener
Sets the contact avatar listener, and the result is returned through the data stream contactAvatarEveStm, which is returned as a FileTransBean object.
_blePlugin.contactAvatarEveStm.listen(
(FileTransBean event) {
/// Do something with new state,for example:
setState(() {
switch (event.type) {
case TransType.transStart:
break;
case TransType.transChanged:
_progress = event.progress!;
break;
case TransType.transCompleted:
break;
case TransType.error:
_error = event.error!;
break;
default:
break;
}
});
});
Callback Description(event):
FileTransBean:
callback value | callback value type | callback value description |
---|---|---|
type | int | Get the corresponding return value according to type, where type is the value corresponding to TransType. |
progress | int | set progress |
error | int | error code |
TransType:
type | value | value description |
---|---|---|
transStart | 1 | Set a contact avatar to get started |
transChanged | 2 | Set contact avatar progress changes |
transCompleted | 3 | Set contact avatar successfully |
error | 4 | Error setting contact avatar |
Check support contacts
ContactConfigBean info = await _blePlugin.checkSupportQuickContact;
Callback Description:
ContactConfigBean:
value | value type | value description |
---|---|---|
supported | bool | Whether symbols are supported, such as ”+“ |
count | int | Maximum number of contacts |
width | int | The width of the contact avatar |
height | int | The height of contact avatar |
Gets current contacts count
int contactCount = _blePlugin.queryContactCount;
Sets contact information
Sets the contact, the result is obtained through contactEveStm.
_blePlugin.sendContact(ContactBean info);
Parameter Description :
ContactBean:
value | value type | value description |
---|---|---|
id | int | The contact id |
width | int | The contact avatar width |
height | int | The contact avatar height |
address | int | The contact address |
name | String | The contact name |
number | String | The contact phone number |
avatar | Uint8List? | The contact avatar |
Precautions:
- The Uint8List? type is a picture type, interacts with the backend, and converts it to a bitmap type at the backend.
- Contacts sent to the watch face, must have an avatar.
- id has size limit. The maximum value of id can be viewed through count in the return value of _blePlugin.checkSupportQuickContact, and cannot be greater than or equal to the queried value.
Sets contact avatar information
Sets the contact avatar , the result is obtained through contactAvatarEveStm.
_blePlugin.sendContactAvatar(ContactBean info);
Delete contacts information
Delete contact information based on contact id.
_blePlugin.deleteContact(int id);
Delete contacts avatar information
Delete contact avatar information based on contact id.
_blePlugin.deleteContactAvatar(int id);
clear contacts information
_blePlugin.clearContact();