Dart, restrictions on generics?

Is there a Dart equivalent syntax for C #'s ability to specify type restrictions for a generic type, for example. in C # type syntax where TBase is SomeType :

 class StackPanel<TBase> extends Panel<TBase> where TBase : SomeType{ } 
+7
generics c # dart constraints
source share
1 answer

You can specify type constraints like this:

 class StackPanel<TBase extends SomeType> extends Panel<TBase> { } 

language specification says:

A parameter of type T can be a suffix with an extends clause that defines the upper bound for T If the extends clause is missing, the upper bound of Object . This is a warning of a static type if the type parameter is a supertype of its upper bound. The boundaries of type variables are a form of type annotation and do not affect execution in production mode.

+6
source share

All Articles