Skip to content

Instantly share code, notes, and snippets.

@nemethmik
Last active August 4, 2019 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nemethmik/d9c6ad22d40a68165f71be502cfbba0e to your computer and use it in GitHub Desktop.
Save nemethmik/d9c6ad22d40a68165f71be502cfbba0e to your computer and use it in GitHub Desktop.
The Precedence of Functions Defined by Multiple Dart Mixins
//import "dart:collection";
//class MyList with ListMixin {}
class Food {
void cook(){}
}
class Recipe implements Food {
//List<String> ingredients;
//Recipe(this.ingredients){}
void cook(){print("Cook in Recipe");}
void prepareAndCook(){
print("Prepare in Recipe");
this.cook();
}
}
mixin Edible on Recipe {
//void cook() {print("Cook in Edible");}
void prepareAndCook(){
print("Prepare in Edible");
this.cook();
}
}
//class CajunRecipe with Edible {}
//class CajunRecipe extends Recipe with Edible {}
//class CajunRecipe with Edible implements Recipe {}
//class CajunRecipe implements Recipe with Edible {}
class CajunRecipe with Recipe, Edible {
void goAndCook() {
this.prepareAndCook();
}
}
// In the example CajunRecipe is compoed with Recipe and Edible,
// where goAndCook is defined only in CajunRecipe, while prepareAndCook
// is defined in both Recipe and Edible, but cook is only in Recipe
void main() {
CajunRecipe().goAndCook();
startApp();
}
class I<T> {}
class M0<T> extends I<T> {}
mixin M1<T> on I<T> {}
// M1 is inferred as M1<int>
class A extends M0<int> with M1 {}
abstract class IQuality {
releaseBatch();
}
mixin MQualityImpl implements IQuality {
}
class QualityImpl implements IQuality {
@override releaseBatch() {print("releaseBatch");}
}
abstract class IStocks {
queryBinLOcationStocks();
moveStocks();
}
mixin StocksImpl implements IStocks {
@override queryBinLOcationStocks(){}
@override moveStocks(){}
}
abstract class IWarehousing implements IQuality,IStocks {}
class WarehousingImpl with QualityImpl, StocksImpl implements IWarehousing {}
startApp() {
var app = WarehousingImpl()..releaseBatch();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment