صحح الكود void main() { WidgetsFlutterBinding.ensureInitialized();…
- User
صحح الكود
void main() { WidgetsFlutterBinding.ensureInitialized();
FlutterForegroundTask.init( androidNotificationOptions: AndroidNotificationOptions( channelId: 'network_monitor_channel', channelName: 'Network Monitor', channelDescription: 'عرض حالة الشبكة عند الخروج من التطبيق', channelImportance: NotificationChannelImportance.LOW, priority: NotificationPriority.LOW, ), iosNotificationOptions: const IOSNotificationOptions( showNotification: true, playSound: false, ), foregroundTaskOptions: const ForegroundTaskOptions( autoRunOnBoot: false, allowWakeLock: true, allowWifiLock: true, eventAction: EventAction.start, ),
);
- Assistant
الكود الذي أرفقته يحتوي على دالة
mainغير مكتملة (تفتقر إلى إغلاق القوس{}في النهاية)، بالإضافة إلى بعض الملاحظات التي يجب الانتباه لها:- دالة
mainيجب أن تكون من نوعFuture<void>إذا كنت تستدعي دوال غير متزامنة (كما هو الحال مع تهيئة FlutterForegroundTask). - يجب استدعاء لتشغيل تطبيق Flutter، وإذا لم يكن موجودًا فأضفه.
- دالة