Skip to content

Commit 317ba47

Browse files
committed
getIconProperties #2
1 parent a87f333 commit 317ba47

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

example/lib/main.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ class _MyAppState extends State<MyApp> {
196196
Row(
197197
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
198198
children: [
199+
ElevatedButton(
200+
child: Text("icon Properties"),
201+
onPressed: () async {
202+
Map<String, int> result =
203+
await flutterShortcuts.getIconProperties();
204+
print(
205+
"maxHeight: ${result["maxHeight"]}, maxWidth: ${result["maxWidth"]}",
206+
);
207+
},
208+
),
199209
ElevatedButton(
200210
child: Text("Change icon of 2nd Shortcut"),
201211
onPressed: () {

lib/flutter_shortcuts.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ class FlutterShortcuts {
2727
return FlutterShortcutsPlatform.instance.getMaxShortcutLimit();
2828
}
2929

30-
// /// [getIconProperties] returns the "maxHeight" and "maxWidth" of the shortcut icon.
31-
// /// Example: {"maxHeight": 250, "maxWidth": 200}
32-
// Future<Map<String, int>> getIconProperties() {
33-
// return FlutterShortcutsPlatform.instance.getIconProperties();
34-
// }
30+
/// [getIconProperties] returns the "maxHeight" and "maxWidth" of the shortcut icon.
31+
/// Example: {"maxHeight": 250, "maxWidth": 200}
32+
Future<Map<String, int>> getIconProperties() {
33+
return FlutterShortcutsPlatform.instance.getIconProperties();
34+
}
3535

3636
/// [setShortcutItems] will set all the shortcut items.
3737
Future<void> setShortcutItems(

lib/src/method_call/flutter_shortcuts_method_call_handler.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,11 @@ class FlutterShortcutsMethodCallHandler extends FlutterShortcutsPlatform {
3636
return channel.invokeMethod<int>('getMaxShortcutLimit');
3737
}
3838

39-
// @override
40-
// Future<Map<String, int>> getIconProperties() async {
41-
// return channel.invokeMethod('getIconProperties').then(
42-
// (value) => value.map(
43-
// (key, value) => MapEntry<String, int>(key, value),
44-
// ),
45-
// );
46-
// }
39+
@override
40+
Future<Map<String, int>> getIconProperties() async {
41+
return Map.castFrom<dynamic, dynamic, String, int>(
42+
await channel.invokeMethod('getIconProperties'));
43+
}
4744

4845
@override
4946
Future<void> setShortcutItems(List<FlutterShortcutItem> items) async {

lib/src/platform/flutter_shortcuts_platform.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ abstract class FlutterShortcutsPlatform extends PlatformInterface {
3636
throw UnimplementedError("getMaxShortcutLimit() has not been implemented.");
3737
}
3838

39-
// Future<Map<String, int>> getIconProperties() {
40-
// throw UnimplementedError("getIconProperties() has not been implemented.");
41-
// }
39+
Future<Map<String, int>> getIconProperties() {
40+
throw UnimplementedError("getIconProperties() has not been implemented.");
41+
}
4242

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

0 commit comments

Comments
 (0)