Convert string to document reference

Custom Code
Resolved

I can't convert a string to a document reference in a custom function

What have you tried so far?

I tried writing a function :

import 'dart:convert';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/flutter_flow/custom_functions.dart';
import '/backend/backend.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import '/backend/schema/structs/index.dart';
import '/backend/supabase/supabase.dart';
import '/auth/firebase_auth/auth_util.dart';

DocumentReference convertStringToRefer(String link) {
  /// MODIFY CODE ONLY BELOW THIS LINE

//вв
  final String collectionName = 'Clients';
  final String documentId = link;
  return FirebaseFirestore.instance.collection(collectionName).doc(documentId);

  /// MODIFY CODE ONLY ABOVE THIS LINE
}

But the function keeps giving an error

Compilation error: Info: Compiling with sound null safety
lib/main.dart:17:10:
Error: Undefined name 'FirebaseFirestore'.
  return FirebaseFirestore.instance.collection(collectionName).doc(documentId);
         ^^^^^^^^^^^^^^^^^
Error: Compilation failed.

In the function I send the document ID (9sHJfV0LBFR90FR5tk4q). in the "Return" I specify which collection this document belongs to

Did you check FlutterFlow's Documentation for this topic?
Yes
4
4 replies