基本上,我有三门课,分别是入门、登陆页和文。用户将能够从入门类导航到登陆页面。我从VIN获得了一些文本或数据值,需要传递到着陆页面,并且我在着陆页类中创建了一个构造函数,以便从VIN检索值。但是我在入门类中收到一个错误,它不需要来自VIN的数据。需要传递给入门路由的参数和值是什么。我收到以下错误:
91:41:错误:必须提供必需的命名参数'vinNumber‘。Get.to(LandingPage());:16:3: Context:查找此候选对象,但参数不匹配。LandingPage({必需this.vinNumber});^
**Getting Started class:**
FlatButton(
child: Text(
'Get a price quote for free!',
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold
),
),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
padding: const EdgeInsets.all(10),
color: Colors.green ,
textColor: Colors.white,
onPressed: () {
**Get.to(LandingPage());**
},
),
**Landing Page class**
class LandingPage extends StatefulWidget {
String? vinNumber;
LandingPage({required this.vinNumber});
@override
_LandingPageState createState() => _LandingPageState(vinNumber!);
}
class _LandingPageState extends State<LandingPage> {
String? vinNumber;
_LandingPageState(this.vinNumber);
**VIN Class**
LandingPage(vinNumber:_getVin.text);发布于 2022-06-10 08:04:27
在登陆页面中,您说vinNumber可以为空,但也要求您只需将LandingPage({required this.vinNumber});更改为LandingPage({this.vinNumber});即可。
发布于 2022-06-10 08:04:05
向您的小部件提供vin编号,如下所示:
onPressed: () {
Get.to(LandingPage(vinNumer: 'anyNumerYouWant' ));
},https://stackoverflow.com/questions/72570925
复制相似问题