build method

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

Builds the UI according to the state in model.

Implementation

@override
Widget build(BuildContext context, Controller model) => ValueListenableBuilder(
    valueListenable: models.rover.status,
    builder: (context, status, _) => Row(
      mainAxisSize: MainAxisSize.min,
      children: [
        IconButton(
          icon: Stack(
            children: [
              const Icon(Icons.sports_esports),
              Positioned(
                bottom: -2,
                right: -2,
                child: Text("${model.index + 1}", style: const TextStyle(fontSize: 12, color: Colors.white)),
              ),
            ],
          ),
          color: isDisabled(status) ? Colors.grey : model.isConnected
            ? getColor(model.gamepad.batteryLevel)
            : Colors.black,
          constraints: const BoxConstraints(maxWidth: 36),
          onPressed: model.connect,
        ),
        DropdownButton<OperatingMode>(
          iconEnabledColor: Colors.black,
          value: model.mode,
          onChanged: isDisabled(status) ? null : model.setMode,
          items: [
            for (final mode in OperatingMode.values) DropdownMenuItem(
              value: mode,
              child: Text(mode.name),
            ),
          ],
        ),
      ],
    ),
  );