'Dart: How do I define nested generics?

I have the following classes (see below). How can I put one generic type into another generic?

class MySet<T> extends MyCollection<T>{}

class MyList<T> extends MyCollection<T>{}

class MyCollection<T> {}

// It works but MyCollection has no type
class MyProvider<C extends MyCollection> {}

// It does not work. What is the correct way here?
class MyProvider<C extends MyCollection<T>> {}


Solution 1:[1]

You have to define second generic type first, Then use it in nested generic class:

    //Define T as second generic type
    class MyProvider<T,C extends MyCollection<T>> {}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 George Rabbat