【发布时间】:2020-06-20 22:05:54
【问题描述】:
我想在这里放一个抽屉,但一直出错。我已在错误所在的位置发表评论。请检查并帮助我。
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
AppBar appBar(String name) {
return AppBar(
leading: Text(""),
title: Text(
name,
style: TextStyle(color: Colors.blue),
),
// centerTitle: true,
elevation: 0,
backgroundColor: Colors.transparent,
actions: <Widget>[
IconButton(
icon: Icon(
Icons.notification_important,
color: Colors.blue,
),
onPressed: () {}),
],
);
}
class Drawer extends StatefulWidget {
@override
_DrawerState createState() => _DrawerState ();
}
class _DrawerState extends State <Drawer> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: new Drawer (
我在此处收到一条错误消息,指出:未定义命名参数“child”。 尝试将名称更正为现有命名参数的名称,或使用名称“child”定义命名参数。我可以请我帮忙解决这个问题吗?
child: <Widget>[
ListView(
children : <Widget>[
ListTile(
onTap: (){},
leading: Icon(Icons.arrow_back),
title: Text("Back"),
),
ListTile(
onTap: (){},
leading: Icon(Icons.home),
title: Text("Home"),
),
ListTile(
onTap: (){},
leading: Icon(Icons.settings),
title: Text("Settings"),
),
ListTile(
onTap: (){},
leading: Icon(Icons.mood_bad),
title: Text("Logout"),
),
]
),
],
),
);
}
}
【问题讨论】: