I want to disable Rate/kg for writing and give it a value by calculating like this
Rate = amount/weight +carriage/weight +unloading/weight
I dont know how to perform these operations on text field plz help link
I want to disable Rate/kg for writing and give it a value by calculating like this
Rate = amount/weight +carriage/weight +unloading/weight
I dont know how to perform these operations on text field plz help link
 
    
     
    
    Simple solution would be executing calculate method onChange of every TextField.
Here is the example in which we have three TextField, and we want to show sum of first two TextField in third TextField.
You can disable the TextField with enabled property or you can use AbsorbPointer.
import 'package:flutter/material.dart';
class StackOverFlow extends StatefulWidget {
  @override
  _StackOverFlowState createState() => _StackOverFlowState();
}
class _StackOverFlowState extends State<StackOverFlow> {
  TextEditingController _firstController = TextEditingController();
  TextEditingController _secondController = TextEditingController();
  TextEditingController _thirdController = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Container(
        child: Column(
          children: <Widget>[
            TextField(
              controller: _firstController,
              onChanged: (value) {
                _calculate();
              },
              keyboardType: TextInputType.number,
            ),
            TextField(
              controller: _secondController,
              onChanged: (value) {
                _calculate();
              },
              keyboardType: TextInputType.number,
            ),
            AbsorbPointer(
              child: TextField(
                controller: _thirdController,
                keyboardType: TextInputType.number,
              ),
            ),
          ],
        ),
      ),
    );
  }
  void _calculate() {
    if (_firstController.text.trim().isNotEmpty &&
        _secondController.text.trim().isNotEmpty) {
      final firstValue = double.parse(_firstController.text);
      final secondValue = double.parse(_secondController.text);
      _thirdController.text = (firstValue + secondValue).toString();
    }
  }
}
 
    
    In-Text widget, You can use the Arithmetic operations like this,
Container(
child: Text(
(currentTemp + kelvin).toStringAsFixed(1),
style: TextStyle(
fontSize: 60,
color: Colors.white,
),
),
),
