Skip to content

Instantly share code, notes, and snippets.

@minikin
Created October 14, 2019 09:36
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 minikin/5d9c3fcc316bb4021a4d5b82a395ef67 to your computer and use it in GitHub Desktop.
Save minikin/5d9c3fcc316bb4021a4d5b82a395ef67 to your computer and use it in GitHub Desktop.
Extension in Dart
import 'package:flutter/foundation.dart';
class User extends Object {
final String userId;
final String firstName;
final String secondName;
bool isActive;
User({
@required this.userId,
@required this.firstName,
@required this.secondName,
@required this.isActive,
});
}
extension UserExtention on User {
static bool toggle() {
return this.isActive = !this.isActive;
}
}
final User = User(userId: '1', firstName: 'John', secondName: 'Doe', isActive: true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment