mobile_nebula/lib/components/DangerButton.dart
Caleb Jasik ed348ab126
Flutter formatting changes (#252)
* `flutter fmt lib/`

* Re-enable formatting in CI
2025-02-13 15:37:44 -06:00

36 lines
1 KiB
Dart

import 'dart:io';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class DangerButton extends StatelessWidget {
const DangerButton({Key? key, required this.child, this.onPressed}) : super(key: key);
final Widget child;
final GestureTapCallback? onPressed;
@override
Widget build(BuildContext context) {
if (Platform.isAndroid) {
return FilledButton(
onPressed: onPressed,
child: child,
style: FilledButton.styleFrom(
backgroundColor: Theme.of(context).colorScheme.error,
foregroundColor: Theme.of(context).colorScheme.onError,
),
);
} else {
// Workaround for https://github.com/flutter/flutter/issues/161590
final themeData = CupertinoTheme.of(context);
return CupertinoTheme(
data: themeData.copyWith(primaryColor: CupertinoColors.white),
child: CupertinoButton(
child: child,
onPressed: onPressed,
color: CupertinoColors.systemRed.resolveFrom(context),
),
);
}
}
}