You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
fluffychat/lib/widgets/adaptive_dialogs/adaptive_dialog_action.dart

39 lines
951 B
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class AdaptiveDialogAction extends StatelessWidget {
final VoidCallback? onPressed;
final bool autofocus;
final Widget child;
const AdaptiveDialogAction({
super.key,
required this.onPressed,
required this.child,
this.autofocus = false,
});
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
switch (theme.platform) {
case TargetPlatform.android:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return TextButton(
onPressed: onPressed,
autofocus: autofocus,
child: child,
);
case TargetPlatform.iOS:
case TargetPlatform.macOS:
return CupertinoDialogAction(
onPressed: onPressed,
isDefaultAction: autofocus,
child: child,
);
}
}
}