shareAndinvite method
share message and inviate the atsign provided
Implementation
Future<void> shareAndinvite(BuildContext context, String jsonData) async {
// create a key and save the json data
var keyID = const Uuid().v4();
int code = Random().nextInt(9999);
String passcode = code.toString().padLeft(4, '0');
MessageShareModel messageContent = MessageShareModel(passcode: passcode, identifier: keyID, message: jsonData);
AtKey atKey = AtKey()..metadata = Metadata();
atKey.key = '$invitationKey.$keyID';
atKey.metadata.ttr = -1;
var result = await AtClientManager.getInstance().atClient.put(atKey, jsonEncode(messageContent)).catchError((e) {
_logger.severe('Error in saving shared data => $e');
throw e;
});
if (result && context.mounted) {
showDialog(
context: context,
builder: (context) => ShareDialog(
uniqueID: keyID,
passcode: passcode,
webPageLink: webPage,
currentAtsign: AtClientManager.getInstance().atClient.getCurrentAtSign() ?? ''),
);
}
}