feat: enable auto-calculation with real-time input updates
Co-authored-by: aider (openrouter/deepseek/deepseek-r1:free) <aider@aider.chat>
This commit is contained in:
parent
5e2acf39c3
commit
54e40a2abc
1 changed files with 8 additions and 16 deletions
|
|
@ -30,18 +30,20 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
// Initialize controllers and units
|
||||
// Initialize controllers and units with listeners
|
||||
for (final input in widget.formula.input) {
|
||||
_inputControllers[input.name] = TextEditingController();
|
||||
_selectedUnits[input.name] = input.magnitude;
|
||||
_inputControllers[input.name]!.addListener(_evaluateFormula);
|
||||
}
|
||||
_selectedOutputUnit = widget.formula.output.magnitude;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Clean up controllers
|
||||
// Clean up controllers and listeners
|
||||
for (final controller in _inputControllers.values) {
|
||||
controller.removeListener(_evaluateFormula);
|
||||
controller.dispose();
|
||||
}
|
||||
super.dispose();
|
||||
|
|
@ -105,9 +107,6 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
key: _formKey,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
_buildInputSection(),
|
||||
|
|
@ -116,13 +115,6 @@ class _FormulaScreenState extends State<FormulaScreen> {
|
|||
],
|
||||
),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _evaluateFormula,
|
||||
child: const Text('Calculate'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue