showAndUpdateServiceAgreement function
- required BuildContext context,
- required int deviceId,
Show the service agreement dialog and update the service agreement details of a device based on the input provided by the user.
Implementation
Future<void> showAndUpdateServiceAgreement({
required BuildContext context,
required int deviceId,
}) async {
final data = await showServiceAgreementDialog(
context: context,
deviceId: deviceId,
);
if (data == null) return;
if (!context.mounted) return;
try {
final updateServiceAgreement = context.read(updateServiceAgreementProvider);
await updateServiceAgreement(
context: context,
deviceId: deviceId,
data: data,
);
if (!context.mounted) return;
showSuccessBanner(
Text(context.l10n.serviceAgreementChangesSaved),
context: context,
);
} catch (_) {
showErrorBanner(
Text(context.l10n.errorOccurredServiceAgreementChangesNotSaved),
contentPadding: const EdgeInsets.symmetric(
horizontal: 22.0,
vertical: 6.0,
),
context: context,
);
}
}