Ehab
Ehab

Reputation: 13

flutter : put TextEditingController in json body

dears,

I'm traying to catch value of TextEditingController to send it like this :-

 final firstName = TextEditingController();
  var data2 = {
    "shipping": {
      "address_1": firstName, // problem here don't accept this value ??
    }
  };

as json

 updateUser() async {
   user = await wooCommerce.updateCustomer(id: 2, data: data2); //id (int) , data (Map<dynamic,dynamic>)
    setState(() {});
  }

"address_1": firstName, given error to me with message (X) the instance member can't be accessed in an initializer

so how to catch this value of text ?

Upvotes: 0

Views: 417

Answers (1)

Thierry
Thierry

Reputation: 8393

You probably want to use firstnameController.text:

final firstnameController = TextEditingController();

...

var data2 = {
  "shipping": {
    "address_1": firstnameController.text, // problem here don't accept this value ??
  }
};

Upvotes: 0

Related Questions