Created
July 22, 2019 10:54
-
-
Save flutter-devs/8b8a56051de58b44f0997270d76aa037 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return Scaffold( | |
backgroundColor: Colors.white10, | |
body: AnimatedBuilder( | |
animation: controller, | |
builder: (context, child) { | |
return Padding( | |
padding: EdgeInsets.all(8.0), | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: <Widget>[ | |
Expanded( | |
child: Align( | |
alignment: FractionalOffset.center, | |
child: AspectRatio( | |
aspectRatio: 1.0, | |
child: Stack( | |
children: <Widget>[ | |
Positioned.fill( | |
child: | |
AnimatedBuilder( | |
animation: controller, | |
builder: | |
(BuildContext context, Widget child) { | |
return CustomPaint( | |
painter: CustomTimerPainter( | |
animation: controller, | |
backgroundColor: Colors.white, | |
color: themeData.indicatorColor, | |
)); | |
}, | |
), | |
), | |
Align( | |
alignment: FractionalOffset.center, | |
child: Column( | |
mainAxisAlignment: | |
MainAxisAlignment.spaceEvenly, | |
crossAxisAlignment: | |
CrossAxisAlignment.center, | |
children: <Widget>[ | |
Text( | |
"Count Down Timer", | |
style: TextStyle( | |
fontSize: 20.0, | |
color: Colors.white), | |
), | |
AnimatedBuilder( | |
animation: controller, | |
builder: (BuildContext context, | |
Widget child) { | |
return Text( | |
timerString, | |
style: TextStyle( | |
fontSize: 112.0, | |
color: Colors.white), | |
); | |
}), | |
], | |
), | |
), | |
], | |
), | |
), | |
), | |
), | |
AnimatedBuilder( | |
animation: controller, | |
builder: (context, child) { | |
return FloatingActionButton.extended( | |
onPressed: () { | |
if (controller.isAnimating) | |
controller.stop(); | |
else { | |
controller.reverse( | |
from: controller.value == 0.0 | |
? 1.0 | |
: controller.value); | |
} | |
}, | |
icon: Icon(controller.isAnimating | |
? Icons.pause | |
: Icons.play_arrow), | |
label: Text( | |
controller.isAnimating ? "Pause" : "Play")); | |
}), | |
], | |
), | |
); | |
}), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment