import 'package:flutter/material.dart'; class HomeSliverAppBar extends StatefulWidget { final List? actions; final Widget? title; final backgroundColor; final Widget? flexibleSpace; final PreferredSizeWidget? bottom; final double? expandedHeight; HomeSliverAppBar( {Key? key, this.actions, this.title, this.backgroundColor, this.flexibleSpace, this.bottom, this.expandedHeight}) : super(key: key); @override HomeSliverAppBarState createState() => HomeSliverAppBarState(); } class HomeSliverAppBarState extends State { Color _displayColor = Colors.red; updateColor(Color color) { setState(() { _displayColor = color; }); } @override void initState() { super.initState(); _displayColor = widget.backgroundColor; } @override Widget build(BuildContext context) { return SliverAppBar( titleSpacing: 3, actions: widget.actions, title: widget.title, floating: true, pinned: true, snap: true, elevation: 0, backgroundColor: _displayColor, flexibleSpace: widget.flexibleSpace, collapsedHeight: kToolbarHeight+10, expandedHeight: widget.expandedHeight, bottom: widget.bottom, ); } }