Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void main(List<String> arguments) {}
- // code becomes very complex or to understand in Multiple heritance
- class MyLogin extends AuthClass with MyRewards, Authentication, Authentication {
- @override
- logout() {
- throw UnimplementedError();
- }
- }
- abstract class AuthClass {
- logout();
- }
- mixin MyRewards {
- int points = 100;
- }
- /**
- * User
- * Admin
- * Moderator
- */
- class User with Authentication {}
- class Admin with Authentication {}
- class Moderator with Authentication {}
- mixin Authentication {
- int cibiliPoints = 0;
- bool isLogin = false;
- setLogin(bool status) {
- isLogin = status;
- }
- logout() {
- // logout
- }
- getCibilPoints() {}
- bool isHeElgible() {
- if (cibiliPoints > 730) {
- return true;
- } else {
- return false;
- }
- }
- }
- /**
- * In Dart, a mixin is a way to reuse a class's code in multiple class hierarchies.
- * A mixin is defined like a regular class,
- * but it is intended to be used as a component of a class rather than a standalone class.
- * To use a mixin, a class includes it using the "with" keyword.
- * This allows the class that uses the mixin to have access to the mixin's methods and fields,
- * as if they were defined in the class itself.
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement