Open stopwatch.dart to get started:
- The bottom sheet API is not dramatically different from dialogs. The global function expects a BuildContent and a WidgetBuilder.
- Let's create that builder as its own function.
- Add the following code underneath the _stopTimer method:
Widget _buildRunCompleteSheet(BuildContext context) {
final totalRuntime = laps.fold(milliseconds, (total, lap) => total + lap);
final textTheme = Theme.of(context).textTheme;
return SafeArea(
child: Container(
color: Theme.of(context).cardColor,
width: double.infinity,
child: Padding(
padding: EdgeInsets.symmetric(vertical: 30.0),
child: Column(mainAxisSize: MainAxisSize.min, children: [
Text('Run Finished!', style: textTheme.headline6),
Text('Total Run Time is
${_secondsText(totalRuntime)}.')
])),
)
);
}
- Showing the bottom sheet should now be remarkably...