This is my Sales page where I navigate to a form in Add sales page to add data
class _Sales extends State<SalesList>{
final Color primaryColor = Color(0xff18203d);
final Color secondaryColor = Color(0xff232c51);
@override
Widget build(BuildContext context) {
// ignore: todo
// TODO: implement build
return Scaffold(
appBar: AppBar(
actions: [
MaterialButton(
child: Icon(Icons.add),
onPressed: (){
Navigator.push(context, MaterialPageRoute(
builder: (context)=> AddSales()));
})
],
),
body: Container(
child:_salesList(),
),
floatingActionButton: FloatingActionButton(onPressed: () =>
Navigator.push(context, MaterialPageRoute(builder: (context) => AddSales(ref: widget.snap,))),),
);
}
I keep getting the error invalid double when navigating to the next page (Add Sales page) containing the method (_getAvailable)below
class AddSales extends StatefulWidget{
final ref;
AddSales({this.ref});
@override
State<StatefulWidget> createState() => _AddSales();
}
class _AddSales extends State<AddSales>{
final Color primaryColor = Color(0xff18203d);
final Color secondaryColor = Color(0xff232c51);
DateTime dateTime = DateTime.now();
var formated = DateFormat.yMMMMd('en_US');
var month = DateFormat.MMM('en_US');
var year = DateFormat.y('en_US');
TextEditingController _opening = new TextEditingController();
TextEditingController _issued = new TextEditingController();
TextEditingController _returns = new TextEditingController();
TextEditingController _unitPrice = new TextEditingController();
TextEditingController _closing = new TextEditingController();
TextEditingController _comment = new TextEditingController();
double available;
_getAvailable(){
setState(() {
available = VendorsSales(
double.parse(_opening.text),
double.parse(_issued.text),
available,
double.parse(_returns.text),
double.parse(_closing.text),)
.getAvailable();
});
return available;
}
*Inorder to get the available I need to add double values of _issued and _opening stock which will be "parsed" from the textfield *
class VendorsSales{
VendorsSales(this._opening, this._issued, this._available, this._returns ,this._closing);
var id;
DateTime dateTime;
double _opening;
double _issued;
double _available;
double _returns;
double _closing;
double _quantity;
double _price;
double _amount;
String _comment;
var formated = DateFormat.yMMMMd('en_US');
var month = DateFormat.MMM('en_US');
var year = DateFormat.y('en_US');
getAvailable( ){
_available = _opening + _issued;
return _available;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…