decorate method

  1. @override
List<Decorator> decorate(
  1. BuildContext context
)
override

Implementation

@override
List<Decorator> decorate(BuildContext context) {
  return [
    Decorator(
      (context, story) {
        return ListenableBuilder(
          listenable: this,
          builder: (context, child) {
            if (value) {
              return ConstrainedBox(
                constraints: BoxConstraints.tight(MediaQuery.sizeOf(context)),
                child: Flex(
                  // TODO(@melvspace): 03/06/25 add direction change support.
                  direction: Axis.horizontal,
                  children: [
                    for (final brightness in Brightness.values) //
                      Expanded(
                        child: MediaQuery(
                          data: MediaQuery.of(context).copyWith(
                            platformBrightness: brightness,
                          ),
                          child: Theme(
                            data: switch (brightness) {
                              Brightness.light => lightTheme,
                              Brightness.dark => darkTheme,
                            },
                            child: child!,
                          ),
                        ),
                      ),
                  ],
                ),
              );
            }

            return child!;
          },
          child: story,
        );
      },
    )
  ];
}