I have the following types:
class AddressEditor extends TextEditor {}
class TypeEditor extends TextEditor {}
I tried to identify the editors as such:
void validationErrorHandler( ValidationError e )
{
var editor = e.editor;
if( editor is AddressEditor )
print( editor.runtimeType.toString() ) // prints TextEditor
if( editor is TypeEditor )
print( editor.runtimeType.toString() ) // prints TextEditor
}
If I use mirrors
import 'dart:mirrors';
getTypeName(dynamic obj)
{
return reflect(obj).type.reflectedType.toString();
}
void validationErrorHandler( ValidationError e )
{
var editor = e.editor;
if( editor is AddressEditor )
print( getTypeName( editor ) ) // prints TextEditor
if( editor is TypeEditor )
print( getTypeName( editor ) ) // prints TextEditor
}
Why is the editor type TypeEditor
and AddressEditor
not being identified? Yes, I know that either is a TextEditor
, but is there any way to identify the TypeEditor
or the AddressEditor
in Dart.
I need to make these identification to work with the result of the validation.
Thanks