gpt4 book ai didi

flutter - 错误 : The argument type 'MaterialPageRoute' can't be assigned to the parameter type 'Route'

转载 作者:IT王子 更新时间:2023-10-29 07:14:08 24 4
gpt4 key购买 nike

我正在学习 flutter,这段代码直接来自老师。我知道 flutter 一直在变化,这可能就是它没有运行的原因。不管怎样,它是:

class Klimatic extends StatefulWidget {
@override
_KlimaticState createState() => new _KlimaticState();
}

class _KlimaticState extends State<Klimatic> {

String _cityEntered;

Future _goToNextScreen(BuildContext context) async {
Map results = await Navigator
.of(context)
.push(new MaterialPageRoute<dynamic>(builder: (BuildContext context) {
return new ChangeCity();
}));

if ( results != null && results.containsKey('enter')) {
_cityEntered = results['enter'];

// debugPrint("From First screen" + results['enter'].toString());


}
}

最佳答案

在不了解确切的 API 详细信息的情况下,看起来您期待的是一种类型 Route<Map> , 但你正在创建一个 Route<dynamic> (或 MaterialPageRoute<dynamic> )。我假设您可以尝试:

new MaterialPageRoute<Map>(...)

... 相反。

关于flutter - 错误 : The argument type 'MaterialPageRoute' can't be assigned to the parameter type 'Route<Map>' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49903420/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com