Flutter 如何在抽屉标题的左侧制作另一个AccountPicture

Flutter 如何在抽屉标题的左侧制作另一个AccountPicture,flutter,layout,drawer,Flutter,Layout,Drawer,如何在左侧添加另一个帐户图片,如, 我尝试过使用row列,但我认为有更好的方法。 提前感谢。您可以复制下面的粘贴运行完整代码 您可以使用其他AccountsPicture UserAccountsDrawerHeader( accountName: Text("xxx"), accountEmail: Text("flutterdev@gmail.com"), currentAccountPict

如何在左侧添加另一个帐户图片,如, 我尝试过使用row列,但我认为有更好的方法。
提前感谢。

您可以复制下面的粘贴运行完整代码
您可以使用
其他AccountsPicture

UserAccountsDrawerHeader(
          accountName: Text("xxx"),
          accountEmail: Text("flutterdev@gmail.com"),
          currentAccountPicture: CircleAvatar(
            backgroundImage: NetworkImage('https://img.icons8.com/pastel-glyph/2x/user-male.png'),
            backgroundColor: Colors.white,
          ),
          decoration: BoxDecoration(
            color: Colors.deepOrangeAccent
          ),
        ),
工作演示

完整代码

otherAccountsPictures: [
      CircleAvatar(
        backgroundImage: NetworkImage(
            'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
        backgroundColor: Colors.white,
      ),
    ],
导入“包装:颤振/材料.省道”;
void main(){
runApp(MyApp());
}
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回材料PP(
标题:“颤振演示”,
主题:主题数据(
主样本:颜色。蓝色,
视觉密度:视觉密度。自适应平台密度,
),
主页:MyHomePage(标题:“颤振演示主页”),
);
}
}
类MyHomePage扩展StatefulWidget{
MyHomePage({Key,this.title}):超级(Key:Key);
最后的字符串标题;
@凌驾
_MyHomePageState createState()=>\u MyHomePageState();
}
类_MyHomePageState扩展状态{
int _计数器=0;
void _incrementCounter(){
设置状态(){
_计数器++;
});
}
@凌驾
小部件构建(构建上下文){
返回脚手架(
appBar:appBar(
标题:文本(widget.title),
),
抽屉(
子:列(
儿童:[
UserAccountsDrawerHeader(
账户名称:文本(“xxx”),
帐户电子邮件:文本(“flutterdev@gmail.com"),
currentAccountPicture:CircleAvatar(
背景图片:NetworkImage(
'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
背景颜色:Colors.white,
),
装饰:盒子装饰(颜色:Colors.deeporangeacent),
其他帐户结构:[
圆形(
背景图片:NetworkImage(
'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
背景颜色:Colors.white,
),
],
),
MediaQuery.removePadding(
上下文:上下文,
儿童:扩大(
子:ListView(
//重要提示:从ListView中删除任何填充。
填充:EdgeInsets.zero,
儿童:[
列表砖(
标题:文本(“项目1”),
onTap:(){
//更新应用程序的状态。
// ...
},
),
列表砖(
标题:文本(“项目2”),
onTap:(){
//更新应用程序的状态。
// ...
},
),
],
),
),
),
],
),
),
正文:中(
子:列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“您已经按了这么多次按钮:”,
),
正文(
“$”计数器“,
风格:Theme.of(context).textTheme.headline4,
),
],
),
),
浮动操作按钮:浮动操作按钮(
按下时:\ u递增计数器,
工具提示:“增量”,
子:图标(Icons.add),
),
);
}
}
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      drawer: Drawer(
        child: Column(
          children: <Widget>[
            UserAccountsDrawerHeader(
              accountName: Text("xxx"),
              accountEmail: Text("flutterdev@gmail.com"),
              currentAccountPicture: CircleAvatar(
                backgroundImage: NetworkImage(
                    'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
                backgroundColor: Colors.white,
              ),
              decoration: BoxDecoration(color: Colors.deepOrangeAccent),
              otherAccountsPictures: [
                CircleAvatar(
                  backgroundImage: NetworkImage(
                      'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
                  backgroundColor: Colors.white,
                ),
              ],
            ),
            MediaQuery.removePadding(
              context: context,
              child: Expanded(
                child: ListView(
                  // Important: Remove any padding from the ListView.
                  padding: EdgeInsets.zero,
                  children: <Widget>[
                    ListTile(
                      title: Text('Item 1'),
                      onTap: () {
                        // Update the state of the app.
                        // ...
                      },
                    ),
                    ListTile(
                      title: Text('Item 2'),
                      onTap: () {
                        // Update the state of the app.
                        // ...
                      },
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ),
    );
  }
}