Skip to content

Commit 63e3ac0

Browse files
authored
[flutter_local_notifications] format enums.dart and add testing related info (#465)
* format enums.dart file * format enums.dart * add info related to FlutterLocalNotificationsPlugin.private()
1 parent af67dec commit 63e3ac0

File tree

5 files changed

+27
-3
lines changed

5 files changed

+27
-3
lines changed

flutter_local_notifications/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# [1.1.5+1]
2+
* No function changes. Fixed a reported formatting issue.
3+
* Mention removal of named constructor argument in 1.1.0 changelog entry
4+
* Add API docs to `FlutterLocalNotificationsPlugin.private()` on how it could be used for testing
5+
* Update notes on testing to mention that the `FlutterLocalNotificationsPlugin.private()` named constructor may be of use
6+
17
# [1.1.5]
28
* [Android] minor optimisation on scheduling related code so that `Gson` instance is reused instead of being rebuilt each time
39
* Changed plugin to require 1.12.3+hotfix.5 or greater since pub has issues resolving 1.12.3+hotfix.6
@@ -25,6 +31,7 @@
2531
*Note*: this may have inadvertently broke some tests for users as the plugin now checks which platform the plugin is executing code on and would throw an `UnimplementedError` since neither iOS or Android can be detected. Another issue is that `NotificationAppLaunchDetails` was no longer exposed via the main plugin. Please upgrade to 1.1.3 to have both of these issues fixed
2632
* **BREAKING CHANGE** Plugin callbacks are no longer publicly accessible
2733
* **BREAKING CHANGE** [iOS] Local notifications that launched the app should now only be processed by the plugin if they were created by the plugin.
34+
* **BREAKING CHANGE** `MethodChannel` argument has been removed from the named constructor that was visible for testing purposes
2835

2936
# [1.0.0]
3037
* **BREAKING CHANGE** [iOS] Added checks to ensure callbacks are only invoked for notifications originating from the plugin to improve compatibility with other notification plugins.

flutter_local_notifications/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,4 +420,4 @@ https://developer.apple.com/documentation/usernotifications/unnotificationsound?
420420

421421
## Testing
422422

423-
As the plugin class is not static, it is possible to mock and verify it's behaviour when writing tests as part of your application. Check the source code for a sample test suite can be found at _test/flutter_local_notifications_test.dart_ that demonstrates how this can be done. If you decide to use the plugin class directly as part of your tests, note that the methods will be mostly a no-op and methods that return data will return default values. Part of this is because the plugin detects if you're running on a supported plugin to determine which platform implementation of the plugin should be used. If it's neither Android or iOS, then it defaults to the aforementioned behaviour to reduce friction when writing tests. If this not desired then consider using mocks.
423+
As the plugin class is not static, it is possible to mock and verify it's behaviour when writing tests as part of your application. Check the source code for a sample test suite can be found at _test/flutter_local_notifications_test.dart_ that demonstrates how this can be done. If you decide to use the plugin class directly as part of your tests, note that the methods will be mostly a no-op and methods that return data will return default values. Part of this is because the plugin detects if you're running on a supported plugin to determine which platform implementation of the plugin should be used. If it's neither Android or iOS, then it defaults to the aforementioned behaviour to reduce friction when writing tests. If this not desired then consider using mocks. Note there is also a [named constructor](https://pub.dev/documentation/flutter_local_notifications/latest/flutter_local_notifications/FlutterLocalNotificationsPlugin/FlutterLocalNotificationsPlugin.private.html) that can be used to pass the platform for the plugin to resolve the desired platform-specific implementation.

flutter_local_notifications/lib/src/flutter_local_notifications_plugin.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@ import 'types.dart';
1515
class FlutterLocalNotificationsPlugin {
1616
factory FlutterLocalNotificationsPlugin() => _instance;
1717

18+
/// Used internally for creating the appropriate platform-specific implementation of the plugin.
19+
/// This can be used for tests as well. For example, the following code
20+
///
21+
/// ```
22+
/// FlutterLocalNotificationsPlugin.private(FakePlatform(operatingSystem: 'android'))
23+
/// ```
24+
///
25+
/// could be used in a test needs the plugin to use Android implementation
1826
@visibleForTesting
1927
FlutterLocalNotificationsPlugin.private(Platform platform)
2028
: _platform = platform {

flutter_local_notifications/lib/src/platform_specifics/android/enums.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,14 @@ enum BitmapSource { Drawable, FilePath }
55
enum IconSource { Drawable, FilePath, ContentUri }
66

77
/// The available notification styles on Android
8-
enum AndroidNotificationStyle { Default, BigPicture, BigText, Inbox, Messaging, Media }
8+
enum AndroidNotificationStyle {
9+
Default,
10+
BigPicture,
11+
BigText,
12+
Inbox,
13+
Messaging,
14+
Media
15+
}
916

1017
/// The available actions for managing notification channels.
1118
/// [CreateIfNotExists]: will create a channel if it doesn't exist
@@ -52,8 +59,10 @@ enum GroupAlertBehavior { All, Summary, Children }
5259
enum NotificationVisibility {
5360
/// Show this notification on all lockscreens, but conceal sensitive or private information on secure lockscreens.
5461
Private,
62+
5563
/// Show this notification in its entirety on all lockscreens.
5664
Public,
65+
5766
/// Do not reveal any part of this notification on a secure lockscreen.
5867
Secret,
5968
}

flutter_local_notifications/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: flutter_local_notifications
22
description: A cross platform plugin for displaying and scheduling local notifications for Flutter applications with the ability to customise for each platform.
3-
version: 1.1.5
3+
version: 1.1.5+1
44
homepage: https://github.com/MaikuB/flutter_local_notifications/tree/master/flutter_local_notifications
55

66
dependencies:

0 commit comments

Comments
 (0)