fluffychat/lib/widgets/adaptive_flat_button.dart

36 lines
835 B
Dart
Raw Permalink Normal View History

2020-12-05 13:03:57 +01:00
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
2021-10-26 18:50:34 +02:00
import 'package:fluffychat/utils/platform_infos.dart';
2020-12-05 13:03:57 +01:00
class AdaptiveFlatButton extends StatelessWidget {
2021-02-27 07:53:34 +01:00
final String label;
2021-11-19 20:38:16 +01:00
final Color? textColor;
final void Function()? onPressed;
2020-12-05 13:03:57 +01:00
const AdaptiveFlatButton({
2021-11-19 20:38:16 +01:00
Key? key,
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
}