withColor<R> method

R withColor<R>(
  1. Color? colorResolver(
    1. BuildContext context
    ),
  2. R block()
)

Applies colorResolver to text appended in block, then restores the previous resolver.

The resolver runs when the text is rendered, using the consuming widget's context.

Implementation

R withColor<R>(
  Color? Function(BuildContext context) colorResolver,
  R Function() block,
) {
  _colorResolverStack.add(colorResolver);
  try {
    return block();
  } finally {
    _colorResolverStack.removeLast();
  }
}