'The argument type 'dynamic Function()' can't be assigned to the parameter type 'FutureOr<dynamic> Function(void)'

Im trying to remove user snapshot from firebase database with method onDisconnect()

here is my code:

    lastOnlineRef
        .onDisconnect()
        .set(ServerValue.timestamp)
        .then(()=>firebaseController.removeThisUser(roomId: uid));

Before I tried:

lastOnlineRef
            .onDisconnect()
            .set(ServerValue.timestamp)
            .then(firebaseController.removeThisRoom(roomId: uid));

and then I receive the error:

Unhandled Exception: type 'Future<dynamic>' is not a subtype of type '(void) => dynamic'

Here is removeThisRoom method:

  removeThisRoom({String roomId}) {
    print('removeThisRoom被触发');
    final databaseReference = FirebaseDatabase.instance.ref();
    final roomRef = databaseReference.child('/waitingList/$roomId');
    roomRef.remove();
  }

For now it is failed to remove this user from database when device is offline, Please tell me if it is the right solution, when device is offline totally and should inform database this user is unavailable.

My second solution is just to update the status of this user to unavailable instead of remove this user completely from



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source