如何在 Flutter 中删除 Android AppBar 上方的阴影?

How can I remove shadow above AppBar for Android in Flutter?

Flutter中Android的AppBar上方的阴影如何去除?在 iOS 模拟器上,以下代码工作正常。

代码:

    return Scaffold(
        extendBodyBehindAppBar: true,
        appBar: AppBar(
          backgroundColor: Colors.transparent,
          shadowColor: Colors.transparent,
          elevation: 0.0,
          title: Text('Title'),
        ),
        body: Container(
          decoration: BoxDecoration(
            image: DecorationImage(
              image: AssetImage('images/background_01.jpg'),
              fit: BoxFit.cover,
            ),
          ),
          child: SafeArea(
            child: Column(
              children: [
                Container(),
                Container(),
              ],
            ),
          ),
        ));

它的状态栏尝试改变状态栏

将您的安全区域作为整个小部件父级移动。有关安全区域的更多信息,请参见此处 https://api.flutter.dev/flutter/widgets/SafeArea-class.html

return SafeArea(
  child: Scaffold(
      extendBodyBehindAppBar: true,
      appBar: AppBar(
        backgroundColor: Colors.transparent,
        shadowColor: Colors.transparent,
        elevation: 0.0,
        title: Text('Title'),
      ),
      body: Container(
        decoration: BoxDecoration(
          image: DecorationImage(
            image: AssetImage('images/background_01.jpg'),
            fit: BoxFit.cover,
          ),
        ),
        child: Column(
          children: [
            Container(),
            Container(),
          ],
        ),
      )),
);

将此添加到小部件

Widget build(BuildContext context) {
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle(
  statusBarColor: Colors.transparent,
));
return Scaffold(