time_progress_tracker/lib/ui/buttons/date_picker_btn.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

37 lines
979 B
Dart

import 'package:flutter/material.dart';
class DatePickerBtn extends StatelessWidget {
final String leadingString;
final DateTime pickedDate;
final void Function(DateTime) onDatePicked;
DatePickerBtn({
required this.leadingString,
required this.pickedDate,
required this.onDatePicked,
}) : super();
void _onButtonPressed(BuildContext context) async {
onDatePicked((await showDatePicker(
context: context,
initialDate: pickedDate,
firstDate: DateTime(1900),
lastDate: DateTime(2100),
))!);
}
@override
Widget build(BuildContext context) {
ThemeData appTheme = Theme.of(context);
return TextButton(
onPressed: () => _onButtonPressed(context),
child: Text(
"$leadingString ${pickedDate.toLocal().toString().split(" ")[0]}"),
style: TextButton.styleFrom(
primary: appTheme.primaryTextTheme.button!.color,
backgroundColor: appTheme.accentColor,
),
);
}
}