Flutter make http api call when Firestore document changed

I'm trying to call data api when a firestore document is changed but I'm getting error: Error type 'null' is not a subtype of 'bool' with riverpod. What am I doing wrong? Thanks

final firebaseAuthProvider = Provider<FirebaseAuth>((ref) => FirebaseAuth.instance);
final authStateChangesProvider = StreamProvider<User?>((ref) => ref.watch(firebaseAuthProvider).authStateChanges());

final databaseProvider = Provider<DatabaseService?>((ref) {
  final auth = ref.watch(authStateChangesProvider);

  if (auth.asData?.value?.uid != null) {
    return DatabaseService(uid: auth.asData!.value!.uid);
  }
  return null;
});
final firestoreDatabaseProvider = Provider<FirestoreDatabase?>((ref) {
  final auth = ref.watch(authStateChangesProvider);

  if (auth.asData?.value?.uid != null) {
    return FirestoreDatabase(uid: auth.asData!.value!.uid);
  }
  return null;
});
final apiDataProvider2 = FutureProvider.autoDispose<ProfileUser?>((ref) {
  final authUser = ref.watch(authStateChangesProvider);
  final user = authUser.value;
  if (user != null) {
    final userValue = ref.watch(firestoreDatabaseProvider);
    final dbProvider = ref.watch(databaseProvider);
    var profileUser;
    userValue?.getFirestoreUser().listen((event) {
      profileUser = dbProvider!.getProfile();
    });

    if (profileUser) {
      return profileUser;
    } else {
      return Future.value(null);
    }
  } 
});

The problem is with profileUser; It is being returned before

   var profileUser;
    userValue?.getFirestoreUser().listen((event) {
      profileUser = dbProvider!.getProfile();
    });

    if (profileUser) {
      return profileUser;
    } else {
      return Future.value(null);
    }

Try this instead:

   var profileUser = (await userValue?.getFirestoreUser().first)!.getProfile();
    if (profileUser) {
      return profileUser;
    } else {
      return Future.value(null);
    }