Created
April 9, 2021 07:54
-
-
Save suragch/3d06b11a531e296f7fb783a1d6e3e287 to your computer and use it in GitHub Desktop.
Minimalist state management: Timer tutorial: timer page UI
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
import 'package:flutter/material.dart'; | |
class TimerPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
print('building MyHomePage'); | |
return Scaffold( | |
appBar: AppBar(title: Text('My Timer App')), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
TimerTextWidget(), | |
SizedBox(height: 20), | |
ButtonsContainer(), | |
], | |
), | |
), | |
); | |
} | |
} | |
class TimerTextWidget extends StatelessWidget { | |
const TimerTextWidget({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Text( | |
'00:10', | |
style: Theme.of(context).textTheme.headline2, | |
); | |
} | |
} | |
class ButtonsContainer extends StatelessWidget { | |
const ButtonsContainer({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Row( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: [ | |
PauseButton(), | |
SizedBox(width: 20), | |
ResetButton(), | |
], | |
); | |
} | |
} | |
class StartButton extends StatelessWidget { | |
const StartButton({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return FloatingActionButton( | |
onPressed: () {}, | |
child: Icon(Icons.play_arrow), | |
); | |
} | |
} | |
class PauseButton extends StatelessWidget { | |
const PauseButton({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return FloatingActionButton( | |
onPressed: () {}, | |
child: Icon(Icons.pause), | |
); | |
} | |
} | |
class ResetButton extends StatelessWidget { | |
const ResetButton({Key key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return FloatingActionButton( | |
onPressed: () {}, | |
child: Icon(Icons.replay), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment