[ERROR: flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type ‘List’ is not a subtype of type ‘FutureOr’

DevOps

MOTOSHARE 🚗🏍️
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
🚀 Everyone wins.

Start Your Journey with Motoshare

Error

Restarted application in 6,092ms.
I/flutter ( 4152): yaha tak aa raha hai onepices
I/flutter ( 4152): https://www.myhospitalnow.com/doctors/api/v1/doctor-api/j/get-all-doctors
E/flutter ( 4152): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'List<dynamic>' is not a subtype of type 'FutureOr<String>'
E/flutter ( 4152): #0      _HomePageState.getDoctors
home_page.dart:34
E/flutter ( 4152): <asynchronous suspension>
E/flutter ( 4152):Code language: PHP (php)

Solution:

It looks like the error you’re encountering is due to a type mismatch between the return type of your getDoctors function and the expected return type when setting the doctors state. You’re trying to set a list (List) to the doctors state, but the function is declared to return a Future.

To resolve this issue, you should update your getDoctors function to return a List instead of a Future. Here’s the modified code:

Your code ought to function as intended after this modification, which should fix the type mismatch problem. The obtained information is now assigned directly to the doctor’s list within the setState function, and the getDoctors function now returns a FutureVoid.

Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x