Skip to content

Commit 1b055f4

Browse files
committed
Enhance theme example
1 parent 6e85407 commit 1b055f4

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

example/lib/pages/alert_page.dart

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:adaptive_dialog/adaptive_dialog.dart';
22
import 'package:example/router/router.dart';
33
import 'package:example/util/logger.dart';
4+
import 'package:flutter/cupertino.dart';
45
import 'package:flutter/material.dart';
56
import 'package:go_router/go_router.dart';
67

@@ -89,27 +90,6 @@ class AlertPage extends StatelessWidget {
8990
logger.info(result);
9091
},
9192
),
92-
ListTile(
93-
title: const Text('OK Dialog (Theme builder)'),
94-
onTap: () async {
95-
final result = await showOkAlertDialog(
96-
context: context,
97-
title: 'Title',
98-
message: 'This is message.',
99-
builder: (context, child) => Theme(
100-
data: ThemeData(
101-
textButtonTheme: TextButtonThemeData(
102-
style: TextButton.styleFrom(
103-
foregroundColor: Colors.orange,
104-
),
105-
),
106-
),
107-
child: child,
108-
),
109-
);
110-
logger.info(result);
111-
},
112-
),
11393
ListTile(
11494
title: const Text('OK/Cancel Dialog'),
11595
onTap: () async {
@@ -133,14 +113,31 @@ class AlertPage extends StatelessWidget {
133113
logger.info(result);
134114
},
135115
),
116+
const ListTile(
117+
title: Text('OK/Cancel Dialog (Destructive)'),
118+
),
136119
ListTile(
137-
title: const Text('OK/Cancel Dialog (Destructive)'),
120+
title: const Text('OK/Cancel Dialog (Theme builder)'),
138121
onTap: () async {
139122
final result = await showOkCancelAlertDialog(
140123
context: context,
141124
title: 'Title',
142125
message: 'This is message.',
143126
isDestructiveAction: true,
127+
builder: (context, child) => Theme(
128+
data: ThemeData(
129+
textButtonTheme: TextButtonThemeData(
130+
style: TextButton.styleFrom(
131+
foregroundColor: Colors.orange,
132+
),
133+
),
134+
// If this is commented out, the color for cupertino will be default blue/red.
135+
cupertinoOverrideTheme: const CupertinoThemeData(
136+
primaryColor: Colors.purple,
137+
),
138+
),
139+
child: child,
140+
),
144141
);
145142
logger.info(result);
146143
},

0 commit comments

Comments
 (0)