我有这个螺丝(波纹管),我正在试着在上面打开一个抽屉。每当我单击按钮时,我都会得到以下回报:
class _BarberListState extends State<BarberList> {
final TextStyle dropdownMenuItem =
TextStyle(color: Colors.black, fontSize: 18);
final GlobalKey<ScaffoldState> _key = GlobalKey<ScaffoldState>();
final primary = Color(0xFF63736B);
final secondary = Color(0xFF0C0E0B);
final green = Color(0xFF79FF00);
final Color active = Colors.grey.shade800;
final Color divider = Colors.grey.shade600;
final String image = 'https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png';
final List<Map> barberLists = [
{
"name": "Barbearia do Laender",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png",
"description":
"Barbaria conceituada que está no mercado de trabalho a mais de 10 anos e com vários clientes satisfeitos",
"details":
"Detalhes como produtos a serem vendidas e serviços adicionais: \n* Corte de Barba: R\$15,00 \n*Pomoda modeladora: R\$50,00",
"detailImage":
"https://cdn.pixabay.com/photo/2019/09/17/18/52/barbershop-4484297__340.jpg",
"prices": "R\$15,00-R\$40,00"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
{
"name": "Barbearia do PA",
"location": "Rua Paraná, 184 - Cidade de Deus",
"type": "De 09h ás 18h - Seg. à Sex.",
"phone": "(37) 99122-3338",
"logoText":
"https://cdn.pixabay.com/photo/2017/01/13/01/22/rocket-1976107_960_720.png"
},
];
@override
Widget build(BuildContext context) {
return new MaterialApp(
key: _key,
home: Scaffold(
drawer: Drawer(
child: Container(
padding: const EdgeInsets.only(left: 16.0, right: 40),
decoration: BoxDecoration(
color: primary, boxShadow: [BoxShadow(color: Colors.black45)]),
width: 300,
child: SafeArea(
child: SingleChildScrollView(
child: Column(
children: <Widget>[
Container(
alignment: Alignment.centerRight,
child: IconButton(
icon: Icon(
Icons.power_settings_new,
color: active,
),
onPressed: () {},
),
),
Container(
height: 90,
alignment: Alignment.center,
decoration: BoxDecoration(
shape: BoxShape.circle,
gradient: LinearGradient(
colors: [Colors.orange, Colors.deepOrange])),
child: CircleAvatar(
radius: 40,
backgroundImage: CachedNetworkImageProvider(image),
),
),
SizedBox(height: 5.0),
Text(
"erika costell",
style: TextStyle(
color: Colors.black,
fontSize: 18.0,
fontWeight: FontWeight.w600),
),
Text(
"@erika07",
style: TextStyle(color: active, fontSize: 16.0),
),
SizedBox(height: 30.0),
_buildRow(Icons.home, "Home"),
_buildDivider(),
_buildRow(Icons.person_pin, "My profile"),
_buildDivider(),
_buildRow(Icons.message, "Messages", showBadge: true),
_buildDivider(),
_buildRow(Icons.notifications, "Notifications",
showBadge: true),
_buildDivider(),
_buildRow(Icons.settings, "Settings"),
_buildDivider(),
_buildRow(Icons.email, "Contact us"),
_buildDivider(),
_buildRow(Icons.info_outline, "Help"),
_buildDivider(),
],
),
),
),
),
),
resizeToAvoidBottomInset: false,
backgroundColor: Color(0xfff0f0f0),
body: SingleChildScrollView(
child: Container(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(top: 145),
height: MediaQuery.of(context).size.height,
width: double.infinity,
child: ListView.builder(
itemCount: barberLists.length,
itemBuilder: (BuildContext context, int index) {
return buildList(context, index);
}),
),
Container(
height: 140,
width: double.infinity,
decoration: BoxDecoration(
color: green,
borderRadius: BorderRadius.only(
bottomLeft: Radius.circular(30),
bottomRight: Radius.circular(30))),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
MaterialButton(
padding: const EdgeInsets.all(8.0),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0)),
child: Icon(Icons.menu),
color: Colors.white,
textColor: Colors.black,
minWidth: 0,
height: 40,
onPressed: () {
_key.currentState.openDrawer();
},
),
Text(
"Barbearias",
style: TextStyle(color: Colors.white, fontSize: 24),
),
IconButton(
onPressed: () {},
icon: Icon(
Icons.filter_list,
color: Colors.white,
),
),
],
),
),
),
Container(
child: Column(
children: <Widget>[
SizedBox(
height: 110,
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 20),
child: Material(
elevation: 5.0,
borderRadius: BorderRadius.all(Radius.circular(30)),
child: TextField(
// controller: TextEditingController(text: locations[0]),
cursorColor: Theme.of(context).primaryColor,
style: dropdownMenuItem,
decoration: InputDecoration(
hintText: "Procurar Barbearias",
hintStyle: TextStyle(
color: Colors.black38, fontSize: 16),
prefixIcon: Material(
elevation: 0.0,
borderRadius:
BorderRadius.all(Radius.circular(30)),
child: Icon(Icons.search),
),
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(
horizontal: 25, vertical: 13)),
),
),
),
],
),
)
],
),
),
),
),
);
}
我尝试遵循一些示例来解决该问题,但是我失败了。我真的很乐于助人。 如果需要的话,我会将其他方法发布在抽屉上,但是我认为此屏幕上有内容,但是我不知道我在做什么错。
答案 0 :(得分:6)
不要忘记将全局密钥分配给支架中的密钥专有性
Scaffold(
key: _scaffoldKey,...
答案 1 :(得分:0)
该消息不存在,因为密钥在MaterialApp中。当我在脚手架上声明钥匙时,抽屉将根据需要工作。