Flutter 提供程序没有作用域,声明后访问错误
我正在我的移动应用程序上完成身份验证流程,现在是注册时间,所以用户应该插入其数据(姓名、年龄…),但我收到错误Flutter 提供程序没有作用域,声明后访问错误,flutter,google-cloud-platform,firebase-authentication,flutter-provider,Flutter,Google Cloud Platform,Firebase Authentication,Flutter Provider,我正在我的移动应用程序上完成身份验证流程,现在是注册时间,所以用户应该插入其数据(姓名、年龄…),但我收到错误提供商不在范围内,因此我无法使用FirestoreDatabase功能。这是所有应用程序流中提供商的第一个声明,我想我没有正确地阅读它,可能是上下文造成的问题 首先显示代码,这是如何定义数据库类的: class FirestoreDatabase implements Database{//...some functions 现在代码是: Widget build(BuildConte
提供商不在范围内
,因此我无法使用FirestoreDatabase
功能。这是所有应用程序流中提供商的第一个声明,我想我没有正确地阅读它,可能是上下文
造成的问题
首先显示代码,这是如何定义数据库
类的:
class FirestoreDatabase implements Database{//...some functions
现在代码是:
Widget build(BuildContext context) {
return Provider<Database>( //Database is an interface to use FirebaseFirestore class methods and other
create: (context) => FirestoreDatabase(uid: widget.userUid),
child: Scaffold(...
我想问题是关于上下文
或者我在最后几行声明了数据库
类型的变量
Future<void> _submit() async {
if (_validateAndSaveForm()) {
Database database = Provider.of<Database>(context, listen: false);
database.(some functions)