time_progress_tracker/lib/ui/buttons/platform_action_button.dart
Andreas Fahrecker 08db53db20 Updated Flutter SDK for Null-Safety
Ported Progress Detail Screen to PlatformScaffold

Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
2021-03-18 18:34:29 +01:00

45 lines
1.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
import 'package:time_progress_tracker/utils/helper_functions.dart';
class PlatformActionButton extends StatelessWidget {
final String heroTag;
final IconData icon;
final Color? materialBackground;
final void Function()? onBtnPressed;
const PlatformActionButton({
Key? key,
required this.heroTag,
required this.icon,
this.materialBackground,
required this.onBtnPressed,
}) : super(key: key);
@override
Widget build(BuildContext context) {
Widget _renderCupertino() {
return PlatformButton(
padding: EdgeInsets.all(4),
child: Icon(
icon,
color: Colors.white,
),
onPressed: onBtnPressed,
);
}
Widget _renderMaterial() {
return FloatingActionButton(
heroTag: heroTag,
child: Icon(icon),
backgroundColor: materialBackground,
onPressed: onBtnPressed,
);
}
return useCupertino() ? _renderCupertino() : _renderMaterial();
}
}