|
@@ -1,3 +1,4 @@
|
|
|
+import 'dart:math' as math;
|
|
|
import 'package:flutter/material.dart';
|
|
|
import 'package:get/get.dart';
|
|
|
import 'package:vitalapp/managers/device_controller_manager.dart';
|
|
@@ -257,6 +258,14 @@ class _ExamBodyWeightState extends State<BodyWeight> {
|
|
|
|
|
|
void getBmi() {
|
|
|
if (_weight.isNotEmpty && _height.isNotEmpty) {
|
|
|
+ final w = double.parse(_weight);
|
|
|
+ final h = double.parse(_height) / 100.0;
|
|
|
+ if (h == 0) {
|
|
|
+ // 0不能被除
|
|
|
+ _bmi = "0";
|
|
|
+ } else {
|
|
|
+ _bmi = (w / math.pow(h, 2)).toStringAsFixed(2);
|
|
|
+ }
|
|
|
_bmi = (double.parse(_weight) /
|
|
|
((double.parse(_height) / 100) * (double.parse(_height) / 100)))
|
|
|
.toStringAsFixed(2);
|