【发布时间】:2022-01-18 10:14:35
【问题描述】:
目前我创建了一个应用程序,我在列表中显示我的传感器数据,但我的问题是,如果我想导航到列表页面,我总是会得到一个黑屏。 我试着这样导航:
Container(
height: 150.0,
margin: EdgeInsets.fromLTRB(75, 25, 75, 100),
child: Material(
borderRadius: BorderRadius.circular(20.0),
shadowColor: Colors.greenAccent,
color: Colors.green,
elevation: 7.0,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => DataPage(key: null,)));
},
我得到了错误
The argument type 'Null' can't be assigned to the parameter type 'Key'.
这是我的列表页面代码的一部分
class DataPage extends StatelessWidget {
const DataPage({
required Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hive Test'),
),
body: Column(
children: <Widget>[
Expanded(child: _buildListView()),
],
));
}
以我目前的知识,我不知道如何解决我的问题。对于任何语法错误,我深表歉意,我会感谢您的帮助!
【问题讨论】:
标签: flutter dart navigation