{"id":13547936,"url":"https://github.com/zonble/flutter_platform_alert","last_synced_at":"2025-04-05T09:06:02.898Z","repository":{"id":43321402,"uuid":"429941655","full_name":"zonble/flutter_platform_alert","owner":"zonble","description":"Plays native alert sound and shows native dialogs/alerts in your Flutter app.","archived":false,"fork":false,"pushed_at":"2025-02-23T12:39:16.000Z","size":67834,"stargazers_count":77,"open_issues_count":5,"forks_count":18,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T08:05:11.998Z","etag":null,"topics":["flutter","flutter-desktop","flutter-plugin"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_platform_alert","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zonble.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"zonble"}},"created_at":"2021-11-19T21:42:22.000Z","updated_at":"2025-02-28T09:24:31.000Z","dependencies_parsed_at":"2024-01-18T18:25:37.612Z","dependency_job_id":"f3cf00d3-2653-4b7c-95c2-1f9ff983f8ee","html_url":"https://github.com/zonble/flutter_platform_alert","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2Fflutter_platform_alert","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2Fflutter_platform_alert/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2Fflutter_platform_alert/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zonble%2Fflutter_platform_alert/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zonble","download_url":"https://codeload.github.com/zonble/flutter_platform_alert/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247312077,"owners_count":20918344,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flutter","flutter-desktop","flutter-plugin"],"created_at":"2024-08-01T12:01:03.331Z","updated_at":"2025-04-05T09:06:02.839Z","avatar_url":"https://github.com/zonble.png","language":"C++","readme":"# flutter_platform_alert\n\n2021 and onwards © Weizhong Yang a.k.a zonble.\n\n[![Pub](https://img.shields.io/pub/v/flutter_platform_alert.svg)](https://pub.dartlang.org/packages/flutter_platform_alert) [![example workflow](https://github.com/zonble/flutter_platform_alert/actions/workflows/ci.yaml/badge.svg)](https://github.com/zonble/flutter_platform_alert/actions) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/zonble/flutter_platform_alert/blob/main/LICENSE)\n\nA simple plugin to present native alerts, including playing alert sounds and\nshowing alert dialogs on various platforms including iOS, Android, Windows,\nmacOS and Linux.\n\n![iOS](https://img.shields.io/badge/iOS-000000?style=for-the-badge\u0026logo=ios\u0026logoColor=white)\n![Android](https://img.shields.io/badge/Android-3DDC84?style=for-the-badge\u0026logo=android\u0026logoColor=white)\n![macOS](https://img.shields.io/badge/mac%20os-000000?style=for-the-badge\u0026logo=macos\u0026logoColor=F0F0F0)\n![Windows](https://img.shields.io/badge/Windows-0078D6?style=for-the-badge\u0026logo=windows\u0026logoColor=white)\n![Linux](https://img.shields.io/badge/Linux-FCC624?style=for-the-badge\u0026logo=linux\u0026logoColor=black)\n\nIt uses following API to show play alert sound.\n\n- iOS: [AudioService](https://developer.apple.com/documentation/audiotoolbox/1405248-audioservicesplaysystemsound)\n- Android: [RingtoneManager](https://developer.android.com/reference/android/media/RingtoneManager)\n- macOS: [NSSound](https://developer.apple.com/documentation/appkit/nssound/2903487-beep)\n- Windows: [MessageBeep](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebeep)\n- Linux: [gtk_widget_error_bell](https://docs.gtk.org/gtk3/method.Widget.error_bell.html)\n\nIt uses following API to show alert dialogs.\n\n- iOS: [UIAlertController](https://developer.apple.com/documentation/uikit/uialertcontroller) (It requires iOS 8)\n- Android: [AlertDialog](https://developer.android.com/reference/android/app/AlertDialog)\n- macOS: [NSAlert](https://developer.apple.com/documentation/appkit/nsalert)\n- Windows: [MessageBox](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox) and\n  [TaskDialogIndirect](https://docs.microsoft.com/en-us/windows/win32/api/commctrl/nf-commctrl-taskdialogindirect)\n- Linux: [GtkMessageDialog](https://docs.gtk.org/gtk3/class.MessageDialog.html)\n\nThe package was developed and tested on\n\n- iOS 15\n- Android 11\n- macOS 11 Big Sur and mac OS 12 Monterey / Xcode 13\n- Windows 10 / Visual Studio Community 2019\n- Ubuntu 21.10\n\n## Getting Started\n\n- Add the dependency to your pubspec.yaml file by `flutter pub add flutter_platform_alert`.\n- Run `flutter pub get`.\n\nTo play platform alert sound.\n\n```dart\nimport 'package:flutter_platform_alert/flutter_platform_alert.dart';\nawait FlutterPlatformAlert.playAlertSound();\n```\n\nTo show a platform alert dialog.\n\n```dart\nimport 'package:flutter_platform_alert/flutter_platform_alert.dart';\nawait FlutterPlatformAlert.playAlertSound();\n\nfinal clickedButton = await FlutterPlatformAlert.showAlert(\n    windowTitle: 'This ia title',\n    text: 'This is body',\n    alertStyle: AlertButtonStyle.yesNoCancel,\n    iconStyle: IconStyle.information,\n);\n```\n\nTo show an alert dialog with custom button titles:\n\n```dart\nimport 'package:flutter_platform_alert/flutter_platform_alert.dart';\nawait FlutterPlatformAlert.playAlertSound();\n\nfinal result = await FlutterPlatformAlert.showCustomAlert(\n  windowTitle: 'This is title',\n  text: 'This is body',\n  positiveButtonTitle: \"Positive\",\n  negativeButtonTitle: \"Negative\",\n  neutralButtonTitle: \"Neutral\",\n  options: PlatformAlertOptions(\n    windows: WindowsAlertOptions(\n      additionalWindowTitle: 'Window title',\n      showAsLinks: true,\n    ),\n  ),\n);\n```\n\n## Platform Alert Dialogs\n\n### Alert Styles\n\nWhen calling `showCustomAlert`, you can assign any button titles and use up to\nthree buttons. Once there is no button title specified, it falls back to only an\n\"OK\" button.\n\nWhen calling `showAlert`, you can specify the buttons listed in the alert dialog\nby passing `alertStyle` argument. The package follows the API design on Windows\n(see the reference of [MessageBox win32\nAPI](https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-messagebox)),\nand it provides following styles:\n\n- Abort, retry and ignore\n- Cancel, try again and continue\n- OK\n- OK and cancel\n- Retry and cancel\n- Yes and no\n- Yes, no, and cancel\n\nSince each platform has its own conventions, the order of these buttons are not\nguaranteed to be the same.\n\n### Icon Styles\n\nThe package also follow the API design of MessageBox on Windows to add icons to\nthe alert dialogs (see the link above). There are several different icons styles\nbut actually four:\n\n- No icon\n- Warning icon\n- Information icon\n- Question icon\n\nPlease note that these icons are not available on iOS and Android.\n\n### Themes/Dark or Light Mode\n\nOn iOS and macOS, the alert dialogs follows the dark/light mode settings on\nusers' system. On Linux, the alert dialogs are rendered with current GTK theme.\nOn Windows, they are always in light mode even you choose to use dark mode on\nWindows 10 and Windows 11.\n\nOn Android, the alert dialog uses the default theme of Material design\n(as Theme.Material.Dialog.Alert).\n\n## Localization\n\nSince the plugin calls native API, if you want to localize buttons like \"OK\",\n\"Cancel\" and so on on Platforms like iOS, macOS and Linux, you have to do some\nworks in your app.\n\n- To localize the button titles on iOS and macOS, add \"Localizable.strings\" or\n  \"Localizable.stringsdict\" files in your Xcode project. Visit Apple's official\n  page for [localization](https://developer.apple.com/localization) for further\n  information.\n- On Linux, we use [gettext](https://www.gnu.org/software/gettext/) to localize\n  apps. Please update the PO files in your projects once you integrate the\n  plugin.\n\nAndroid apps embeds resources for localized strings. The localized strings files\nfor the project are located under\n[android/src/main/res](https://github.com/zonble/flutter_platform_alert/tree/main/android/src/main/res).\nOnce you need to add new languages, just fork the project and put your files\nunder the folder.\n\nOn Windows, the buttons on the message boxes will be in the Windows system\nlanguage.\n\n## License\n\nThe package in released under MIT License.\n\n## Screenshots\n\nAndroid 13 on Pixel 6 emulator\n\n![Android](./screenshot_android.png)\n\niOS 16 in Simulator\n\n![iOS](./screenshot_ios.png)\n\niOS 15 in Simulator (IosAlertOptions: alertStyle = IosAlertStyle.actionSheet)\n\n![iOS](./screenshot_ios_sheet.png)\n\nmacOS 12 Monterey\n\n![macOS](./screenshot_macos.png)\n\nWindows 10 with MessageBox API\n\n![Windows](./screenshot_windows.png)\n\nWindows 11 with TaskDialogIndirect API\n\n![Windows](./screenshot_windows_11.png)\n\nWindows 11 with TaskDialogIndirect API that shows buttons as links\n\n![Windows](./screenshot_windows_11_links.png)\n\nUbuntu 21.10\n\n![linux](./screenshot_linux.png)","funding_links":["https://github.com/sponsors/zonble"],"categories":["C++","Packages"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonble%2Fflutter_platform_alert","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzonble%2Fflutter_platform_alert","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzonble%2Fflutter_platform_alert/lists"}