Skip to content

Remove usage of deprecated Notification.setListener(..) #8317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions flutter-idea/src/io/flutter/FlutterMessages.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
package io.flutter;

import com.intellij.notification.Notification;
import com.intellij.notification.NotificationListener;
import com.intellij.notification.NotificationType;
import com.intellij.notification.Notifications;
import com.intellij.openapi.project.Project;
Expand All @@ -23,24 +22,24 @@ public class FlutterMessages {
private FlutterMessages() {
}

public static void showError(String title, @NotNull String message, @Nullable Project project) {
public static void showError(@NotNull String title, @NotNull String message, @Nullable Project project) {
Notifications.Bus.notify(
new Notification(FLUTTER_NOTIFICATION_GROUP_ID,
title,
message,
NotificationType.ERROR), project);
}

public static void showWarning(String title, String message, @Nullable Project project) {
public static void showWarning(@NotNull String title, @NotNull String message, @Nullable Project project) {
Notifications.Bus.notify(
new Notification(
FLUTTER_NOTIFICATION_GROUP_ID,
title,
message,
NotificationType.WARNING).setListener(NotificationListener.URL_OPENING_LISTENER), project);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a listener already set for this without using the deprecated fn? Or are we deciding to not listen for URL opens?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, I didn't see any negative effects on the core UX here of a user being exposed to the notification. If there is some piece I am missing we can prioritize and implement with non-deprecated APIs.

NotificationType.WARNING), project);
}

public static void showInfo(String title, String message, @Nullable Project project) {
public static void showInfo(@NotNull String title, @NotNull String message, @Nullable Project project) {
final Notification notification = new Notification(
FLUTTER_NOTIFICATION_GROUP_ID,
title,
Expand Down
19 changes: 11 additions & 8 deletions flutter-idea/src/io/flutter/run/daemon/DeviceDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import io.flutter.FlutterMessages;
import io.flutter.FlutterUtils;
import io.flutter.android.IntelliJAndroidSdk;
Expand Down Expand Up @@ -361,14 +362,16 @@ public void onDaemonLogMessage(@NotNull DaemonEvent.DaemonLogMessage message) {

@Override
public void onDaemonShowMessage(@NotNull DaemonEvent.DaemonShowMessage event) {
if ("error".equals(event.level)) {
FlutterMessages.showError(event.title, event.message, null);
}
else if ("warning".equals(event.level)) {
FlutterMessages.showWarning(event.title, event.message, null);
}
else {
FlutterMessages.showInfo(event.title, event.message, null);
if (StringUtil.isNotEmpty(event.level) && StringUtil.isNotEmpty(event.title) && StringUtil.isNotEmpty(event.message)) {
if ("error".equals(event.level)) {
FlutterMessages.showError(event.title, event.message, null);
}
else if ("warning".equals(event.level)) {
FlutterMessages.showWarning(event.title, event.message, null);
}
else {
FlutterMessages.showInfo(event.title, event.message, null);
}
}
}

Expand Down