gpt4 book ai didi

flutter - 返回类型不是闭包上下文所需的小部件

转载 作者:行者123 更新时间:2023-12-04 08:48:38 25 4
gpt4 key购买 nike

我尝试完成教程,但出现此错误(查看图片)。

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:provider_architecture/core/viewmodels/login_model.dart';
import 'package:provider_architecture/locator.dart';

class LoginView extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<LoginModel>(
builder: (context) => locator<LoginModel>(), // the error is here
child: Consumer<LoginModel>(
builder: (context, model, child) => Scaffold(),
),
);
}
}

enter image description here

最佳答案

改变:

builder: (context) => locator<LoginModel>()

到:

create: (context) => locator<LoginModel>()

关于flutter - 返回类型不是闭包上下文所需的小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64182682/

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