rrousselGit / flutter_hooks

React hooks for Flutter. Hooks are a new kind of object that manages a Widget life-cycles. They are used to increase code sharing between widgets and as a complete replacement for StatefulWidget.
MIT License
3.07k stars 175 forks source link

Flutter hook documentation example needed #309

Closed skillkrio closed 2 years ago

skillkrio commented 2 years ago

Dart mixins can partially solve this issue, but they suffer from other problems:

A given mixin can only be used once per class. Mixins and the class share the same object. This means that if two mixins define a variable under the same name, the result may vary between compilation fails to unknown behavior.

can you provide any example for the above two points. i didn't get it.

rrousselGit commented 2 years ago

An example would be:

mixin A {
  String name = 'Hello';
}

mixin B {
  String name = 'World';
}

class MyState extends State<MyWidget> with A, B {
  // Both A and B define a "name" property, but they override each other.
}