Rory Prince
Rory Prince

Reputation: 63

What needs to use Dispose in Flutter?

UPDATE: I have a general idea of what dispose does. But I want a list of specific items have to be disposed, like: text controllers, stream controllers, or "any and all variables declared in a Stateful page"...

Here is the original post:
...
I know you use Dispose to "clean up" a Stateful page. And I have used it for textfield controllers. But I am unclear on:

  1. what types of things need to be disposed? (besides textfield controllers)
  2. what happens if you don't dispose? (memory leaks?)

Thanks!

Upvotes: 2

Views: 435

Answers (1)

MANISH DAYMA
MANISH DAYMA

Reputation: 1242

dispose method is used to release the memory allocated to variables when the state object is removed.

For example, if you are using a stream in your application then you have to release memory allocated to the stream controller. Otherwise, your app may get a warning from the PlayStore and AppStore about memory leakage.

Upvotes: 0

Related Questions