import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:toolheim/data/warband_roster.dart'; class StatsWidget extends StatelessWidget { Stats stats; @override Widget build(BuildContext context) { return GridView.count( crossAxisCount: 10, crossAxisSpacing: 0.0, //padding: const EdgeInsets.all(10), primary: false, shrinkWrap: true, children: [ statsElement('M', stats.movement, stats.movement > 3 ? (stats.movement > 5 ? 3 : 2) : 1), statsElement('WS', stats.weaponSkill, stats.weaponSkill > 3 ? (stats.weaponSkill > 5 ? 3 : 2) : 1), statsElement( 'BS', stats.ballisticSkill, stats.ballisticSkill > 3 ? (stats.ballisticSkill > 5 ? 3 : 2) : 1), statsElement('S', stats.strength, stats.strength > 3 ? (stats.strength > 5 ? 3 : 2) : 1), statsElement('T', stats.toughtness, stats.toughtness > 3 ? (stats.toughtness > 5 ? 3 : 2) : 1), statsElement('W', stats.wounds, stats.wounds > 1 ? (stats.wounds > 2 ? 3 : 2) : 1), statsElement('I', stats.initiative, stats.initiative > 3 ? (stats.initiative > 5 ? 3 : 2) : 1), statsElement('A', stats.attacks, stats.attacks > 1 ? (stats.attacks > 2 ? 3 : 2) : 1), statsElement('Ld', stats.leadership, stats.leadership > 7 ? (stats.leadership > 9 ? 3 : 2) : 1), statsElement('Sv', stats.save, stats.save > 0 ? (stats.leadership > 1 ? 3 : 2) : 0), ]); } StatsWidget(this.stats); Widget statsElement(stat, value, qualityFactor) { TextStyle styles = TextStyle(fontSize: 14, fontWeight: FontWeight.normal); String val = value.toString(); if (qualityFactor == 0) { styles = styles.merge(TextStyle(color: Colors.black45)); val = '-'; } if (qualityFactor > 1) { styles = styles .merge(TextStyle(color: Colors.red, fontWeight: FontWeight.bold)); } if (qualityFactor > 2) { styles = styles.merge(TextStyle(color: Colors.purple)); } return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Text( stat, style: TextStyle(fontSize: 9, color: Colors.grey), ), Text(val, style: styles) ]); } }