update method

Future<void> update({
  1. String? title,
  2. String? message,
})

Updates the template content on Android Auto.

Android Auto templates are immutable. This method asks the native side to rebuild the message template and invalidate the current screen. Changing the title or message is treated by Android Auto as a new template step, not as a refresh of the existing template, and can count toward host template limits.

message must not be empty. Native update errors are surfaced as PlatformExceptions from the MethodChannel call.

Implementation

Future<void> update({String? title, String? message}) async {
  final nextTitle = title ?? this.title;
  final nextMessage = message ?? this.message;
  _validateMessage(nextMessage);

  await FlutterAndroidAutoController.flutterToNativeModuleStatic(
    updateChannelType,
    {'elementId': _elementId, 'title': nextTitle, 'message': nextMessage},
  );

  updateTemplate(title: nextTitle, message: nextMessage);
}