summaryrefslogtreecommitdiffstats
path: root/lib/presentation/screens/dashboard/widgets/range.dart
diff options
context:
space:
mode:
Diffstat (limited to 'lib/presentation/screens/dashboard/widgets/range.dart')
-rw-r--r--lib/presentation/screens/dashboard/widgets/range.dart19
1 files changed, 9 insertions, 10 deletions
diff --git a/lib/presentation/screens/dashboard/widgets/range.dart b/lib/presentation/screens/dashboard/widgets/range.dart
index aea92af..34435ae 100644
--- a/lib/presentation/screens/dashboard/widgets/range.dart
+++ b/lib/presentation/screens/dashboard/widgets/range.dart
@@ -10,8 +10,12 @@ class RangeWidget extends ConsumerWidget {
final range = ref.watch(vehicleProvider.select((vehicle) => vehicle.range));
final unit =
ref.watch(unitStateProvider.select((unit) => unit.distanceUnit));
+ final rangeString = (unit == DistanceUnit.kilometers)
+ ? (range / 1000.0).toStringAsFixed(0)
+ : (range / 1609.0).toStringAsFixed(0);
+
return Container(
- height:130,
+ height: 130,
width: 306,
// padding: const EdgeInsets.all(10),
decoration: const ShapeDecoration(
@@ -54,24 +58,19 @@ class RangeWidget extends ConsumerWidget {
),
RichText(
text: TextSpan(
-
- text: '$range',
+ text: rangeString,
style: GoogleFonts.brunoAce(
-
- textStyle:
- const TextStyle(
+ textStyle: const TextStyle(
color: Colors.white,
fontSize: 44,
),
),
children: <TextSpan>[
TextSpan(
- text:
- unit == DistanceUnit.kilometers ? ' Km' : ' Mi',
+ text: unit == DistanceUnit.kilometers ? ' km' : ' mi',
style: GoogleFonts.brunoAce(
textStyle: const TextStyle(
- color: Color(0xFFC1D8FF),
- fontSize: 38),
+ color: Color(0xFFC1D8FF), fontSize: 38),
),
),
]),