您可以在下面复制粘贴运行完整代码
你可以使用otherAccountsPictures
otherAccountsPictures: [
CircleAvatar(
backgroundImage: NetworkImage(
'https://img.icons8.com/pastel-glyph/2x/user-male.png'),
backgroundColor: Colors.white,
),
],
工作演示
完整代码
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),
),
);
}
}