I am writing a Flutter app that turns a light on and off based on a time of day. So let's say the time range is to turn on at 5pm and off at 6pm. If the app is opened during this time or if the app is already opened when the time hits, the light would turn on.
I already have the light widget all worked out and will be using opacity to simulate the light on and off.
Container(
height: MediaQuery.of(context).size.height * 0.18,
decoration: new BoxDecoration(
color: Colors.red.withOpacity(0.1),
shape: BoxShape.circle,
),
),
I have been doing some research on Dart's DateTime, but I am not really sure where to start because I want the light to turn on if the app is opened during the "on" window. But also, if the app is already open before the "on" window it will poll in the background and if the "on" window hits, the light will turn on.