Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter firestore read data

static final db = FirebaseFirestore.instance;

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

flutter firestore read

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 :: dart map foreach 
Dart :: dart string to color 
Dart :: text in column flutter overflow ellipsis not working 
Dart :: dart jsonEncode 
Dart :: dart try-catch 
Dart :: list of strings in dart 
Dart :: create publisher account on pub.dev 
Dart :: flutter check if platform is ios or andriod 
Dart :: flutter delay a function 
Dart :: change password firebase flutter 
Dart :: flutter bullet point 
Dart :: dart regex 
Dart :: dart empty check 
Dart :: flutter rename 
Dart :: listview inside column flutter 
Dart :: transparent appbar flutter 
Dart :: badge flutter 
Dart :: children vs child dart 
Dart :: dart list sort by value 
Dart :: expansion tile widget flutter opening one at time 
Dart :: media query flutter 
Dart :: elevated Button Theme background color in flutter 
Dart :: flutter showSnackBar replacme 
Dart :: listtile flutter 
Dart :: spacer in singlechildscrollview 
Dart :: how to rename file in flutter 
Dart :: how to change the shape of a buton in flutter to cicular 
Dart :: special characters flutter 
Dart :: flutter how to create text with line on bot 
Dart :: empty object in dart 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =