Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ailabs-software/391c0ffde63b4f6066107d11bef387e9 to your computer and use it in GitHub Desktop.
Save ailabs-software/391c0ffde63b4f6066107d11bef387e9 to your computer and use it in GitHub Desktop.
Attempting to extend both an interface (abstract class) & implement overrides of those methods, using extension.
abstract class IDataType
{
void render();
}
class StringDataType implements IDataType
{
@override
void render()
{
print("Render something here.");
}
}
// We know we are in the client build target if the following is imported, which will be in a separate file.
extension IClientDataType on IDataType
{
void run()
{
throw new Exception("This method should be considered abstract."); // Unfortunately, this method is not virtual, it appears, because it is an extension method.
}
}
extension ClientStringDataType on StringDataType
{
void run()
{
print("The 'override' of run() has been executed.");
}
}
void main() {
Map<String, String> foo = const {};
IDataType dataType = new StringDataType();
dataType.run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment