Skip to content

Instantly share code, notes, and snippets.

@lsgd
Created July 22, 2024 20:40
Show Gist options
  • Save lsgd/cbdaffc73727a6e1cc7fc982dc9e29a5 to your computer and use it in GitHub Desktop.
Save lsgd/cbdaffc73727a6e1cc7fc982dc9e29a5 to your computer and use it in GitHub Desktop.
Display the current month and day in a calendar box
import 'package:flutter/material.dart';
class CalendarDateBox extends StatelessWidget {
CalendarDateBox({
super.key,
required this.month,
required this.day,
});
final String month;
final String day;
final Color boxColor = Colors.grey[800]!;
final double boxWidth = 50;
final Color monthTextColor = Colors.white;
final double monthFontSize = 14;
final double dayFontSize = 20;
@override
Widget build(BuildContext context) {
return Table(
columnWidths: {
0: FixedColumnWidth(boxWidth),
},
border: TableBorder.all(width: 0, style: BorderStyle.none),
children: [
TableRow(
children: [
Container(
decoration: BoxDecoration(
color: boxColor,
border: Border.all(
color: boxColor,
width: 1,
),
borderRadius: const BorderRadius.only(
topRight: Radius.circular(6.0),
topLeft: Radius.circular(6.0),
),
),
child: Text(
month,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: monthFontSize,
fontWeight: FontWeight.bold,
color: monthTextColor,
),
),
),
],
),
TableRow(
children: [
Container(
decoration: BoxDecoration(
border: Border(
top: BorderSide.none,
left: BorderSide(color: boxColor, width: 1),
right: BorderSide(color: boxColor, width: 1),
bottom: BorderSide(color: boxColor, width: 1),
),
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(2.0),
bottomRight: Radius.circular(2.0),
),
),
child: Text(day,
textAlign: TextAlign.center,
style: TextStyle(
color: boxColor,
fontSize: dayFontSize,
)),
),
],
),
],
);
}
}
@lsgd
Copy link
Author

lsgd commented Jul 22, 2024

Example: image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment