There are two types of notifications, data message and notification message. Notification messages are not handled by your app, but you have control on data messages.
Secondly, you need to check whether you are on chat screen with a specific user who sent you a message or not. To fulfil this requirement, you can save the userID at any place (SharedPref, Utils or any singleton) when you open chat room and remove it when you leave chatRoom. Now when you receive notification, just compare it with your saved userID to whether you want to show notification or vibrate
For only vibrating your phone, you can use package flutter_vibrate 1.0.0 and for generating notification you can use package flutter_local_notifications
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
if(message.data.senderID == prefs.getString(‘chatRoomID)){
// Check if the device can vibrate
bool canVibrate = await Vibrate.canVibrate;
// Vibrate
// Vibration duration is a constant 500ms because
// it cannot be set to a specific duration on iOS.
Vibrate.vibrate();
// Vibrate with pauses between each vibration
final Iterable<Duration> pauses = [
const Duration(milliseconds: 500),
const Duration(milliseconds: 1000),
const Duration(milliseconds: 500),
];
// vibrate - sleep 0.5s - vibrate - sleep 1s - vibrate - sleep 0.5s - vibrate
Vibrate.vibrateWithPauses(pauses);
} Else{ AndroidNotificationDetails(
'your channel id', 'your channel name', 'your channel description',
importance: Importance.max,
priority: Priority.high,
showWhen: false); }
});
One more thing which you also need to do is to show that new message in chat screen. For this, you can use Stream Builder.