Created
November 8, 2021 03:14
-
-
Save t-cool/359ff405c5ea5425a05a7c2dda5a1620 to your computer and use it in GitHub Desktop.
Dart Mixin
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
// クラスの継承関係でうまくいかないとき Mixin で継承をする | |
mixin M { | |
int intM = 111; | |
String methodM() => "M's method"; | |
} | |
mixin N { | |
int intN = 111; | |
String methodN() => "N's method"; | |
} | |
class MixedinClass with M,N{ | |
} | |
main(){ | |
var obj = MixedinClass(); | |
print(obj.intM); | |
print(obj.methodN()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment