Issue
List foo -> List bar
I can use three method
1.List<MyClass> bar = foo.cast<MyClass>()
2.List<MyClass> bar = List.castFrom(foo)
3.List<MyClass> bar = List.from(foo)
What is the difference?
Solution
cast<MyClass>
: Returns the view (Immutable List, altering order of the list won’t be reflected in original list) of the List containing instances of MyClass type. Please follow.castFrom(foo)
: Adapts source (foo) to be a List. Please followfrom(foo)
: Creates a List from Iterable (foo) objects provided in the Argument. Please follow
Answered By – Zain Ul Abideen
Answer Checked By – Senaida (FlutterFixes Volunteer)