class _BillDetailsWidgetState extends State<BillDetailsWidget> {
_BillDetailsWidgetState(
{this.qtyCount,
this.singleServicePrice,
this.itemsTotal,
this.totalPayablePrice});
int qtyCount = 10;
int singleServicePrice = 100;
int itemsTotal;
int totalPayablePrice = 0;
String cartPriceTotal() {
totalPayablePrice = qtyCount * singleServicePrice;
return totalPayablePrice.toString();
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: 10.0),
color: Colors.white,
child: Container(
color: Colors.white,
padding:
EdgeInsets.only(top: 20.0, bottom: 20.0, left: 20.0, right: 20.0),
child: Column(
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Bill Details:',
style: kTextStyle,
),
SizedBox(
height: 10,
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Item(s) Total',
style: kOtherTextStyle,
),
Text(
'249',
style: kOtherTextStyle,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'Safety & Conveyance Charges',
style: kOtherTextStyle,
),
Text(
'₹ 80',
style: kOtherTextStyle,
),
],
),
SizedBox(
height: 10,
),
Container(
height: 1,
color: Colors.grey,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
Text(
cartPriceTotal(),
style: kOtherTextStyle,
),
],
),
],
),
],
),
),
);
}
}
Can anybody help with an error!
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following NoSuchMethodError was thrown building BillDetailsWidget(dirty, state: _BillDetailsWidgetState#4bb59): The method '*' was called on null. Receiver: null Tried calling: *(null)
The relevant error-causing widget was: BillDetailsWidget file:///C:/Users/admin/AndroidStudioProjects/gloveson/lib/Screens/Bookings%20Page/pricing.dart:185:13 When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5) #1 _BillDetailsWidgetState.cartPriceTotal (package:gloveson/Screens/Bookings%20Page/pricing.dart:532:34) #2 _BillDetailsWidgetState.build (package:gloveson/Screens/Bookings%20Page/pricing.dart:593:23) #3 StatefulElement.build (package:flutter/src/widgets/framework.dart:4792:27) #4 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4675:15) ... ════════════════════════════════════════════════════════════════════════════════════════════════════ Reloaded 5 of 589 libraries in 1,280ms.
totalPayablePrice = qtyCount * singleServicePrice;
either qtyCount or singleServicePrice isnull
. Could you post the rest of your code where_BillDetailsWidgetState
is called? – Er1