Created
January 29, 2020 01:48
-
-
Save IhwanID/79276e4b5a4a6b9fd69f8b495e137ea4 to your computer and use it in GitHub Desktop.
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
| void main() { | |
| final person = Person(name: 'Arin', height: 160.0, weight: 55.0); | |
| print(person.bmi); | |
| } | |
| mixin BMI{ | |
| double calculate(double height, double weight){ | |
| return weight / (height * height); | |
| } | |
| } | |
| class Person with BMI{ | |
| Person({this.name, this.weight, this.height}); | |
| final String name; | |
| final double height; | |
| final double weight; | |
| double get bmi => calculate(height, weight); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment