Last active
May 5, 2021 04:13
-
-
Save dened/7d078b784bdce61cbd5908fd53ff3010 to your computer and use it in GitHub Desktop.
Инициализация поля
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
void main() { | |
final bar = Bar(); | |
print(bar.model.value); | |
bar.model.value = "test"; | |
print(bar.model.value); | |
bar.model = SomeModel('newModel'); | |
print(bar.model.value); | |
} | |
abstract class Model<T> { | |
abstract T? value; | |
} | |
class SomeModel extends Model<String> { | |
SomeModel(String param) { | |
print('SomeModel'); | |
value = param; | |
} | |
@override | |
String? value = 'default'; | |
} | |
abstract class Foo<T> { | |
abstract Model<T> model; | |
} | |
class Bar extends Foo<String> { | |
@override | |
Model<String> model = SomeModel('initModel'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment