Skip to content

[General] Provide useful aliases / deprecate verbose names #2692

@Levi-Lesches

Description

@Levi-Lesches

While users can define these on their own, but doing so here will really help the docs, examples, and even source code to be more readable.

// 1. Remove "Flutter" and "Plugin" from all the plugin classes
typedef LocalNotifications = FlutterLocalNotificationsPlugin;
typedef AndroidLocalNotifications = AndroidFlutterLocalNotificationsPlugin;
// ...

// 2. Rename FlutterLocalNotificationsPlugin methods: 
cancelAllPending() => cancelAllPendingNotifications();
getActive() => getActiveNotifications();
getLaunchDetails() => getNotificationAppLaunchDetails();
getPending() => pendingNotificationRequests();
forPlatform() => resolvePlatformSpecificImplementation();
repeat() => periodicallyShowWithDuration()

// 3. Remove "Notification" from all platform details classes
typedef AndroidDetails = AndroidNotificationDetails;
// ...

// 4. Remove "Initialization" from all platform initialization settings
typedef AndroidSettings = AndroidInitializationSettings;
// ...

This could lead to some nice savings like

final androidPlugin = FlutterLocalNotificationsPlugin()
  .resolvePlatformSpecificImplementation
  <AndroidFlutterLocalNotificationsPlugin>();

// vs

final androidPlugin = LocalNotifications().forPlatform<AndroidLocalNotifications>();

I think 1 and 2 are pretty harmless, while 3 and 4 have a higher chance of conflicting with an application's own classes. But I think this is pretty unlikely if developers are containing most / all of their notification logic in a dedicated file (and InitializationSettings doesn't have the word "notification" in it anyway)

Wanted to clear these with you before making a PR. This would be entirely non-breaking and can be done alongside #2614.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions