wrapAdaptiveTestWidget function

Widget wrapAdaptiveTestWidget(
  1. Widget child, {
  2. TextScaler textScaler = TextScaler.noScaling,
  3. ThemeData? materialTheme,
  4. CupertinoThemeData? cupertinoTheme,
})

Helper to wrap a widget inside the appropriate native shell (CupertinoApp / MaterialApp).

Implementation

Widget wrapAdaptiveTestWidget(
  Widget child, {
  TextScaler textScaler = TextScaler.noScaling,
  ThemeData? materialTheme,
  CupertinoThemeData? cupertinoTheme,
}) {
  final Widget body = Builder(
    builder: (BuildContext context) {
      return MediaQuery(
        data: MediaQuery.of(context).copyWith(textScaler: textScaler),
        child: Center(child: child),
      );
    },
  );

  if (PlatformUtils.isCupertino) {
    return CupertinoApp(
      theme: cupertinoTheme,
      home: body,
    );
  }

  return MaterialApp(
    theme: materialTheme ?? ThemeData(platform: TargetPlatform.android),
    home: Material(child: body),
  );
}