Flutter - 如何更改 LicensePage 的背景颜色?

kab*_*boc 3 flutter flutter-theme

我想设置LicensePage除某些颜色之外的每个屏幕的背景颜色,因此我scaffoldBackbroundColor通过如下theme参数指定了。MaterialApp

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(scaffoldBackgroundColor: Colors.blue.shade200),
      home: HomeScreen(),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

这也会更改许可证页面的背景颜色,因此为了将其改回白色,我尝试覆盖scaffoldBackbroundColor,但它不起作用。

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Theme(
        data: Theme.of(context).copyWith(scaffoldBackgroundColor: Colors.white),
        child: Center(
          child: RaisedButton(
            child: const Text('Show licenses'),
            onPressed: () => showLicensePage(context: context),
          ),
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

我该怎么做?

but*_*oys 6

就我而言,我发现 ThemeData(cardColor) 指定了 LicensePage 背景颜色。所以,

showLicense(BuildContext context) {
  Navigator.of(context).push(
    MaterialPageRoute<void>(
      builder: (context) => Theme(
        data: ThemeData(
          cardColor: Colors.yellow,
        ),
        child: LicensePage(
          applicationVersion: '0.1',
          applicationIcon: Icon(Icons.person),
          applicationLegalese: 'Legal stuff',
        ),
      ),
    ),
  );
}
Run Code Online (Sandbox Code Playgroud)