解决Flutter报错The named parameter |method ‘xxxx‘ isn‘t defined.

场景

更新Flutter到2.0后,某些代码或三方库编译出错。

../../../dev_tools/flutter/.pub-cache/hosted/pub.flutter-io.cn/city_pickers-0.1.18/lib/src/cities_selector/cities_selector.dart:387:9: Error: No named parameter with the name 'resizeToAvoidBottomPadding'.
        resizeToAvoidBottomPadding: false,                              
        ^^^^^^^^^^^^^^^^^^^^^^^^^^
../sdk/flutter/packages/flutter/lib/src/material/scaffold.dart:1437:9: Context: Found this candidate, but the arguments don't match.
const Scaffold({
      ^^^^^^^^ 
 
../../../dev_tools/flutter/.pub-cache/hosted/pub.flutter-io.cn/city_pickers-0.1.18/lib/src/mod/inherit_process.dart:20:20: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
 - 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../apps/flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
        context.inheritFromWidgetOfExactType(PageProvider);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

解决方案

查看具体代码发现,是Scaffold的命名参数未定义,BuildContext的方法未定义 。
resizeToAvoidBottomPadding是Scaffold以前版本的参数,Flutter 2.0后改成了resizeToAvoidBottomInset。
同样的地,inheritFromWidgetOfExactType是BuildContext以前的方法,2.0后改成了dependOnInheritedWidgetOfExactType。

Scaffold(
	backgroundColor: Colors.white,
	// resizeToAvoidBottomPadding: false,
	resizeToAvoidBottomInset: false,
)
//context.inheritFromWidgetOfExactType(PageProvider);
context.dependOnInheritedWidgetOfExactType(aspect: PageProvider);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值