Skip to content

Instantly share code, notes, and snippets.

@HansMuller
Created December 14, 2018 20:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HansMuller/793b7a2b7fd35a2def4337315918a26d to your computer and use it in GitHub Desktop.
Save HansMuller/793b7a2b7fd35a2def4337315918a26d to your computer and use it in GitHub Desktop.
class Model {
const Model({ this.value = 0 });
final int value;
@override
bool operator ==(Object other) {
if (identical(this, other))
return true;
if (other.runtimeType != runtimeType)
return false;
final Model otherModel = other;
return otherModel.value == value;
}
@override
int get hashCode => value.hashCode;
static Model of(BuildContext context) {
final ModelBinding binding = context.inheritFromWidgetOfExactType(ModelBinding);
return binding.model;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment