Skip to content

Commit 5a3288e

Browse files
author
afjal1
committed
Fixed " MissingPluginException(No implementation found for method saveWidgetData on channel home_widget)"
1 parent 30ee6c7 commit 5a3288e

File tree

3 files changed

+32
-26
lines changed

3 files changed

+32
-26
lines changed

lib/controller/WidgetController.dart

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,39 +31,41 @@ class WidgetController extends GetxController {
3131
bool stopTraver = false;
3232

3333
void fetchAllData() async {
34-
storageWidget = StorageWidget.of(context!); // Use Get.context from GetX
35-
var currentProfile = ProfilesWidget.of(context!).currentProfile;
36-
37-
baseDirectory = await getApplicationDocumentsDirectory();
38-
storage =
39-
Storage(Directory('${baseDirectory!.path}/profiles/$currentProfile'));
40-
41-
allData.assignAll(storage.data.allData());
42-
43-
if (allData.isNotEmpty) {
44-
List<Task> temp = [];
45-
for (int i = 0; i < allData.length; i++) {
46-
if (allData[i].status == "pending") {
47-
if (temp.length < 3) {
48-
temp.add(allData[i]);
49-
} else {
50-
break;
34+
if (Platform.isAndroid || Platform.isIOS) {
35+
storageWidget = StorageWidget.of(context!); // Use Get.context from GetX
36+
var currentProfile = ProfilesWidget.of(context!).currentProfile;
37+
38+
baseDirectory = await getApplicationDocumentsDirectory();
39+
storage =
40+
Storage(Directory('${baseDirectory!.path}/profiles/$currentProfile'));
41+
42+
allData.assignAll(storage.data.allData());
43+
44+
if (allData.isNotEmpty) {
45+
List<Task> temp = [];
46+
for (int i = 0; i < allData.length; i++) {
47+
if (allData[i].status == "pending") {
48+
if (temp.length < 3) {
49+
temp.add(allData[i]);
50+
} else {
51+
break;
52+
}
5153
}
5254
}
53-
}
5455

55-
allData.assignAll(temp);
56-
// allData = allData.reversed.toList().obs;
57-
_sendAndUpdate();
56+
allData.assignAll(temp);
57+
// allData = allData.reversed.toList().obs;
58+
sendAndUpdate();
59+
}
5860
}
5961
}
6062

61-
Future<void> _sendAndUpdate() async {
62-
await _sendData();
63-
await _updateWidget();
63+
Future<void> sendAndUpdate() async {
64+
await sendData();
65+
await updateWidget();
6466
}
6567

66-
Future<void> _sendData() async {
68+
Future<void> sendData() async {
6769
try {
6870
for (int i = 0; i < allData.length && i < 3; i++) {
6971
String subtitle = 'No Pending Task';
@@ -98,7 +100,7 @@ class WidgetController extends GetxController {
98100
}
99101
}
100102

101-
Future _updateWidget() async {
103+
Future updateWidget() async {
102104
try {
103105
return HomeWidget.updateWidget(
104106
name: 'TaskWarriorWidgetProvider', iOSName: 'HomeWidgetExample');

macos/Runner/DebugProfile.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
<true/>
99
<key>com.apple.security.network.server</key>
1010
<true/>
11+
<key>com.apple.security.network.client</key>
12+
<true/>
1113
</dict>
1214
</plist>

macos/Runner/Release.entitlements

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@
44
<dict>
55
<key>com.apple.security.app-sandbox</key>
66
<true/>
7+
<key>com.apple.security.network.client</key>
8+
<true/>
79
</dict>
810
</plist>

0 commit comments

Comments
 (0)