builder property

TransitionBuilder? builder
final

Syntax sugar for obtaining a BuildContext that can read the provider created.

This code:

Provider<int>(
  create: (context) => 42,
  builder: (context, child) {
    final value = context.watch<int>();
    return Text('$value');
  }
)

is strictly equivalent to:

Provider<int>(
  create: (context) => 42,
  child: Builder(
    builder: (context) {
      final value = context.watch<int>();
      return Text('$value');
    },
  ),
)

For an explanation on the child parameter that builder receives, see the "Performance optimizations" section of AnimatedBuilder.

Implementation

final TransitionBuilder? builder;