1

My code:

import 'package:firedart/firedart.dart';
import 'package:firedart/firestore/firestore.dart';
class FirestoreMethods{
final _firestore = Firestore.instance;
Future<void> likePost(String postId, String uid, List likes) async {
    try {
      if (likes.contains(uid)) {
        _firestore.collection('posts').document(postId).update({
          'likes':  FieldValue.arrayRemove([uid])
        });
      } else {
        _firestore.collection('posts').document(postId).update({
          'likes': FieldValue.arrayUnion([uid])
        });
      }
    } catch (e) {
      print(e.toString());
    }
  }
}

I want to update array value on firestore using firedart package. But it shows error saying "undefined name 'FieldValue' ".

1 Answer 1

0

From looking at issue #29 on the source repo, it looks like arrayUnion is current not supported in the firedart library. In a comment, the creator of the library is asking for a pull request to add it and I left a comment on how this operator maps to the REST API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.