Factory Method is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
Tutorial: here.
This the very conceptual example rewrite from original source code java example
late Dialog dialog;
void main() {
configure();
runBusinessLogic();
}
void configure() {
if (Platform.isWindows) {
dialog = WindowsDialog();
} else {
dialog = HtmlDialog();
}
}
void runBusinessLogic() {
dialog.renderWindow();
}
Windows Button
Click! Button says - "Hello World!"