Skip to content

Instantly share code, notes, and snippets.

@dened
Last active May 5, 2021 04:13
Show Gist options
  • Save dened/7d078b784bdce61cbd5908fd53ff3010 to your computer and use it in GitHub Desktop.
Save dened/7d078b784bdce61cbd5908fd53ff3010 to your computer and use it in GitHub Desktop.
Инициализация поля
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