패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.9.1

flutter_platform_alert

플러그인은 원격 API를 호출하여 알림 사운드를 재생하고 알림 대화 상자를 표시하는 데 도움을 줍니다. 예를 들어, Windows에서 MessageBox와 TaskDialogIndirect를 연결합니다.

AndroidiOSmacOSWindowsLinux
30일 다운로드
1.2만
좋아요
145
Pub 점수
160

패키지 설치

flutter pub add flutter_platform_alert

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

플랫폼 고유의 알림 대화 상자를 표시하고 경고 사운드를 재생하기 위해 네이티브 시스템 API를 호출할 수 있는 플러터 플러그인입니다. Windows에서는 MessageBox 및 TaskDialogIndirect와 같은 네이티브 대화 상자 메커니즘을 연결하여 다양한 플랫폼 간 일관된 사용자 경험을 보장합니다. 이 패키지는 Android, iOS, macOS, Windows, Linux를 지원하며, 시스템 수준의 알림이나 네이티브한 외관과 동작을 필요로 하는 애플리케이션에 이상적입니다.

사용 사례

  • 시스템 내장 알림 대화상자 표시
  • 플랫폼별 알림 사운드 재생
  • Windows TaskDialogIndirect와의 통합
  • 경고의 다중 플랫폼 일관성 보장
  • 네이티브 UI 요소를 통한 사용자 피드백 향상

주요 기능

  • 크로스 플랫폼 네이티브 대화 상자 지원
  • 알림 사운드 재생을 지원합니다
  • 윈도우 전용 TaskDialogIndirect 통합
  • 필수 최소 구성
  • 원본 OS API를 사용하여 진짜처럼 보이고 느껴지게 합니다

적합한 대상

  • 네이티브 경고 대화 상자를 필요로 하는 응용 프로그램
  • 고급 대화 상자를 사용하여 Windows를 타겟으로 하는 개발자
  • 시스템 수준 알림 사운드가 필요한 앱
  • 플랫폼 일관성 있는 UI를 우선시하는 프로젝트
  • 데스크톱 중심의 플러터 앱을 개발하는 팀

고려 사항

  • 특정 플랫폼(안드로이드, iOS, 맥OS, 윈도우, 리눅스)에 한정
  • 대상 시스템의 네이티브 API 액세스가 필요합니다
  • 운영 체제 설정에 따라 다르게 동작할 수 있습니다
  • 웹 플랫폼에 적합하지 않습니다
  • 하위 OS 대화 상자 구현에 따라 다름

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_platform_alert

2021 and onwards © Weizhong Yang a.k.a zonble.

Pub example workflow License: MIT Ask DeepWiki

A simple plugin to present native alerts, including playing alert sounds and showing alert dialogs on various platforms including iOS, Android, Windows, macOS and Linux.

iOS Android macOS Windows Linux

It uses following API to show play alert sound.

It uses following API to show alert dialogs.

The package was developed and tested on

  • iOS 15
  • Android 11
  • macOS 11 Big Sur and mac OS 12 Monterey / Xcode 13
  • Windows 10 / Visual Studio Community 2019
  • Ubuntu 21.10

Getting Started

  • Add the dependency to your pubspec.yaml file by flutter pub add flutter_platform_alert.
  • Run flutter pub get.

To play platform alert sound.

import 'package:flutter_platform_alert/flutter_platform_alert.dart';
await FlutterPlatformAlert.playAlertSound();

To show a platform alert dialog.

import 'package:flutter_platform_alert/flutter_platform_alert.dart';
await FlutterPlatformAlert.playAlertSound();

final clickedButton = await FlutterPlatformAlert.showAlert(
    windowTitle: 'This ia title',
    text: 'This is body',
    alertStyle: AlertButtonStyle.yesNoCancel,
    iconStyle: IconStyle.information,
);

To show an alert dialog with custom button titles:

import 'package:flutter_platform_alert/flutter_platform_alert.dart';
await FlutterPlatformAlert.playAlertSound();

final result = await FlutterPlatformAlert.showCustomAlert(
  windowTitle: 'This is title',
  text: 'This is body',
  positiveButtonTitle: "Positive",
  negativeButtonTitle: "Negative",
  neutralButtonTitle: "Neutral",
  options: PlatformAlertOptions(
    windows: WindowsAlertOptions(
      additionalWindowTitle: 'Window title',
      showAsLinks: true,
    ),
  ),
);

Platform Alert Dialogs

Alert Styles

When calling showCustomAlert, you can assign any button titles and use up to three buttons. Once there is no button title specified, it falls back to only an "OK" button.

When calling showAlert, you can specify the buttons listed in the alert dialog by passing alertStyle argument. The package follows the API design on Windows (see the reference of MessageBox win32 API), and it provides following styles:

  • Abort, retry and ignore
  • Cancel, try again and continue
  • OK
  • OK and cancel
  • Retry and cancel
  • Yes and no
  • Yes, no, and cancel

Since each platform has its own conventions, the order of these buttons are not guaranteed to be the same.

Icon Styles

The package also follow the API design of MessageBox on Windows to add icons to the alert dialogs (see the link above). There are several different icons styles but actually four:

  • No icon
  • Warning icon
  • Information icon
  • Question icon

Please note that these icons are not available on iOS and Android.

Themes/Dark or Light Mode

On iOS and macOS, the alert dialogs follows the dark/light mode settings on users' system. On Linux, the alert dialogs are rendered with current GTK theme. On Windows, they are always in light mode even you choose to use dark mode on Windows 10 and Windows 11.

On Android, the alert dialog uses the default theme of Material design (as Theme.Material.Dialog.Alert).

Localization

Since the plugin calls native API, if you want to localize buttons like "OK", "Cancel" and so on on Platforms like iOS, macOS and Linux, you have to do some works in your app.

  • To localize the button titles on iOS and macOS, add "Localizable.strings" or "Localizable.stringsdict" files in your Xcode project. Visit Apple's official page for localization for further information.
  • On Linux, we use gettext to localize apps. Please update the PO files in your projects once you integrate the plugin.

Android apps embeds resources for localized strings. The localized strings files for the project are located under android/src/main/res. Once you need to add new languages, just fork the project and put your files under the folder.

On Windows, the buttons on the message boxes will be in the Windows system language.

License

The package in released under MIT License.

Screenshots

Android 13 on Pixel 6 emulator

Android

iOS 16 in Simulator

iOS

iOS 15 in Simulator (IosAlertOptions: alertStyle = IosAlertStyle.actionSheet)

iOS

macOS 12 Monterey

macOS

Windows 10 with MessageBox API

Windows

Windows 11 with TaskDialogIndirect API

Windows

Windows 11 with TaskDialogIndirect API that shows buttons as links

Windows

Ubuntu 21.10

linux

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트