ToastAction constructor

ToastAction({
  1. required String content,
  2. required String arguments,
  3. String? type,
  4. ToastActionActivationType? activationType,
  5. String? placement,
  6. String? imageUri,
  7. String? hintInputId,
  8. ToastActionHintButtonStyle? hintButtonStyle,
  9. String? hintToolTip,
})

Implementation

ToastAction({
  /// The content displayed on the button.
  required String content,

  /// App-defined string of arguments that the app will later receive if the user clicks this button.
  required String arguments,

  /// An argument string that can be passed to the associated app to provide
  /// specifics about the action that it should execute in response to the user action.
  String? type,

  /// Decides the type of activation that will be used when the user interacts with a specific action.
  /// "foreground" - Default value. Your foreground app is launched.
  /// "background" - Your corresponding background task is triggered,
  ///                and you can execute code in the background without interrupting the user.
  /// "protocol" - Launch a different app using protocol activation.
  ToastActionActivationType? activationType,

  /// When set to "contextMenu", the action becomes a context menu action
  /// added to the toast notification's context menu rather than a traditional toast button.
  String? placement,

  /// The URI of the image source for a toast button icon. These icons are white transparent 16x16 pixel images at 100% scaling and should have no padding included in the image itself. If you choose to provide icons on a toast notification, you must provide icons for ALL of your buttons in the notification, as it transforms the style of your buttons into icon buttons. Use one of the following protocol handlers:
  /// http:// or https:// - A web-based image.
  /// ms-appx:/// - An image included in the app package.
  /// ms-appdata:///local/ - An image saved to local storage.
  /// file:/// - A local image. (Supported only for desktop apps. This protocol cannot be used by UWP apps.)
  String? imageUri,

  /// Set to the Id of an input to position button beside the input.
  String? hintInputId,

  /// The button style. useButtonStyle must be set to true in the toast element.
  /// "Success" - The button is green
  /// "Critical" - The button is red.
  ToastActionHintButtonStyle? hintButtonStyle,

  /// The tooltip for a button, if the button has an empty content string.
  String? hintToolTip,
}) {
  _action.attributes.add(XmlAttribute(XmlName('content'), content));
  _action.attributes.add(XmlAttribute(XmlName('arguments'), arguments));
  if (type != null) {
    _action.attributes.add(XmlAttribute(XmlName('type'), type));
  }
  if (activationType != null) {
    _action.attributes.add(XmlAttribute(
        XmlName('activationType'), activationType.name.toLowerCase()));
  }
  if (placement != null) {
    _action.attributes.add(XmlAttribute(XmlName('placement'), placement));
  }
  if (imageUri != null) {
    _action.attributes.add(XmlAttribute(XmlName('imageUri'), imageUri));
  }
  if (hintInputId != null) {
    _action.attributes
        .add(XmlAttribute(XmlName('hint-inputId'), hintInputId));
  }
  if (hintButtonStyle != null) {
    final String style;
    switch (hintButtonStyle) {
      case ToastActionHintButtonStyle.success:
        style = 'Success';
        break;
      case ToastActionHintButtonStyle.critical:
        style = 'Critical';
        break;
    }
    _action.attributes.add(XmlAttribute(XmlName('hint-buttonStyle'), style));
  }
  if (hintToolTip != null) {
    _action.attributes
        .add(XmlAttribute(XmlName('hint-toolTip'), hintToolTip));
  }
}