);

How to fix leak prone code?

The following code is not leak prone,
because:

The closure doesn’t use the large and short-living context object.

The theme object (used instead) is long-living. It is created once and
shared between BuildContext instances.

// GOOD

@override

Widget

build

BuildContext

context

final

theme

Theme

of

context

);

final

handler

()

apply

theme

);

useHandler

handler

);

General rule for BuildContext