-1

I am facing a error while using "List" in dart. I am using Visual Studio Code. I don't know why is it showing red mark under this List keyword? Can anyone give me a solution to get rid of this?

Please see the screenshot for better understanding:

enter image description here

5
  • 1
    Did you maybe define something on top that is called "List"?
    – nvoigt
    Jul 17, 2022 at 5:02
  • Can you hover on the list and see where the list is defined? Jul 17, 2022 at 5:12
  • Post code that can reproduce your problem, not screenshots.
    – jamesdlin
    Jul 17, 2022 at 5:14
  • Please provide enough code so others can better understand or reproduce the problem.
    – Community Bot
    Jul 17, 2022 at 22:55
  • Did you manage to solve this? I have the same problem! Feb 27 at 12:39

1 Answer 1

1

There is a function named List somewhere. Try to find it and just rename it to something else more specific as it conflicts with the already existing type List from Dart.

Tip: On VSCode you can go to the definition of a type/function/var by just pressing Ctrl + click (Cmd + click) over it.

11
  • Dear lepsch, Thanks for your feedback. But there is no function name like List in my dart page. List has been used as a Future return type . U can check my attachment. Let's see one of my function user here:
    – Moshad
    Jul 17, 2022 at 6:45
  • Future<List<IPOSubscription>> getSubscribers(investorcode, comid) async { List<IPOSubscription> ipoSubscriptions = []; final response = await http.get(Uri.parse( '159.120.3.12:5000/getSubscribers' + investorcode + '/' + comid)); final body = jsonDecode(response.body) as List<dynamic>; return body.map((json) => IPOSubscription.fromJson(json)).toList(); //return ipoSubscriptions; }
    – Moshad
    Jul 17, 2022 at 6:49
  • Would you please edit your question and copy-paste the module imports of this file into the question itself?
    – lepsch
    Jul 17, 2022 at 6:57
  • import 'dart:convert'; import 'dart:core'; import 'package:flutter/cupertino.dart'; import 'package:http/http.dart' as http; import 'package:shel_apps/models/fund_model.dart'; import 'package:shel_apps/models/ipo_model.dart'; import 'package:shel_apps/models/listIPO.dart'; import 'package:shel_apps/models/user_model.dart';
    – Moshad
    Jul 17, 2022 at 7:33
  • Is there some exactly named List declared in the module package:shel_apps/models/listIPO.dart'?
    – lepsch
    Jul 17, 2022 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.