Skip to content

Commit 1775008

Browse files
committed
perf(dialog): dialog button colors can be customized
1 parent aeb0895 commit 1775008

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

lib/dialog.dart

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import 'package:flutter/material.dart';
22
import 'package:flutter/cupertino.dart';
33

4+
class DialogBtnColor {
5+
static const Color btnDefault = const Color(0xff353535);
6+
static const Color btnPrimary = const Color(0xff09bb07);
7+
}
8+
49
class DialogActions {
5-
DialogActions({this.text, this.onPressed});
10+
DialogActions({this.text, this.onPressed, this.color = DialogBtnColor.btnPrimary});
611
final String text;
712
final VoidCallback onPressed;
13+
final Color color;
814
}
915

1016
class _AndroidDialog extends StatelessWidget {
@@ -25,7 +31,10 @@ class _AndroidDialog extends StatelessWidget {
2531
),
2632
actions: actions
2733
.map((action) => FlatButton(
28-
child: Text(action.text),
34+
child: Text(
35+
action.text,
36+
style: TextStyle(color: action.color),
37+
),
2938
highlightColor: Color(0xFFDEDEDE),
3039
onPressed: () {
3140
Navigator.pop(context);
@@ -51,7 +60,10 @@ class _IosDialog extends StatelessWidget {
5160
actions: actions
5261
.map(
5362
(action) => CupertinoDialogAction(
54-
child: Text(action.text),
63+
child: Text(
64+
action.text,
65+
style: TextStyle(color: action.color),
66+
),
5567
isDefaultAction: true,
5668
onPressed: () {
5769
Navigator.pop(context);

0 commit comments

Comments
 (0)