How to change text color of AppBar, icon color of FAB universally using theme?

后端 未结 9 1576
渐次进展
渐次进展 2020-12-14 13:50

I am able to set the background color of AppBar to Colors.amber. This automatically sets the text color to Black. I am aware of the accessibility i

9条回答
  •  旧巷少年郎
    2020-12-14 14:46

    Here is the way you can set the AppBar Title color.

    return new MaterialApp(
      theme: Theme.of(context).copyWith(
          accentIconTheme: Theme.of(context).accentIconTheme.copyWith(
            color: Colors.white
          ),
          accentColor: Colors.amber,
          primaryColor: Colors.amber,
          primaryIconTheme: Theme.of(context).primaryIconTheme.copyWith(
            color: Colors.white
          ),
          primaryTextTheme: Theme
              .of(context)
              .primaryTextTheme
              .apply(bodyColor: Colors.white)),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Theme Demo"),
          leading: IconButton(
            onPressed: (){},
            icon: Icon(Icons.menu),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          child: Icon(Icons.add),
        ),
      ),
    );
    

提交回复
热议问题