[英]The argument type 'Widget Function(BuildContext, T, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, T, Widget?)'
i have been following a tutorial to implement state management into our flutter web app.我一直在按照教程在我们的 flutter web 应用程序中实施 state 管理。 This is the tutorial: https://medium.flutterdevs.com/firebase-authentication-using-provider-in-flutter-522841a2ee4d
这是教程: https://medium.flutterdevs.com/firebase-authentication-using-provider-in-flutter-522841a2ee4d
Now i am creating the "baseView" model for my widgets and am a bit lost because i am new to flutter.现在我正在为我的小部件创建“baseView”model,我有点迷失了,因为我是 flutter 的新手。
class BaseView<T extends BaseModel> extends StatefulWidget {
final Widget Function(BuildContext context, T model, Widget child) builder;
const BaseView({
@required this.builder,
});
@override
_BaseViewState<T> createState() => _BaseViewState<T>();
}
class _BaseViewState<T extends BaseModel> extends State<BaseView<T>> {
T model = locator<T>();
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<T>.value(
//builder: (context) => model,
child: Consumer<T>(builder: widget.builder),
//notifier: model,
value: model,
);
}
}
Firstly i get the error message for the "@required this.builder" part: The parameter 'builder' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
首先,我收到“@required this.builder”部分的错误消息:
The parameter 'builder' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
And for the "Consumer(builder: widget.builder)" part i get this error: The argument type 'Widget Function(BuildContext, T, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, T, Widget?)'.
对于“Consumer(builder:widget.builder)”部分,我收到此错误:无法
The argument type 'Widget Function(BuildContext, T, Widget)' can't be assigned to the parameter type 'Widget Function(BuildContext, T, Widget?)'.
I also have the link to the Github repo of the project, which is presented in the tutorial: https://github.com/flutter-devs/flutter_auth_provider我还有该项目的 Github 存储库的链接,该链接在教程中提供: https://github.com/flutter-devs/flutter_auth_provider
Any help is kindly appreciated!任何帮助将不胜感激!
Widget Function(BuildContext, T, Widget)
cannot accept a null
value for the widget, which is required by the Widget Function(BuildContext, T, Widget?)
signature. Widget Function(BuildContext, T, Widget)
不能接受Widget Function(BuildContext, T, Widget?)
签名所需的null
值。
That's it.而已。 Make sense?
说得通?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.