Home > Enterprise >  How can I fix context.read(xxx).state error? Or replace with anything
How can I fix context.read(xxx).state error? Or replace with anything

Time:12-19

var submitData = {
      'beauticianId': context.read(selectedBeautician).state.docId,
      'beauticianName': context.read(selectedBeautician).state.name,
      'cityBook': context.read(selectedCity).state.name,
      //'name': context.read(selectedBeautician).state.name,
      'clinicAddress': context.read(selectedClinic).state.address,
      'clinicId': context.read(selectedClinic).state.docId,
      'clinicName': context.read(selectedClinic).state.name,
      'slot': context.read(selectedTimeSlot).state,
      'timeStamp': timeStamp,
      'time': '${context.read(selectedTime).state} - ${DateFormat('dd/MM/yyyy').format(context.read(selectedDate).state)}'
    };

I can't seem to find the solution anywhere. There's a lot of that errors since I used that lines a lot.

CodePudding user response:

so instead of using context.read(someProvider).state use this

Provider.of<someProvider>(context).state
  • Related