fluffychat/lib/views/widgets/adaptive_flat_button.dart

35 lines
825 B
Dart
Raw Normal View History

2020-12-05 12:03:57 +00: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 06:53:34 +00:00
final String label;
2020-12-05 12:03:57 +00:00
final Color textColor;
final Function onPressed;
const AdaptiveFlatButton({
Key key,
2021-02-27 06:53:34 +00:00
@required this.label,
2020-12-05 12:03:57 +00: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 11:28:06 +00:00
child: Text(label),
2020-12-05 12:03:57 +00:00
);
}
2021-02-27 06:53:34 +00:00
return TextButton(
2021-03-04 11:28:06 +00:00
onPressed: onPressed,
2021-02-27 06:53:34 +00:00
child: Text(
label,
style: TextStyle(color: textColor),
),
2020-12-05 12:03:57 +00:00
);
}
2020-12-08 14:55:42 +00:00
}