I want to be able to display the current calendar week, but as far as I have seen that isn't possible with DateTime
.
Currently I have to get the current day number, divide it by 7 and round up that number. The last part is where I'm stuck at. Is there a way to round up integers in Flutter?
Here is the code I use:
class CurrentWeek extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return new CurrentWeekState();
}
}
class CurrentWeekState extends State<CurrentWeek> {
DateTime currentTime;
String currentDayCount;
@override
void initState() {
super.initState();
currentTime = DateTime.now();
}
@override
Widget build(BuildContext context) {
currentDayCount = DateFormat("D").format(currentTime);
return Text(currentDayCount);
}
}