@@ -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' );
0 commit comments