【发布时间】:2020-06-24 08:42:48
【问题描述】:
【问题讨论】:
【问题讨论】:
您可以使用ListTile 小部件实现此目的
试试这个方法
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
void main() => runApp( HomeApp());
class HomeApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
// TODO: implement build
return new MaterialApp(
theme: new ThemeData(
primarySwatch: Colors.deepPurple,
brightness: Brightness.light,
accentColor: Colors.red),
home: new HomePage(),
);
}
}
class HomePage extends StatefulWidget {
@override
_HomePageScreen createState() => _HomePageScreen();
}
class _HomePageScreen extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Home"),
),
endDrawer: Drawer(
child: ListView(
padding: EdgeInsets.all(0.0),
children: <Widget>[
UserAccountsDrawerHeader(
accountName: Text("Nilesh Rathod"),
accountEmail: Text("nilesh@gmail.com"),
currentAccountPicture: CircleAvatar(
backgroundColor: Colors.white,
child: Text("Nilu"),
),
otherAccountsPictures: <Widget>[
CircleAvatar(
backgroundColor: Colors.white,
child: Text("Pilu"),
),
],
),
ListTile(
title: Text("Home"),
trailing: Icon(Icons.new_releases),
),
Divider(),
ListTile(
title: Text("Profile"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Tab Layout"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Comman View Demo"),
trailing: Icon(Icons.person),
onTap: () => {},
),
Divider(),
ListTile(
title: Text("Close"),
trailing: Icon(Icons.close),
onTap: () => Navigator.of(context).pop(),
),
],
),
),
body: Center(
child: Text("Home Screen"),
),
);
}
}
示例代码
【讨论】:
利用 ListTile trailing 属性
ListTile(
title: Text("text"),
trailing: Icon(Icons.account),
onTap:null,
),
【讨论】: