FEELIX
FEELIX

Reputation: 427

How to avoid stack overflow Error in Get_It Package in flutter

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

Answers (1)

R&#233;mi Rousselet
R&#233;mi Rousselet

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

Related Questions