We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
// here is the code import 'package:cloud_firestore/cloud_firestore.dart'; class FireStoreDatabase{ CollectionReference f=Firestore.instance.collection('newCollection'); void CreateDocument(){ Map<String,dynamic> data=new Map.fromEntries({ MapEntry('value one','value 2'), }); f.add(data); } } // and the exception is W/Firestore( 6281): (21.3.0) [Firestore]: Write failed at newCollection/IQBxMWbhGsfsR0WjFXK2: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null} E/flutter ( 6281): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error performing setData, PERMISSION_DENIED: Missing or insufficient permissions., null) E/flutter ( 6281): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7) E/flutter ( 6281): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33) E/flutter ( 6281): E/flutter ( 6281): #2 MethodChannelDocumentReference.setData (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:28:43) E/flutter ( 6281): #3 DocumentReference.setData (package:cloud_firestore/src/document_reference.dart:48:22) E/flutter ( 6281): #4 CollectionReference.add (package:cloud_firestore/src/collection_reference.dart:49:23) E/flutter ( 6281): #5 FireStoreDatabase.CreateDocument (package:bbp2/CloudFireStore/FireStoreDatabase.dart:8:7) E/flutter ( 6281): #6 _AdminHomeState.build.. (package:bbp2/Screns/AdminHome.dart:122:47) E/flutter ( 6281): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24) E/flutter ( 6281): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11) E/flutter ( 6281): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5) E/flutter ( 6281): #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7) E/flutter ( 6281): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27) E/flutter ( 6281): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20) E/flutter ( 6281): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22) E/flutter ( 6281): #14 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7) E/flutter ( 6281): #15 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7) E/flutter ( 6281): #16 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7) E/flutter ( 6281): #17 _rootRunUnary (dart:async/zone.dart:1138:13) E/flutter ( 6281): #18 _CustomZone.runUnary (dart:async/zone.dart:1031:19) E/flutter ( 6281): #19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7) E/flutter ( 6281): #20 _invoke1 (dart:ui/hooks.dart:273:10) E/flutter ( 6281): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5) E/flutter ( 6281):
The text was updated successfully, but these errors were encountered:
Hi @ADTheJava You don't sufficient permission to write in firestore Go to firestore ->. Rules and make these changes
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /{document=**} { allow read, write: if true; } } }
and try this code sample
import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, title: 'Material App', theme: ThemeData.dark(), home: Home(), ); } } class Home extends StatelessWidget { final FireStoreDatabase fireStoreDatabase = FireStoreDatabase(); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Firestore Example'), ), floatingActionButton: FloatingActionButton( child: Icon(Icons.add), onPressed: () { fireStoreDatabase.CreateDocument(); }, ), ); } } class FireStoreDatabase { CollectionReference f = Firestore.instance.collection('newCollection'); void CreateDocument() { Map<String, dynamic> data = new Map.fromEntries({ MapEntry('value one', 'value 2'), }); f.add(data); } }
Closing, as this isn't an issue with cloud_firestore itself, if you disagree please write in the comments and I will reopen it Thank you
cloud_firestore
Sorry, something went wrong.
No branches or pull requests
// here is the code
import 'package:cloud_firestore/cloud_firestore.dart';
class FireStoreDatabase{
CollectionReference f=Firestore.instance.collection('newCollection');
void CreateDocument(){
Map<String,dynamic> data=new Map.fromEntries({
MapEntry('value one','value 2'),
});
f.add(data);
}
}
// and the exception is
W/Firestore( 6281): (21.3.0) [Firestore]: Write failed at newCollection/IQBxMWbhGsfsR0WjFXK2: Status{code=PERMISSION_DENIED, description=Missing or insufficient permissions., cause=null}
E/flutter ( 6281): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: PlatformException(Error performing setData, PERMISSION_DENIED: Missing or insufficient permissions., null)
E/flutter ( 6281): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter ( 6281): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:321:33)
E/flutter ( 6281):
E/flutter ( 6281): #2 MethodChannelDocumentReference.setData (package:cloud_firestore_platform_interface/src/method_channel/method_channel_document_reference.dart:28:43)
E/flutter ( 6281): #3 DocumentReference.setData (package:cloud_firestore/src/document_reference.dart:48:22)
E/flutter ( 6281): #4 CollectionReference.add (package:cloud_firestore/src/collection_reference.dart:49:23)
E/flutter ( 6281): #5 FireStoreDatabase.CreateDocument (package:bbp2/CloudFireStore/FireStoreDatabase.dart:8:7)
E/flutter ( 6281): #6 _AdminHomeState.build.. (package:bbp2/Screns/AdminHome.dart:122:47)
E/flutter ( 6281): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter ( 6281): #8 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:486:11)
E/flutter ( 6281): #9 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:264:5)
E/flutter ( 6281): #10 BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:236:7)
E/flutter ( 6281): #11 GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
E/flutter ( 6281): #12 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:222:20)
E/flutter ( 6281): #13 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter ( 6281): #14 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter ( 6281): #15 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter ( 6281): #16 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter ( 6281): #17 _rootRunUnary (dart:async/zone.dart:1138:13)
E/flutter ( 6281): #18 _CustomZone.runUnary (dart:async/zone.dart:1031:19)
E/flutter ( 6281): #19 _CustomZone.runUnaryGuarded (dart:async/zone.dart:933:7)
E/flutter ( 6281): #20 _invoke1 (dart:ui/hooks.dart:273:10)
E/flutter ( 6281): #21 _dispatchPointerDataPacket (dart:ui/hooks.dart:182:5)
E/flutter ( 6281):
The text was updated successfully, but these errors were encountered: