How to change the default color of the area that appears when scrolling occurs on the screen?

Asked

Viewed 90 times

0

Área azul na tela

On the home screen of this application I use a Sliverappbar and when I perform a Scroll on screen this area/ blue shadow appears. What is the name of this area?

I want to allow the user to choose a default color for the shadow within the app. Also, when he navigates to another screen, he can save a default color for the shadow of that screen he is on. So the app can apply different colors to the shade.

How do I do it the right way?

import 'package:flutter/material.dart';

class NoteScreen extends StatefulWidget {

  @override
  _NoteScreenState createState() => _NoteScreenState();
}

class _NoteScreenState extends State<NoteScreen> {
  var _sliverAppBar = SliverAppBar(
    backgroundColor: Colors.black87,
    shadowColor: Colors.black,
    pinned: true,
    title: Text('Title'),
    expandedHeight: 200,
    stretch: true,
    flexibleSpace: FlexibleSpaceBar(
      background: Image.asset(
        'assets/images/warrior.jpg',
        fit: BoxFit.cover,
      ),
    ),
  );

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        color: Colors.black,
        child: CustomScrollView(
          slivers: [
            _sliverAppBar,
          ],
        ),
      ),
    );
  }
}
  • 1

    Just pass the desired color to the property accentColor of ThemeData.

  • @user140828 Puts as answer for me to put as right.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.