3
votes

Flutter shows me this error, but the two types are identical.

[CartItem it's just a simple model; there was a conflict since another widget had the same name but I resolved it using "as" in the import statement]

The argument type List<CartItems> (where CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart)' can't be assigned to the parameter type List<CartItems> (where CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart)'.dartargument_type_not_assignable

list.dart(56, 16): List is defined in /Users/marco/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart

cart.dart(3, 7): CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart

list.dart(56, 16): List is defined in /Users/marco/flutter/bin/cache/pkg/sky_engine/lib/core/list.dart

cart.dart(3, 7): CartItem is defined in /Users/marco/Documenti Locali/shop_app/lib/providers/cart.dart

Peek Problem (⌥F8) No quick fixes available

3

3 Answers

2
votes

It was a double slash in the import statement that generated this strange error.

0
votes

you should use the library prefix in the usage too so if your namespace is

import 'package:app/xxxx/shop_app/lib/providers/cart.dart as shop_cart;

you should specify it in the generic List as well such as;

List shopCarts = etc...;

0
votes

Check your import statement at the top of file even if you mistyped a directory folder name as 'Caps or Small' you can get this error.