fluffychat/lib/components/dialogs/adaptive_flat_button.dart

35 lines
825 B
Dart
Raw Normal View History

2020-12-05 13:03:57 +01:00
import 'package:fluffychat/utils/platform_infos.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AdaptiveFlatButton extends StatelessWidget {
2021-02-27 07:53:34 +01:00
final String label;
2020-12-05 13:03:57 +01:00
final Color textColor;
final Function onPressed;
const AdaptiveFlatButton({
Key key,
2021-02-27 07:53:34 +01:00
@required this.label,
2020-12-05 13:03:57 +01:00
this.textColor,
this.onPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
if (PlatformInfos.isCupertinoStyle) {
return CupertinoDialogAction(
onPressed: onPressed,
textStyle: textColor != null ? TextStyle(color: textColor) : null,
2021-03-04 12:28:06 +01:00
child: Text(label),
2020-12-05 13:03:57 +01:00
);
}
2021-02-27 07:53:34 +01:00
return TextButton(
2021-03-04 12:28:06 +01:00
onPressed: onPressed,
2021-02-27 07:53:34 +01:00
child: Text(
label,
style: TextStyle(color: textColor),
),
2020-12-05 13:03:57 +01:00
);
}
2020-12-08 15:55:42 +01:00
}