35 lines
1014 B
Dart
35 lines
1014 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
class ResultScreen extends StatelessWidget {
|
|
final double bmi;
|
|
const ResultScreen({super.key, required this.bmi});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
String category = '';
|
|
if (bmi < 18.5) {
|
|
category = 'Kurus';
|
|
} else if (bmi < 25) {
|
|
category = 'Normal';
|
|
} else {
|
|
category = 'Gemuk';
|
|
}
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text("Hasil BMI")),
|
|
body: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
Text("BMI: ${bmi.toStringAsFixed(2)}", style: const TextStyle(fontSize: 24)),
|
|
Text("Kategori: $category", style: const TextStyle(fontSize: 20)),
|
|
const SizedBox(height: 20),
|
|
ElevatedButton(onPressed: () => Share.share("BMI saya adalah ${bmi.toStringAsFixed(2)} ($category)"), child: const Text("Bagikan"))
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|