Open
!13 merge br_3.27_dev into br_3.27 #14
zhoukc42Add on Aug 28
!13 merge br_3.27_dev into br_3.27 #14
Open
zhoukc42Add on Aug 28
Merged frombr_3.27_devintobr_3.27
Total: 10 files changed+580-74
@@ -0,0 +1,9 @@
1+## 0.0.3-ohos.1.0.0 - 2026.10
2+ 
3+- Fully rewrote the OpenHarmony README docs (EN/CN): overview, installation via git + ref with a Flutter 3.22–3.44 version mapping table, constraints and limitations, usage example and notes.
4+- Added `README.OpenSource.md` and this `CHANGELOG.OpenHarmony.md`.
5+- Updated `buildEnv.sh` to cover 5 Flutter SDK versions (3.22 / 3.27 / 3.35 / 3.41 / 3.44).
6+- Replaced the non-compiling template Calculator test with 3 widget tests covering the `showDialogAlert` API.
7+- No runtime code changes; public API signatures remain unchanged.
8+- Add integration tests for `example/integration_test`.
9+([#16](https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert/pull/16))
@@ -1,64 +1,126 @@
1-<p align="center">1+<p align="center"><h1 align="center"><code>dialog_alert</code></h1></p>
2- <h1 align="center"> <code>DialogAlert</code> </h1>
3-</p>
4 2 
5-This project is developed based on [DialogAlert](https://pub.dev/packages/dialog_alert).3+This project is developed based on [dialog_alert](https://github.com/mkarundas/DialogAlert).
6 4 
7-## 1. Installation and Usage5+## Overview
8 6 
9-### 1.1 Installation7+`dialog_alert` provides a Flutter API for displaying alert dialogs. The package selects a Material-style or Cupertino-style dialog according to the runtime platform, and supports a confirmation button, an optional cancel button, and button text styles.
10 8 
11-Navigate to the project directory and add the following dependency in pubspec.yaml:9+## Installation
12 10 
13-<!-- tabs:start -->11+Add the dependency to your project's `pubspec.yaml`:
14- 
15-#### pubspec.yaml
16 12 
17```yaml13```yaml
18-...
19- 
20dependencies:14dependencies:
21- DialogAlert:15+ dialog_alert:
22 git:16 git:
23- url: https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert17+ url: https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert.git
24- 18+ ref: TAG # Select a TAG from the TAG version mapping table below
25-...
26```19```
27 20 
28-Run the command21+Install the dependency:
29 22 
30```bash23```bash
31flutter pub get24flutter pub get
32```25```
33 26 
34-<!-- tabs:end -->27+| Flutter Framework Version | TAG Name | Branch |
28+|---|---|---|
29+| 3.22 | 0.0.3-ohos.1.0.0 | br_3.27 |
30+| 3.27 | 0.0.3-ohos.1.0.0 | br_3.27 |
31+| 3.35 | 0.0.3-ohos.1.0.0 | br_3.27 |
32+| 3.41 | 0.0.3-ohos.1.0.0 | br_3.27 |
33+| 3.44 | 0.0.3-ohos.1.0.0 | br_3.27 |
35 34 
36-### 1.2 Usage Example35+## Constraints and Limitations
37 36 
38-See [example](example/lib/main.dart) for usage details.37+### Compatibility
39 38 
40-## 2. Constraints and Limitations39+1. Flutter: 3.22.3-ohos-1.1.5, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
40+2. Flutter: 3.27.4-ohos-1.0.8, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
41+3. Flutter: 3.35.7-ohos-1.0.4, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
42+4. Flutter: 3.41.9-ohos-1.0.1, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
43+5. Flutter: 3.44.9+ohos-0.0.1-canary1, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
41 44 
42-### 2.1 Compatibility45+### Permissions
43 46 
44-Tested and passed on the following versions:47+None. The package only uses Flutter dialog widgets and does not require permissions in `module.json5`.
45 48 
46-1. Flutter: 3.22.1-ohos-1.0.6; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;49+## Usage Example
47-2. Flutter: 3.27.5-ohos-1.0.0; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;
48-3. Flutter: 3.35.7-ohos-0.0.1; SDK: 6.0.1(21); IDE: DevEco Studio: 6.0.1.260; ROM: 6.0.0.120 SP6;
49 50 
50-## 3. API51+```dart
52+import 'package:dialog_alert/dialog_alert.dart';
53+import 'package:flutter/material.dart';
51 54 
52- > [!TIP] The "ohos Support" column with "yes" indicates the property is supported on the ohos platform; "no" means not supported; "partially" means partially supported.55+class AlertPage extends StatelessWidget {
56+ const AlertPage({super.key});
53 57 
54-| Name | Description | Type | Input | Output | ohos Support |58+ @override
55-|---|---|---|---|---|---|59+ Widget build(BuildContext context) {
56-| showDialogAlert | Display dialog box warning message | function | none | Future<String?> | yes |60+ return ElevatedButton(
61+ onPressed: () async {
62+ // Wait for the user's confirmation or cancellation result.
63+ final ButtonActionType? result = await showDialogAlert(
64+ context: context,
65+ title: 'Upload avatar',
66+ message: 'Upload a new avatar?',
67+ actionButtonTitle: 'Upload',
68+ cancelButtonTitle: 'Cancel',
69+ );
70+ if (!context.mounted) {
71+ return;
72+ }
73+ final String resultText = result == ButtonActionType.action
74+ ? 'Confirmed'
75+ : 'Canceled or dismissed';
76+ ScaffoldMessenger.of(context).showSnackBar(
77+ SnackBar(content: Text(resultText)),
78+ );
79+ },
80+ child: const Text('Show dialog'),
81+ );
82+ }
83+}
84+```
57 85 
58-## 4. Known Issues86+See [example/lib/main.dart](example/lib/main.dart) for the complete example.
59 87 
60-None88+## Usage Notes
61 89 
62-## 5. License90+- `showDialogAlert` requires the current page's `BuildContext`, a title, a message, and a confirmation button title.
91+- Set `cancelButtonTitle` to display a cancel button. Without it, only the confirmation button is displayed.
92+- Use `actionButtonTextStyle` and `cancelButtonTextStyle` to set the confirmation and cancel button text styles.
93+- The dialog returns `ButtonActionType.action`, `ButtonActionType.cancel`, or `null`. Dismissing the dialog with the system back action returns `null`.
94+- On OpenHarmony, `Platform.isIOS` is `false`, so the package uses Material `AlertDialog` and `TextButton`.
63 95 
64-This project is licensed under [The MIT License](LICENSE), please feel free to enjoy and participate in open source.96+## API Reference
97+ 
98+### API
99+ 
100+| Name | Description | Type | Parameter Types | Return Value | Required | OpenHarmony Support |
101+|---|---|---|---|---|---|---|
102+| `showDialogAlert` | Displays an alert dialog and returns the user's action | Method | `BuildContext context`, `String title`, `String message`, `String actionButtonTitle`, `String? cancelButtonTitle`, `TextStyle? actionButtonTextStyle`, `TextStyle? cancelButtonTextStyle` | `Future<ButtonActionType?>` | Yes | Yes |
103+| `ButtonActionType.action` | Indicates that the confirmation button was pressed | Enum value | None | `ButtonActionType` | No | Yes |
104+| `ButtonActionType.cancel` | Indicates that the cancel button was pressed | Enum value | None | `ButtonActionType` | No | Yes |
105+ 
106+## Known Issues
107+ 
108+The upstream package uses a Cupertino dialog on iOS and a Material dialog on other platforms. OpenHarmony currently uses the Material branch and does not provide a Cupertino-style dialog.
109+ 
110+## Directory Structure
111+ 
112+| Path | Description |
113+|---|---|
114+| `lib/dialog_alert.dart` | Public library export entry point. |
115+| `lib/src/show_dialog_alert.dart` | Implementation of the dialog API and `ButtonActionType`. |
116+| `lib/src/dialog_alert_button.dart` | Dialog button implementation. |
117+| `example/` | Flutter example project. |
118+| `test/` | Dart and Flutter test files. |
119+ 
120+## Contributing
121+ 
122+If you find any issues during use, feel free to submit an [Issue](https://gitcode.com/fluttertpc_DialogAlert/issues). Contributions via [PR](https://gitcode.com/fluttertpc_DialogAlert/pulls) are also very welcome.
cpf-manager

【AI-Review】【一般】【基础代码问题】【其他基础代码问题】贡献入口链接缺少组织前缀导致 404

● 问题:README.OpenHarmony.md 第 119 行的 Issue 和 PR 链接 https://gitcode.com/fluttertpc_DialogAlert/issues 与 https://gitcode.com/fluttertpc_DialogAlert/pulls 均缺少组织前缀 CPF-Flutter/。通过 HTTP 请求验证两个 URL 均返回 404 Not Found。

● 影响:一般。用户点击 Issue 链接报告问题或点击 PR 链接参与贡献时会跳转到 404 页面,无法正常使用反馈和贡献入口。

● 建议:将链接修改为 https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert/issues 与 https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert/pulls。

likedislike
123+ 
124+## License
125+ 
126+This project is licensed under the [MIT License](https://github.com/mkarundas/DialogAlert/blob/main/LICENSE), please feel free to enjoy and participate in open source.
@@ -1,62 +1,126 @@
1-# DialogAlert1+<p align="center"><h1 align="center"><code>dialog_alert</code></h1></p>
2 2 
3-本项目基于 [DialogAlert](https://pub.dev/packages/dialog_alert) 开发。3+本项目基于 [dialog_alert](https://github.com/mkarundas/DialogAlert) 开发。
4 4 
5-## 1. 安装与使用5+## 简介
6 6 
7-### 1.1 安装方式7+`dialog_alert` 提供用于显示提示对话框的 Flutter API。组件根据运行平台选择 Material 风格或 Cupertino 风格的对话框,并支持确认按钮、可选取消按钮和按钮文本样式。
8 8 
9-进入到工程目录并在 `pubspec.yaml` 中添加以下依赖:9+## 下载安装
10 10 
11-<!-- tabs:start -->11+在工程的 `pubspec.yaml` 中添加依赖:
12- 
13-#### pubspec.yaml
14 12 
15```yaml13```yaml
16-...
17- 
18dependencies:14dependencies:
19- DialogAlert:15+ dialog_alert:
20 git:16 git:
21- url: https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert17+ url: https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert.git
22- 18+ ref: TAG # 根据下方表格选择不同框架适配的TAG版本
23-...
24```19```
25 20 
26-执行命令21+执行依赖安装命令:
27 22 
28```bash23```bash
29flutter pub get24flutter pub get
30```25```
31 26 
32-<!-- tabs:end -->27+| Flutter 框架版本 | TAG 名称 | 分支名 |
28+|---|---|---|
29+| 3.22 | 0.0.3-ohos.1.0.0 | br_3.27 |
30+| 3.27 | 0.0.3-ohos.1.0.0 | br_3.27 |
31+| 3.35 | 0.0.3-ohos.1.0.0 | br_3.27 |
32+| 3.41 | 0.0.3-ohos.1.0.0 | br_3.27 |
33+| 3.44 | 0.0.3-ohos.1.0.0 | br_3.27 |
33 34 
34-### 1.2 使用案例35+## 约束与限制
35 36 
36-使用案例详见 [example](example/lib/main.dart)37+### 兼容性
37 38 
38-## 2. 约束与限制39+1. Flutter: 3.22.3-ohos-1.1.5, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
40+2. Flutter: 3.27.4-ohos-1.0.8, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
41+3. Flutter: 3.35.7-ohos-1.0.4, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
42+4. Flutter: 3.41.9-ohos-1.0.1, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
43+5. Flutter: 3.44.9+ohos-0.0.1-canary1, SDK: 5.0.5(17); IDE: DevEco Studio: 26.0.0.621, ROM: 6.1.0.135 SP8;
39 44 
40-### 2.1 兼容性45+### 权限要求
41 46 
42-在以下版本中已测试通过:47+无。该库仅调用 Flutter 对话框组件,不需要在 `module.json5` 中声明权限。
43 48 
44-1. Flutter: 3.22.1-ohos-1.0.6; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;49+## 使用示例
45-2. Flutter: 3.27.5-ohos-1.0.0; SDK: 5.0.0(12); IDE: DevEco Studio: 6.0.1.251; ROM: 6.0.0.115 SP16;
46-3. Flutter: 3.35.7-ohos-0.0.1; SDK: 6.0.1(21); IDE: DevEco Studio: 6.0.1.260; ROM: 6.0.0.120 SP6;
47 50 
48-## 3. API51+```dart
52+import 'package:dialog_alert/dialog_alert.dart';
53+import 'package:flutter/material.dart';
49 54 
50-> [!TIP] "ohos Support"列为 yes 表示 ohos 平台支持该属性;no 则表示不支持;partially 表示部分支持。55+class AlertPage extends StatelessWidget {
56+ const AlertPage({super.key});
51 57 
52-| 接口名 | 描述 | 类型 | 输入信息 | 输出信息 | ohos是否支持 |58+ @override
53-|---|---|---|---|---|---|59+ Widget build(BuildContext context) {
54-| showDialogAlert | 显示原生对话框 | function | 无 | Future<String?> | 是 |60+ return ElevatedButton(
61+ onPressed: () async {
62+ // 等待用户选择确认或取消,并处理返回结果。
63+ final ButtonActionType? result = await showDialogAlert(
64+ context: context,
65+ title: '上传头像',
66+ message: '是否上传新的头像?',
67+ actionButtonTitle: '上传',
68+ cancelButtonTitle: '取消',
69+ );
70+ if (!context.mounted) {
71+ return;
72+ }
73+ final String resultText = result == ButtonActionType.action
74+ ? '已确认'
75+ : '已取消或关闭对话框';
76+ ScaffoldMessenger.of(context).showSnackBar(
77+ SnackBar(content: Text(resultText)),
78+ );
79+ },
80+ child: const Text('显示对话框'),
81+ );
82+ }
83+}
84+```
55 85 
56-## 4. 遗留问题86+完整示例见 [example/lib/main.dart](example/lib/main.dart)。
57 87 
58-无88+## 使用说明
59 89 
60-## 5. 开源协议90+- `showDialogAlert` 要求传入当前页面的 `BuildContext`、标题、消息和确认按钮标题。
91+- 设置 `cancelButtonTitle` 后显示取消按钮;未设置时只显示确认按钮。
92+- `actionButtonTextStyle` 和 `cancelButtonTextStyle` 分别设置确认按钮和取消按钮的文本样式。
93+- 对话框关闭后返回 `ButtonActionType.action`、`ButtonActionType.cancel` 或 `null`。用户通过系统返回操作关闭对话框时返回 `null`。
94+- 在 OpenHarmony 上 `Platform.isIOS` 为 `false`,因此使用 Material `AlertDialog` 和 `TextButton`。
61 95 
62-本项目基于 [The MIT License](LICENSE),请自由地享受和参与开源。96+## 接口说明
97+ 
98+### API
99+ 
100+| 名称 | 描述 | 类型 | 参数类型 | 返回值 | 必填 | OpenHarmony平台支持 |
101+|---|---|---|---|---|---|---|
102+| `showDialogAlert` | 显示提示对话框并返回用户操作结果 | 方法 | `BuildContext context`、`String title`、`String message`、`String actionButtonTitle`、`String? cancelButtonTitle`、`TextStyle? actionButtonTextStyle`、`TextStyle? cancelButtonTextStyle` | `Future<ButtonActionType?>` | 是 | 是 |
103+| `ButtonActionType.action` | 表示用户点击确认按钮 | 枚举值 | 无 | `ButtonActionType` | 否 | 是 |
104+| `ButtonActionType.cancel` | 表示用户点击取消按钮 | 枚举值 | 无 | `ButtonActionType` | 否 | 是 |
105+ 
106+## 遗留问题
107+ 
108+原库针对 iOS 使用 Cupertino 对话框,针对其他平台使用 Material 对话框。OpenHarmony 当前走 Material 分支,不提供 Cupertino 风格对话框。
109+ 
110+## 目录结构
111+ 
112+| 路径 | 说明 |
113+|---|---|
114+| `lib/dialog_alert.dart` | 库的公开导出入口。 |
115+| `lib/src/show_dialog_alert.dart` | 对话框 API 和 `ButtonActionType` 的实现。 |
116+| `lib/src/dialog_alert_button.dart` | 对话框按钮组件实现。 |
117+| `example/` | Flutter 示例工程。 |
118+| `test/` | Dart 和 Flutter 测试文件。 |
119+ 
120+## 贡献代码
121+ 
122+使用过程中发现任何问题都可以提 [Issue](https://gitcode.com/fluttertpc_DialogAlert/issues) ,当然,也非常欢迎发 [PR](https://gitcode.com/fluttertpc_DialogAlert/pulls) 共建。
cpf-manager

【AI-Review】【一般】【基础代码问题】【其他基础代码问题】贡献入口链接缺少组织前缀导致 404

● 问题:README.OpenHarmony_CN.md 第 119 行的 Issue 和 PR 链接 https://gitcode.com/fluttertpc_DialogAlert/issues 与 https://gitcode.com/fluttertpc_DialogAlert/pulls 均缺少组织前缀 CPF-Flutter/。通过 HTTP 请求验证两个 URL 均返回 404 Not Found。

● 影响:一般。用户点击 Issue 链接报告问题或点击 PR 链接参与贡献时会跳转到 404 页面,无法正常使用反馈和贡献入口。

● 建议:将链接修改为 https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert/issues 与 https://gitcode.com/CPF-Flutter/fluttertpc_DialogAlert/pulls。

likedislike
123+ 
124+## 开源协议
125+ 
126+本项目基于 [MIT License](https://github.com/mkarundas/DialogAlert/blob/main/LICENSE) ,请自由地享受和参与开源。
@@ -0,0 +1,11 @@
1+[
2+ {
3+ "Name": "dialog_alert",
4+ "License": "MIT",
5+ "License File": "LICENSE",
6+ "Version Number": "0.0.3",
7+ "Owner": "panjinling@huawei.com",
8+ "Upstream URL": "https://github.com/mkarundas/DialogAlert",
9+ "Description": "A new Flutter package for showing native alert view."
10+ }
11+]
@@ -11,4 +11,4 @@
11# limitations under the License.11# limitations under the License.
12 12 
13BUILD_PKG_DIR=example13BUILD_PKG_DIR=example
14-FLUTTER_SDK_VERSION=oh-3.35.7-dev14+FLUTTER_SDK_VERSION=("oh-3.22.3-release" "oh-3.27.0-release" "oh-3.35.7-release" "oh-3.41.9-release" "oh-3.44.9-dev")
@@ -0,0 +1,89 @@
1+/*
2+ * Copyright (C) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+part of 'main_test.dart';
17+ 
18+/// Integration cases for DialogAlertButton fields: onPressed, title,
19+/// isDestructiveAction, isDefaultAction and textStyle.
20+/// On OHOS (Platform.isIOS == false) the button renders as a TextButton.
21+void registerDialogAlertButtonCases() {
22+ testWidgets('DialogAlertButton exposes all public fields and renders '
23+ 'title with textStyle on OHOS', (WidgetTester tester) async {
24+ var pressedCount = 0;
25+ const TextStyle buttonStyle = TextStyle(
26+ color: Colors.deepPurple,
27+ fontSize: 18.0,
28+ );
29+ final DialogAlertButton button = DialogAlertButton(
30+ onPressed: () {
31+ pressedCount++;
32+ },
33+ title: 'FieldTitle',
34+ isDestructiveAction: true,
35+ isDefaultAction: true,
36+ textStyle: buttonStyle,
37+ );
38+ 
39+ expect(button.onPressed, isNotNull);
40+ expect(button.title, 'FieldTitle');
41+ expect(button.isDestructiveAction, isTrue);
42+ expect(button.isDefaultAction, isTrue);
43+ expect(button.textStyle, buttonStyle);
44+ 
45+ await tester.pumpWidget(MaterialApp(
46+ home: Scaffold(
47+ body: Center(child: button),
48+ ),
49+ ));
50+ 
51+ // OHOS is not iOS: the Material branch is used.
52+ expect(find.byType(TextButton), findsOneWidget);
53+ expect(find.byType(CupertinoDialogAction), findsNothing);
54+ 
55+ final Text rendered = tester.widget<Text>(find.text('FieldTitle'));
56+ expect(rendered.style, buttonStyle);
57+ 
58+ await tester.tap(find.text('FieldTitle'));
59+ await tester.pumpAndSettle();
60+ expect(pressedCount, 1);
61+ });
62+ 
63+ testWidgets('DialogAlertButton keeps default flag values and fires '
64+ 'onPressed on every tap', (WidgetTester tester) async {
65+ var pressedCount = 0;
66+ final DialogAlertButton button = DialogAlertButton(
67+ onPressed: () {
68+ pressedCount++;
69+ },
70+ title: 'PlainTitle',
71+ );
72+ 
73+ expect(button.isDestructiveAction, isFalse);
74+ expect(button.isDefaultAction, isFalse);
75+ expect(button.textStyle, isNull);
76+ 
77+ await tester.pumpWidget(MaterialApp(
78+ home: Scaffold(
79+ body: Center(child: button),
80+ ),
81+ ));
82+ 
83+ await tester.tap(find.text('PlainTitle'));
84+ await tester.pumpAndSettle();
85+ await tester.tap(find.text('PlainTitle'));
86+ await tester.pumpAndSettle();
87+ expect(pressedCount, 2);
88+ });
89+}
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+import 'package:dialog_alert/dialog_alert.dart';
17+import 'package:dialog_alert/src/dialog_alert_button.dart';
18+import 'package:flutter/cupertino.dart';
19+import 'package:flutter/material.dart';
20+import 'package:flutter_test/flutter_test.dart';
21+import 'package:integration_test/integration_test.dart';
22+ 
23+part 'dialog_alert_button_cases.dart';
24+part 'show_dialog_alert_cases.dart';
25+ 
26+void main() {
27+ final IntegrationTestWidgetsFlutterBinding binding =
28+ IntegrationTestWidgetsFlutterBinding.ensureInitialized();
29+ // OHOS corpus whitelist: these cases run on the ohos real device.
30+ binding.defaultTestTimeout = const Timeout(Duration(minutes: 2));
31+ 
32+ registerShowDialogAlertCases();
33+ registerDialogAlertButtonCases();
34+}
@@ -0,0 +1,150 @@
1+/*
2+ * Copyright (C) 2026 Huawei Device Co., Ltd.
3+ * Licensed under the Apache License, Version 2.0 (the "License");
4+ * you may not use this file except in compliance with the License.
5+ * You may obtain a copy of the License at
6+ *
7+ * http://www.apache.org/licenses/LICENSE-2.0
8+ *
9+ * Unless required by applicable law or agreed to in writing, software
10+ * distributed under the License is distributed on an "AS IS" BASIS,
11+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ * See the License for the specific language governing permissions and
13+ * limitations under the License.
14+ */
15+ 
16+part of 'main_test.dart';
17+ 
18+/// Integration cases for the public entry `showDialogAlert` from
19+/// package:dialog_alert/dialog_alert.dart. All of them run unattended on the
20+/// OHOS device: the alert is a Flutter dialog, no system sheet is involved.
21+void registerShowDialogAlertCases() {
22+ testWidgets('showDialogAlert shows AlertDialog and returns '
23+ 'ButtonActionType.action when action tapped', (WidgetTester tester) async {
24+ ButtonActionType? result;
25+ await tester.pumpWidget(MaterialApp(
26+ home: Builder(
27+ builder: (BuildContext context) => Scaffold(
28+ body: Center(
29+ child: ElevatedButton(
30+ onPressed: () async {
31+ result = await showDialogAlert(
32+ context: context,
33+ title: 'Integration Title',
34+ message: 'You have successfully updated your profile.',
35+ actionButtonTitle: 'OK',
36+ );
37+ },
38+ child: const Text('open simple'),
39+ ),
40+ ),
41+ ),
42+ ),
43+ ));
44+ 
45+ await tester.tap(find.text('open simple'));
46+ await tester.pumpAndSettle();
47+ 
48+ expect(find.text('Integration Title'), findsOneWidget);
49+ expect(find.text('You have successfully updated your profile.'),
50+ findsOneWidget);
51+ expect(find.text('OK'), findsOneWidget);
52+ 
53+ await tester.tap(find.text('OK'));
54+ await tester.pumpAndSettle();
55+ 
56+ expect(result, ButtonActionType.action);
57+ expect(find.text('Integration Title'), findsNothing);
58+ });
59+ 
60+ testWidgets('showDialogAlert returns ButtonActionType.cancel when '
61+ 'cancel button tapped', (WidgetTester tester) async {
62+ ButtonActionType? result;
63+ await tester.pumpWidget(MaterialApp(
64+ home: Builder(
65+ builder: (BuildContext context) => Scaffold(
66+ body: Center(
67+ child: ElevatedButton(
68+ onPressed: () async {
69+ result = await showDialogAlert(
70+ context: context,
71+ title: 'Message',
72+ message: 'Do you want to upload your profile picture?',
73+ actionButtonTitle: 'Upload',
74+ cancelButtonTitle: 'Cancel',
75+ );
76+ },
77+ child: const Text('open cancel'),
78+ ),
79+ ),
80+ ),
81+ ),
82+ ));
83+ 
84+ await tester.tap(find.text('open cancel'));
85+ await tester.pumpAndSettle();
86+ 
87+ expect(find.text('Do you want to upload your profile picture?'),
88+ findsOneWidget);
89+ expect(find.text('Upload'), findsOneWidget);
90+ expect(find.text('Cancel'), findsOneWidget);
91+ 
92+ await tester.tap(find.text('Cancel'));
93+ await tester.pumpAndSettle();
94+ 
95+ expect(result, ButtonActionType.cancel);
96+ });
97+ 
98+ testWidgets('showDialogAlert applies actionButtonTextStyle and '
99+ 'cancelButtonTextStyle', (WidgetTester tester) async {
100+ ButtonActionType? result;
101+ const TextStyle actionStyle = TextStyle(
102+ color: Colors.green,
103+ fontSize: 20.0,
104+ fontWeight: FontWeight.bold,
105+ );
106+ const TextStyle cancelStyle = TextStyle(
107+ color: Colors.pink,
108+ fontSize: 16.0,
109+ );
110+ await tester.pumpWidget(MaterialApp(
111+ home: Builder(
112+ builder: (BuildContext context) => Scaffold(
113+ body: Center(
114+ child: ElevatedButton(
115+ onPressed: () async {
116+ result = await showDialogAlert(
117+ context: context,
118+ title: 'Styled Title',
119+ message: 'You have successfully uploaded',
120+ actionButtonTitle: 'Submit',
121+ cancelButtonTitle: 'Cancel',
122+ actionButtonTextStyle: actionStyle,
123+ cancelButtonTextStyle: cancelStyle,
124+ );
125+ },
126+ child: const Text('open styled'),
127+ ),
128+ ),
129+ ),
130+ ),
131+ ));
132+ 
133+ await tester.tap(find.text('open styled'));
134+ await tester.pumpAndSettle();
135+ 
136+ final Text actionText = tester.widget<Text>(find.text('Submit'));
137+ expect(actionText.style?.color, Colors.green);
138+ expect(actionText.style?.fontSize, 20.0);
139+ expect(actionText.style?.fontWeight, FontWeight.bold);
140+ 
141+ final Text cancelText = tester.widget<Text>(find.text('Cancel'));
142+ expect(cancelText.style?.color, Colors.pink);
143+ expect(cancelText.style?.fontSize, 16.0);
144+ 
145+ await tester.tap(find.text('Submit'));
146+ await tester.pumpAndSettle();
147+ 
148+ expect(result, ButtonActionType.action);
149+ });
150+}
@@ -20,6 +20,8 @@ dependencies:
20dev_dependencies:20dev_dependencies:
21 flutter_test:21 flutter_test:
22 sdk: flutter22 sdk: flutter
23+ integration_test:
24+ sdk: flutter
23 flutter_lints: ^1.0.025 flutter_lints: ^1.0.0
24 26 
25# For information on the generic Dart part of this file, see the27# For information on the generic Dart part of this file, see the
@@ -1,12 +1,97 @@
1+import 'package:flutter/material.dart';
1import 'package:flutter_test/flutter_test.dart';2import 'package:flutter_test/flutter_test.dart';
2 3 
3import 'package:dialog_alert/dialog_alert.dart';4import 'package:dialog_alert/dialog_alert.dart';
4 5 
5void main() {6void main() {
6- test('adds one to input values', () {7+ testWidgets('showDialogAlert shows AlertDialog without cancel button',
7- final calculator = Calculator();8+ (WidgetTester tester) async {
8- expect(calculator.addOne(2), 3);9+ await tester.pumpWidget(MaterialApp(
9- expect(calculator.addOne(-7), -6);10+ home: Builder(
10- expect(calculator.addOne(0), 1);11+ builder: (context) => ElevatedButton(
12+ onPressed: () => showDialogAlert(
13+ context: context,
14+ title: 'Title',
15+ message: 'Message',
16+ actionButtonTitle: 'OK',
17+ ),
18+ child: const Text('show'),
19+ ),
20+ ),
21+ ));
22+ 
23+ await tester.tap(find.text('show'));
24+ await tester.pumpAndSettle();
25+ 
26+ expect(find.byType(AlertDialog), findsOneWidget);
27+ expect(find.text('Title'), findsOneWidget);
28+ expect(find.text('Message'), findsOneWidget);
29+ expect(find.text('OK'), findsOneWidget);
30+ // 未传 cancelButtonTitle 时只应有一个按钮
31+ expect(find.byType(TextButton), findsOneWidget);
32+ });
33+ 
34+ testWidgets('tapping action button pops with ButtonActionType.action',
35+ (WidgetTester tester) async {
36+ ButtonActionType? result;
37+ 
38+ await tester.pumpWidget(MaterialApp(
39+ home: Builder(
40+ builder: (context) => ElevatedButton(
41+ onPressed: () async {
42+ result = await showDialogAlert(
43+ context: context,
44+ title: 'Title',
45+ message: 'Message',
46+ actionButtonTitle: 'OK',
47+ );
48+ },
49+ child: const Text('show'),
50+ ),
51+ ),
52+ ));
53+ 
54+ await tester.tap(find.text('show'));
55+ await tester.pumpAndSettle();
56+ 
57+ await tester.tap(find.text('OK'));
58+ await tester.pumpAndSettle();
59+ 
60+ expect(result, ButtonActionType.action);
61+ });
62+ 
63+ testWidgets(
64+ 'tapping cancel button pops with ButtonActionType.cancel',
65+ (WidgetTester tester) async {
66+ ButtonActionType? result;
67+ 
68+ await tester.pumpWidget(MaterialApp(
69+ home: Builder(
70+ builder: (context) => ElevatedButton(
71+ onPressed: () async {
72+ result = await showDialogAlert(
73+ context: context,
74+ title: 'Title',
75+ message: 'Message',
76+ actionButtonTitle: 'OK',
77+ cancelButtonTitle: 'Cancel',
78+ );
79+ },
80+ child: const Text('show'),
81+ ),
82+ ),
83+ ));
84+ 
85+ await tester.tap(find.text('show'));
86+ await tester.pumpAndSettle();
87+ 
88+ // 传入 cancelButtonTitle 时应有两个按钮,取消按钮在前
89+ expect(find.byType(TextButton), findsNWidgets(2));
90+ expect(find.text('Cancel'), findsOneWidget);
91+ 
92+ await tester.tap(find.text('Cancel'));
93+ await tester.pumpAndSettle();
94+ 
95+ expect(result, ButtonActionType.cancel);
11 });96 });
12}97}