Created
January 29, 2024 03:49
-
-
Save doyle-flutter/54d2599814296d0155eb6d02264e23e9 to your computer and use it in GitHub Desktop.
class01 constructor
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
void main(){ | |
final m1 = Model(0, b:1); | |
m1.a; | |
m1.b; | |
final m2 = Model.named(10); | |
m2.a; | |
m2.b; | |
final fm1 = FinalModel(a: 11); | |
// fm1.a = 22; // err -> final | |
const cm1 = const ConstModel(a: 22); | |
// cm1 = const ConstModel(a:33); // err -> const | |
// cm1.a = 44; // err -> const | |
} | |
class Model{ | |
int a; | |
int b; | |
Model(this.a, {required this.b}); | |
Model.named(int c):a = c+1, b = c+2; | |
} | |
class FinalModel{ | |
final int a; | |
FinalModel({required this.a}); | |
} | |
class ConstModel{ | |
final int a; | |
const ConstModel({required this.a}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment