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

DevOps

YOUR COSMETIC CARE STARTS HERE

Find the Best Cosmetic Hospitals

Trusted • Curated • Easy

Looking for the right place for a cosmetic procedure? Explore top cosmetic hospitals in one place and choose with confidence.

“Small steps lead to big changes — today is a perfect day to begin.”

Explore Cosmetic Hospitals Compare hospitals, services & options quickly.

✓ Shortlist providers • ✓ Review options • ✓ Take the next step with confidence

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