build method

  1. @override
Widget build(
  1. BuildContext context,
  2. Widget child,
  3. ContentItem content
)
override

Builds the modifier widget tree for the given content item.

This method is called by the content system to apply the modifier to the content item's widget tree.

Implementation

@override
Widget build(BuildContext context, Widget child, ContentItem content) {
  final service = VyuhBinding.instance.di.get<ThemeService>();

  // Rebuilds when the themes or the platform brightness change.
  return Observer(
    builder: (_) {
      final themeData = service.theme(mode);
      return themeData != null ? Theme(data: themeData, child: child) : child;
    },
  );
}