为什么这位建筑工人在这里破土动工



我今天已经修复了我的第一组错误,但现在这一行代码中断了,我无法解决

这是queestion 中的错误代码行

builder: (BuildContext context) {... }

错误如下:

编译器消息:lib/main.dart:11:5:错误:没有名为"builder"的命名参数。生成器:(BuildContext上下文({^^^^^^^../../Downloads/flutter_windows_v1.12.13+hotfix.8-stable/src/flutter/.pub-cache/hoster/pub.dartlang.org/provider-4.0.4/lib/src/change_notifier_provider.dart:107:3:上下文:找到了此候选项,但参数不匹配。ChangeNotificationProvider({^^^^^^^^^^^^^^^^^^^^^^目标kernel_snapshot失败:异常:创建快照期间出错:null生成失败。

失败:生成失败,出现异常。

import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'home_page.dart';
import 'auth.dart';
import 'login_page.dart';
void main() => runApp(
ChangeNotifierProvider<AuthService>(
child: MyApp(),
builder: (BuildContext context) {
return AuthService();
},
),
);
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: FutureBuilder<FirebaseUser>(
future: Provider.of<AuthService>(context).getUser(),
builder: (context, AsyncSnapshot<FirebaseUser> snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
// log error to console
if (snapshot.error != null) {
print("error");
return Text(snapshot.error.toString());
}
// redirect to the proper page
return snapshot.hasData ? HomePage(snapshot.data) : LoginPage();
} else {
// show loading indicator
return LoadingCircle();
}
},
),
);
}
}
class LoadingCircle extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: Container(
child: CircularProgressIndicator(),
alignment: Alignment(0.0, 0.0),
),
);
}

ChangeNotifierProvider没有builder属性。您想要使用create属性:

ChangeNotifierProvider<AuthService>(
create: (context) => AuthService(),
child: MyApp(),
},

(文档(

相关内容

  • 没有找到相关文章

最新更新