Skip to content

Commit

Permalink
refactored changes
Browse files Browse the repository at this point in the history
  • Loading branch information
divshekhar committed Dec 25, 2021
1 parent ccd7277 commit 6b5c20b
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 21 deletions.
13 changes: 6 additions & 7 deletions lib/flutter_shortcuts.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class FlutterShortcuts {
}

/// [listenAction] performs action when shortcut is initiated.
Future<void> listenAction(FlutterShortcutAction action) async {
Future<void> listenAction(ShortcutAction action) async {
FlutterShortcutsPlatform.instance.listenAction(action);
}

Expand All @@ -40,7 +40,7 @@ class FlutterShortcuts {

/// [setShortcutItems] will set all the shortcut items.
Future<void> setShortcutItems(
{required List<FlutterShortcutItem> shortcutItems}) async {
{required List<ShortcutItem> shortcutItems}) async {
return FlutterShortcutsPlatform.instance.setShortcutItems(shortcutItems);
}

Expand All @@ -52,28 +52,27 @@ class FlutterShortcuts {
/// [pushShortcutItem] will push a new shortcut item.
/// If there is already a dynamic or pinned shortcut with the same ID,
/// the shortcut will be updated and pushed at the end of the shortcut list.
Future<void> pushShortcutItem({required FlutterShortcutItem shortcut}) async {
Future<void> pushShortcutItem({required ShortcutItem shortcut}) async {
return FlutterShortcutsPlatform.instance.pushShortcutItem(shortcut);
}

/// [pushShortcutItems] updates dynamic or pinned shortcuts with same IDs
/// and pushes new shortcuts with different IDs.
Future<void> pushShortcutItems(
{required List<FlutterShortcutItem> shortcutList}) async {
{required List<ShortcutItem> shortcutList}) async {
return FlutterShortcutsPlatform.instance.pushShortcutItems(shortcutList);
}

/// [updateShortcutItems] updates shortcut items.
/// If the IDs of the shortcuts are not same, no changes will be reflected.
Future<void> updateShortcutItems(
{required List<FlutterShortcutItem> shortcutList}) async {
{required List<ShortcutItem> shortcutList}) async {
return FlutterShortcutsPlatform.instance.updateShortcutItems(shortcutList);
}

/// [updateShortcutItem] updates a single shortcut item based on id.
/// If the ID of the shortcut is not same, no changes will be reflected.
Future<void> updateShortcutItem(
{required FlutterShortcutItem shortcut}) async {
Future<void> updateShortcutItem({required ShortcutItem shortcut}) async {
return FlutterShortcutsPlatform.instance.updateShortcutItem(shortcut);
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/helper/helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ for more details.
*/

export 'action/flutter_shortcut_action.dart';
export 'model/flutter_shortcut_item.dart';
export 'action/shortcut_action.dart';
export 'model/shortcut_item.dart';
export 'enums/shortcut_icon_asset.dart';
12 changes: 6 additions & 6 deletions lib/src/method_call/flutter_shortcuts_method_call_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class FlutterShortcutsMethodCallHandler extends FlutterShortcutsPlatform {
}

@override
Future<void> listenAction(FlutterShortcutAction actionHandler) async {
Future<void> listenAction(ShortcutAction actionHandler) async {
channel.setMethodCallHandler((MethodCall call) async {
assert(call.method == 'launch');
actionHandler(call.arguments);
Expand All @@ -52,7 +52,7 @@ class FlutterShortcutsMethodCallHandler extends FlutterShortcutsPlatform {
}

@override
Future<void> setShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> setShortcutItems(List<ShortcutItem> items) async {
final List<Map<String, dynamic>> itemsList =
items.map((item) => item.serialize()).toList();
await channel.invokeMethod<void>('setShortcutItems', itemsList);
Expand All @@ -64,27 +64,27 @@ class FlutterShortcutsMethodCallHandler extends FlutterShortcutsPlatform {
}

@override
Future<void> pushShortcutItem(FlutterShortcutItem shortcut) async {
Future<void> pushShortcutItem(ShortcutItem shortcut) async {
final Map<String, dynamic> item = shortcut.serialize();
await channel.invokeMethod<void>('pushShortcutItem', [item]);
}

@override
Future<void> pushShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> pushShortcutItems(List<ShortcutItem> items) async {
final List<Map<String, dynamic>> itemsList =
items.map((item) => item.serialize()).toList();
await channel.invokeMethod<void>('pushShortcutItems', itemsList);
}

@override
Future<void> updateShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> updateShortcutItems(List<ShortcutItem> items) async {
final List<Map<String, dynamic>> itemsList =
items.map((item) => item.serialize()).toList();
await channel.invokeMethod<void>('updateShortcutItems', itemsList);
}

@override
Future<void> updateShortcutItem(FlutterShortcutItem shortcut) async {
Future<void> updateShortcutItem(ShortcutItem shortcut) async {
final Map<String, dynamic> item = shortcut.serialize();
await channel.invokeMethod<void>('updateShortcutItem', [item]);
}
Expand Down
12 changes: 6 additions & 6 deletions lib/src/platform/flutter_shortcuts_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ abstract class FlutterShortcutsPlatform extends PlatformInterface {
throw UnimplementedError("initialize() has not been implemented.");
}

Future<void> listenAction(FlutterShortcutAction action) async {
Future<void> listenAction(ShortcutAction action) async {
throw UnimplementedError("listenAction() has not been implemented.");
}

Expand All @@ -44,27 +44,27 @@ abstract class FlutterShortcutsPlatform extends PlatformInterface {
throw UnimplementedError("getIconProperties() has not been implemented.");
}

Future<void> setShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> setShortcutItems(List<ShortcutItem> items) async {
throw UnimplementedError("setShortcutItems() has not been implemented.");
}

Future<void> clearShortcutItems() async {
throw UnimplementedError("clearShortcutItems() has not been implemented.");
}

Future<void> pushShortcutItem(FlutterShortcutItem shortcut) async {
Future<void> pushShortcutItem(ShortcutItem shortcut) async {
throw UnimplementedError("pushShortcutItem() has not been implemented.");
}

Future<void> pushShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> pushShortcutItems(List<ShortcutItem> items) async {
throw UnimplementedError("pushShortcutItems() has not been implemented.");
}

Future<void> updateShortcutItems(List<FlutterShortcutItem> items) async {
Future<void> updateShortcutItems(List<ShortcutItem> items) async {
throw UnimplementedError("updateShortcutItems() has not been implemented.");
}

Future<void> updateShortcutItem(FlutterShortcutItem shortcut) async {
Future<void> updateShortcutItem(ShortcutItem shortcut) async {
throw UnimplementedError("updateShortcutItem() has not been implemented.");
}

Expand Down

0 comments on commit 6b5c20b

Please sign in to comment.