Created
May 27, 2021 17:49
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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