Skip to content

Instantly share code, notes, and snippets.

@om-ha
Last active August 4, 2022 15:16
Show Gist options
  • Save om-ha/2cdd8a32e72360ef4813bd75ec115578 to your computer and use it in GitHub Desktop.
Save om-ha/2cdd8a32e72360ef4813bd75ec115578 to your computer and use it in GitHub Desktop.
divine-utopia-3406
void main() {
final MyType myType = MyType();
myMethod<MyType>(myType);
}
void myMethod<T>(T? value) {
bool isMyInterface;
bool isMyMixin;
isMyInterface = value is MyInterface?;
isMyMixin = value is MyMixin?;
print('`MyInterface?` $isMyInterface'); // `false` with freezed
print('`MyMixin?` $isMyMixin'); // `false` with freezed
print('');
isMyInterface = value is MyInterface;
isMyMixin = value is MyMixin;
print('`MyInterface` $isMyInterface'); // `false` with freezed
print('`MyMixin` $isMyMixin'); // `false` with freezed
print('');
print('value.runtimeType ${value.runtimeType}'); // `_$_MyType` with freezed
print('T $T'); // `MyType?` with freezed
}
abstract class MyInterface {}
mixin MyMixin {}
class MyType with MyMixin implements MyInterface {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment