Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter firestore update

import 'package:cloud_firestore/cloud_firestore.dart';

abstract class OurDatabase {
  static final db = FirebaseFirestore.instance;

  static Future create(String collection, String document, Map<String, dynamic> data) async {
    await db.collection(collection).doc(document).set(data);
  }

  static Future<Map<String, dynamic>?> read(String collection, String document) async {
    final snapshot = await db.collection(collection).doc(document).get();
    return snapshot.data();
  }

  static Future update(String collection, String document, Map<String, dynamic> data) async {
    await db.collection(collection).doc(document).update(data);
  }

  static Future replace(String collection, String document, Map<String, dynamic> data) async {
    await db.collection(collection).doc(document).set(data);
  }

  static Future delete(String collection, String document) async {
    await db.collection(collection).doc(document).delete();
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: flutter floting action button elevation 
Dart :: dartpad missing browser localstorage 
Dart :: flutter column mainaxissize 
Dart :: flutter slider color 
Dart :: flutter icon tap 
Dart :: flutter dictionary example 
Dart :: inkwell in image flutter not working 
Dart :: dart convert int to string 
Dart :: flutter capture image from camera 
Dart :: dart almashtirish 
Dart :: empty widget flutter 
Dart :: flutter alertdialog actionsoverflowdirecation 
Dart :: flutter alertdialog action button padding 
Dart :: provider flutter pub 
Dart :: iterable.every dart 
Dart :: raisedbutton full width flutter 
Dart :: destructor in dart 
Dart :: dart concat string and int 
Dart :: sort list dart 
Dart :: flutter color hex 
Dart :: how to blur container in flutter 
Dart :: string validation in dart 
Dart :: Named parameters dart 
Dart :: map in dart 
Dart :: card in flutter 
Dart :: object dart 
Dart :: text color flutter 
Dart :: flutter how to create text with line on bot 
Dart :: anonymous function in dart 
Dart :: select an item woth index list dart 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =