how to change appbar color when button tap from other screen in flutter

Viewed 34

I'm using BottomNavigationBar and AppBar in HomeScreen in which I'm using two screens A and B , now I want to change AppBar background color when tapping a TextButton from B screen

Does anyone know how to achieve this ?

1 Answers

So here's the solution:

1.Take the AppBar background color in a variable(ex-color) of type color and pass this color as a constructor to new screen(suppose B).

2.Now bind the onclick of textbutton of screen B to a function inside setState that changes color of variable color by changing it's content dynamically at wherever it's getting used.

Related