My CupertinoApp include a Material Design style widget(NavigationRail). I want all widget use same theme.
Some of my code:
@override
Widget build(BuildContext context) {
final Brightness platformBrightness = WidgetsBinding.instance.window.platformBrightness;
return Theme(
data: ThemeData(
brightness: platformBrightness,
),
child: CupertinoApp(
onGenerateTitle: (context) => S.of(context).AppName,
localizationsDelegates: const [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
S.delegate
],
supportedLocales: S.delegate.supportedLocales,
theme: CupertinoThemeData(
brightness: platformBrightness,
),
home: const Scaffold(
resizeToAvoidBottomInset: false,
body: SafeArea(
bottom: false,
child: HomePage(),
),
),
),
);
}
HomePage return
return Row(
children: <Widget>[
SingleChildScrollView(
controller: ScrollController(),
scrollDirection: Axis.vertical,
child: IntrinsicHeight(
child: AppRightSideControls(_controller.future),
),
),
const VerticalDivider(thickness: 1, width: 1),
// This is the main content.
Expanded(
...
),
],
);
class AppRightSideControls extends StatelessWidget {
...
@override
Widget build(BuildContext context) {
return FutureBuilder(
future: _webViewControllerFuture,
builder:
(BuildContext context, AsyncSnapshot<WebViewController> snapshot) {
...
return NavigationRail(
labelType: NavigationRailLabelType.all,
...
);
},
);
}
}
I have try to make CupertinoApp as child of Theme. Make ThemeData and CupertinoThemeData use same brightness. But I got two colors each of black and white.