flutterdartshadowappbarflutter-widget

Removing the drop shadow from a Scaffold AppBar in Flutter?


Is there a way to remove the drop shadow under the app bar (AppBar class) when using a Scaffold widget in Flutter?


Solution

  • Looking at the AppBar constructor, there's an elevation property that can be used to set the height of the app bar and hence the amount of shadow cast. Setting this to zero removes the drop shadow:

      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('My App Title'),
            elevation: 0,
          ),
          body: const Center(
            child: Text('Hello World'),
          ),
        );
      }
    

    enter image description here