Created with <3 with dartpad.dev.
Created
March 15, 2023 23:54
-
-
Save dnys1/9720b6abe565ad345e1c4d5a174c2315 to your computer and use it in GitHub Desktop.
hopeful-zephyr-4541
This file contains hidden or 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
class Options<PluginOptions extends Object?> { | |
const Options({ | |
this.pluginOptions, | |
}); | |
final PluginOptions? pluginOptions; | |
} | |
class AWSPluginOptions {} | |
class Category<PluginOptions extends Object?> { | |
Category(this.plugin); | |
final Plugin<PluginOptions> plugin; | |
void doSomething(Options<PluginOptions> options) { | |
plugin.doSomething(options); | |
} | |
} | |
abstract class Plugin<PluginOptions extends Object?> { | |
void doSomething(Options<PluginOptions> options); | |
} | |
class AWSPlugin extends Plugin<AWSPluginOptions> { | |
@override | |
void doSomething(Options<AWSPluginOptions> options) { | |
print(options.pluginOptions.runtimeType); | |
} | |
} | |
void main() { | |
final Plugin awsPlugin = AWSPlugin(); // plugin type gets erased | |
final category = Category(awsPlugin); | |
category.doSomething(Options(pluginOptions: AWSPluginOptions())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment