【问题标题】:Changing Drawer Icon Color Flutter更改抽屉图标颜色颤动
【发布时间】:2018-08-02 16:34:47
【问题描述】:

我有一个白色的 AppBar 颜色,当我将 AppDrawer 添加到抽屉的图标中时,它会与白色的 AppBar 融为一体。如何更改抽屉图标的颜色?

这是我的一些代码:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      endDrawer: AppDrawer(),
      appBar: AppBar(
        backgroundColor: Colors.white,
        title: Image.asset(
          'images/appbar_logo.jpg',
          fit: BoxFit.fill,
        ),
        centerTitle: true,
      ), // AppBar

还有我的 AppDrawer 有状态小部件:

class AppDrawer extends StatefulWidget {
  @override
  _AppDrawerState createState() => _AppDrawerState();
}

class _AppDrawerState extends State<AppDrawer> {
  @override
  Widget build(BuildContext context) {
    return Drawer(
      child: ListView(
        children: <Widget>[
          new DrawerHeader(
              child: new Image.asset("images/drawer_header_img.jpg")),
          ListTile(
            title: new Text("Item 1"),
          ),
          ListTile(
            title: new Text("Item 2"),
          ),
        ],
      ),
    );
  }

【问题讨论】:

标签: dart flutter


【解决方案1】:

将 iconTheme 属性添加到 appBar

@override
Widget build(BuildContext context) {
return Scaffold(
  endDrawer: AppDrawer(),
  appBar: AppBar(
    backgroundColor: Colors.white,
    title: Image.asset(
      'images/appbar_logo.jpg',
      fit: BoxFit.fill,
    ),
    centerTitle: true,
    iconTheme: IconThemeData(color: Colors.blue), //add this line here
  ), // AppBar

参考:doc

【讨论】:

    猜你喜欢
    • 2018-06-05
    • 2015-10-23
    • 2017-05-09
    • 2018-12-07
    • 2018-08-22
    • 2020-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多