1
0
Fork 0
flutter_demo_energy/lib/main.dart

44 lines
1.1 KiB
Dart
Raw Permalink Normal View History

2023-04-12 08:41:41 +02:00
import 'package:energy/widgets/energy_input_widget.dart';
import 'package:energy/widgets/energy_widget.dart';
import 'package:energy/widgets/heat_capacity_widget.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'models/energy_model.dart';
void main() => runApp(const EnergyApp());
class EnergyApp extends StatelessWidget {
const EnergyApp({super.key});
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider(
create: (_) => EnergyModel(),
child: const MaterialApp(
home: EnergyHomePage(),
),
);
}
}
class EnergyHomePage extends StatelessWidget {
const EnergyHomePage({super.key});
@override
Widget build(BuildContext context) {
final EnergyModel e = context.watch<EnergyModel>();
return Scaffold(
appBar: AppBar(title: const Text('Energy Calculation')),
body: Column(
children: [
EnergyInputWidget(e: e),
EnergyWidget(energy: e.energy),
HeatCapacityWidget(water: e.water, iron: e.iron),
],
),
);
}
}