Skip to content

Instantly share code, notes, and snippets.

@IhwanID
Created January 29, 2020 01:48
Show Gist options
  • Select an option

  • Save IhwanID/79276e4b5a4a6b9fd69f8b495e137ea4 to your computer and use it in GitHub Desktop.

Select an option

Save IhwanID/79276e4b5a4a6b9fd69f8b495e137ea4 to your computer and use it in GitHub Desktop.
mixin
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