build method

  1. @override
Widget build(
  1. BuildContext context,
  2. MissionTimer model
)
override

Builds the UI according to the state in model.

Implementation

@override
Widget build(BuildContext context, MissionTimer model) => model.title == null
    ? Container()
    : Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        Text("${model.title}: ",
          style: context.textTheme.headlineSmall!.copyWith(color: context.colorScheme.onPrimary),
        ),
        const SizedBox(width: 4),
        AnimatedScale(
          scale: (model.underMin) && (model.timeLeft.inSeconds.isEven) ? 1.2 : 1,
          duration: const Duration(milliseconds: 750),
          child: Text(
            model.timeLeft.toString().split(".").first.padLeft(8, "0"),
            style: getStyle(context, model),
          ),
        ),
        const SizedBox(width: 8),
        ElevatedButton(
          onPressed: model.isPaused ? model.resume : model.pause,
          child: model.isPaused ? const Text("Resume") : const Text("Pause"),
        ),
        const SizedBox(width: 8),
        ElevatedButton(
          onPressed: model.cancel,
          child: const Text("Cancel"),
        ),
      ],
    );