itemBox method
Implementation
Widget itemBox(int index) {
String item = controller.items[index];
Widget targetIcon = Container();
double degree = itemDegree(item);
if (degree == controller.targetHeading) {
targetIcon = const Positioned(
top: -2,
left: -3,
child: Icon(
Icons.location_pin,
color: Colors.green,
size: 20,
),
);
}
return SizedBox(
width: itemWidth,
child: Stack(
children: [
Positioned(
bottom: 0,
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: 1,
height: 8,
color: Colors.black,
padding: const EdgeInsets.only(bottom: 2),
),
ListenableBuilder(
listenable: controller,
builder: (context, child) {
bool isCurrent = degree > controller.heading - 3 &&
degree < controller.heading + 3;
return Text(
item,
style: TextStyle(
color: Colors.black,
fontSize: isCurrent ? 16 : 12,
fontWeight: isCurrent ? FontWeight.bold : null,
),
);
}),
],
),
),
),
targetIcon,
if (controller.showIndex)
Positioned(
bottom: 0,
left: 20,
child: Text(
"$index",
style: const TextStyle(
color: Colors.black,
fontSize: 10,
),
)),
],
),
);
}