Reputation: 427
To avoid this kind of error in Flutter get Package:
════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following StackOverflowError was thrown building Builder: Stack Overflow
Avoid calling depending widget or class from a depending widget or class
if you have :
class A{
var x=locator<B>;
}```
Avoid doing this in class B
```class B{
var x=locator<A>;
}```
:) its crazy but possible...have fun
Upvotes: 2
Views: 407
Reputation: 276911
Instead of a variable, make it a getter:
class A{
B get x => locator<B>()
}
class B{
A get x => locator<A>();
}
Upvotes: 3