Custom action compile error

Custom Code

I'm writing a new custom action which queries with custom enum/data type from firestore, and it's not compiling well.

The thing is, even the boilerplate occurs error.

This is how the error looks like. every import line says almost same:

and here's my code:

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.dart';
import '/backend/schema/enums/enums.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

Future<List<UsersRecord>> filterAndSortUsers(
  CategoryAType selectedCategory,
  SortType selectedSort,
) async {
  // debugPrint(message: "custom action started");

  CollectionReference usersCollection =
      FirebaseFirestore.instance.collection('users');

  Query query = usersCollection.where('verificationStatus',
      isEqualTo: VerificationStatus.approved.toString());

  // debugPrint(message: "verificationStatus ok");

  if (selectedCategory != CategoryAType.All.toString()) {
    query =
        query.where('seller_profile.categoryA', isEqualTo: selectedCategory);
  }

  // debugPrint(message: "category ok");

  if (selectedSort == SortType.Latest.toString()) {
    query = query.orderBy('created_time', descending: true);
  } else if (selectedSort == SortType.HigestRating.toString()) {
    query = query.orderBy('seller_profile.ratingAverage', descending: true);
  } else if (selectedSort == SortType.MostReviews.toString()) {
    query = query.orderBy('seller_profile.ratingCount', descending: true);
  }

  // debugPrint(message: "sort ok");

  QuerySnapshot querySnapshot = await query.get();

  List<UsersRecord> users = querySnapshot.docs.map((doc) {
    return UsersRecord.fromSnapshot(doc);
  }).toList();

  // debugPrint(message: "hmm ended");

  return users;
}
What have you tried so far?

I tried to console log, but even "debugPrint" doesn't compile well..

Did you check FlutterFlow's Documentation for this topic?
No
3 replies