build method
- @override
- BuildContext context,
- PositionModel model
override
Builds the UI according to the state in model
.
Implementation
@override
Widget build(BuildContext context, PositionModel model) => Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Row(children: [ // The header at the top
const SizedBox(width: 8),
Text("Drive", style: context.textTheme.headlineMedium),
const Spacer(),
ViewsSelector(index: index),
],),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(
child: Column(children: [
const Text(
"Front View",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Expanded(child: Transform.rotate(
angle: model.position.roll * (pi/180),
child: Image.asset("assets/rover_front.png"),
),),
],),
),
Expanded(
child: Column(children: [
const Text(
"Side View",
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.bold,
),
),
Expanded(child: Transform.rotate(
angle: model.position.pitch * (pi/180),
child: Image.asset("assets/rover_side.png", scale: 0.5),
),),
],),
),
],
),
),
Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Expanded(child: _Wheels(wheels: model.wheelsRPM, colors: model.wheelColors)),
Expanded(child: _BarChart(values: [model.leftWheels, model.rightWheels])),
],
),
),
],
);