### Basic usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/05-routeros-rest-api.md Shows how to instantiate RouterOsRestApi with host, port, username, and password, then perform a GET request to '/system/resource' and print the 'version' field. Finally closes the client. ```dart final api = RouterOsRestApi( host: '192.168.88.1', port: 80, username: 'admin', password: 's3cret', ); final res = await api.get('/system/resource'); print(res['version']); api.close(); ``` -------------------------------- ### HotspotUser usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Shows how to create a HotspotUser instance and call toParams to get the request body. The comment shows the resulting body keys. ```dart import 'package:tikplus_ultra/models/hotspot_user.dart'; final u = HotspotUser( name: 'client42', password: '1234', profile: 'bronze', limitBytesTotal: 10 * 1024 * 1024, ); final body = u.toParams(); // body: {name, password, profile, limit-bytes-total} ``` -------------------------------- ### Usage example for BusinessService Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/10-business-service.md Shows how to get the current role (defaults to manager), set a new role, retrieve invoices, add a new BillingRecord with a UUID, and save the updated list. ```dart final svc = BusinessService.instance; final role = await svc.getRole(); // BusinessRole.manager افتراضياً await svc.setRole(BusinessRole.technician); final records = await svc.invoices(); records.add(BillingRecord( id: const Uuid().v4(), username: 'client42', amount: 150.0, dueDate: DateTime.now().add(const Duration(days: 30)), )); await svc.saveInvoices(records); ``` -------------------------------- ### LiveChart usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of creating a LiveChart with values from _cpu, color AppColors.primary, title 'حمل المعالج', unit '%', and maxY 100. ```dart LiveChart(values: _cpu, color: AppColors.primary, title: 'حمل المعالج', unit: '%', maxY: 100) ``` -------------------------------- ### PppoeUser usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Shows how to create a PppoeUser instance using the fromRow factory method, passing a map with '.id', 'name', and 'profile' keys. The example prints the profile value, which is 'vip'. ```dart import 'package:tikplus_ultra/models/pppoe_user.dart'; final p = PppoeUser.fromRow({ '.id': '*3', 'name': 'user3', 'profile': 'vip', }); print(p.profile); // 'vip' ``` -------------------------------- ### UltraInput usage example with validation Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of using UltraInput with a controller, label, icon, validator that checks for empty and spaces, and onSubmitted callback. ```dart UltraInput( controller: nameCtrl, label: 'اسم المستخدم', icon: Icons.person_outline_rounded, validator: (v) { if ((v ?? '').trim().isEmpty) return 'أدخل اسم المستخدم'; if ((v ?? '').contains(' ')) return 'بدون مسافات'; return null; }, onSubmitted: submit, ) ``` -------------------------------- ### PrimaryButton usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of using PrimaryButton with a label, icon, loading state, and onPressed callback. ```dart PrimaryButton( label: 'توليد الكروت', icon: const Icon(Icons.confirmation_number_rounded), loading: isBusy, onPressed: generate, ) ``` -------------------------------- ### GlassCard usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of using GlassCard with a glow color, onTap callback, and a child text widget. ```dart GlassCard( glowColor: AppColors.primary, onTap: () => print('tapped'), child: Text('بطاقة زجاجية'), ) ``` -------------------------------- ### Basic usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/06-routeros-binary-api.md Connects to a RouterOS device, fetches the system resource, prints the version, and closes the connection. Requires valid host, port, username, and password. ```dart final api = await RouterOsBinaryApi.connect( host: '192.168.88.1', port: 8728, username: 'admin', password: 's3cret', ); final resource = await api.getResource(); print('v${resource['version']}'); api.close(); ``` -------------------------------- ### Basic Connection and Read Example (Dart) Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/07-mikrotik-service.md Shows how to connect to a router using `mikrotikProvider` and read hotspot users. Uses `RouterProfile` with `RouterVersion.auto` and prints protocol label, latency, identity, and user names. ```dart final service = ref.watch(mikrotikProvider); // داخل ConsumerWidget final result = await service.connect(RouterProfile( name: 'الرئيسي', host: '192.168.88.1', version: RouterVersion.auto, )); print('${result.protocol.label} — ${result.latencyMs}ms — ${result.identity}'); final users = await service.hotspotUsers(); for (final u in users) print('${u.name} (${u.profile})'); ``` -------------------------------- ### Usage example with gradient card Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/12-theme.md Shows how to use AppColors, AppGradients, AppRadius, and AppShadows to create a scaffold with a gradient card. Imports the theme file. ```dart import 'package:tikplus_ultra/theme.dart'; final scaffold = Scaffold( backgroundColor: AppColors.bgDeep, body: Padding( padding: const EdgeInsets.all(24), child: Container( decoration: BoxDecoration( gradient: AppGradients.primary, borderRadius: BorderRadius.circular(AppRadius.lg), boxShadow: AppShadows.glow(AppColors.primary), ), child: Text('بطاقة مميزة', style: const TextStyle(color: Colors.white, fontSize: 16)), ), ), ); ``` -------------------------------- ### BusinessGate usage example in app_router.dart Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/17-screens-business-ai.md Shows how to use BusinessGate in the app router to protect a screen. The example allows manager and technician roles to access FirewallScreen. ```dart // في app_router.dart BusinessGate( allowed: const [BusinessRole.manager, BusinessRole.technician], child: FirewallScreen(), ) ``` -------------------------------- ### RouterProfile usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Shows how to create a RouterProfile instance with a name, host, username, and password, and then access the displayName getter, which returns the name if not empty, otherwise the host. ```dart import 'package:tikplus_ultra/models/router_config.dart'; final profile = RouterProfile( name: 'فرع المدينة', host: '192.168.88.1', username: 'admin', password: 's3cret', ); print(profile.displayName); // 'فرع المدينة' ``` -------------------------------- ### Usage example: connect to a router Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/04-connection-provider.md Shows how to use the connectionProvider notifier to connect to a router. It imports the necessary packages, reads the notifier, calls connect with a RouterProfile, and prints the latency or error. ```dart import 'package:tikplus_ultra/providers/connection_provider.dart'; import 'package:tikplus_ultra/models/router_config.dart'; // داخل ConsumerWidget: final notifier = ref.read(connectionProvider.notifier); final ok = await notifier.connect(RouterProfile( name: 'المكتب', host: '10.0.0.2', username: 'admin', password: 'x', )); if (ok) print('متصل: ${ref.read(connectionProvider).result!.latencyMs} ms'); else print(ref.read(connectionProvider).error); ``` -------------------------------- ### get Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/05-routeros-rest-api.md Performs an HTTP GET request to the specified path with optional query parameters. ```APIDOC ## get ### Description Sends a GET request to the RouterOS REST API. The `query` map is sent as query parameters. ### Method GET ### Parameters - **path** (String) - Required - The API endpoint path (e.g., `/system/resource`). - **query** (Map?) - Optional - Query parameters to include in the request. ### Returns Future - The decoded JSON response (or raw text if JSON decoding fails). ### Example ```dart final res = await api.get('/system/resource'); print(res['version']); ``` ``` -------------------------------- ### Dart usage example for consuming a RouterOS REST API endpoint Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Shows two ways to call the API: via the high-level `mikrotikProvider` service and via the direct `RouterOsRestApi` client. The direct client requires host, port, username, and password, and the `get` method accepts a query parameter. Remember to call `close()` on the client. ```dart // عبر الخدمة عالية المستوى: final users = await ref.read(mikrotikProvider).hotspotUsers(); // أو عبر العميل المباشر: final api = RouterOsRestApi( host: '192.168.88.1', port: 80, username: 'admin', password: 'x', ); final data = await api.get('/ip/dhcp-server/lease', query: {'detail': 'dynamic'}); api.close(); ``` -------------------------------- ### Low-level protocol example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/06-routeros-binary-api.md Shows manual sentence encoding and explicit timeout control via talk. Useful for testing or custom word sequences. ```dart // تشفير جملة يدوياً (مفيد للاختبار أو لدى إضافة كلمات مخصصة) final bytes = RouterOsBinaryApi.encodeSentence(['/system/resource/print']); assert(bytes.last == 0); // تحكم صريح بالمهلة عبر talk final reply = await api.talk( ['/ip/neighbor/print', '=interface=bridge1'], timeout: const Duration(seconds: 5), ); print(reply.rows.length); ``` -------------------------------- ### VersionSelector usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of using VersionSelector with a state variable _version and onChanged callback that updates the state via setState. ```dart VersionSelector( value: _version, onChanged: (v) => setState(() => _version = v), ) ``` -------------------------------- ### StatCard usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/13-widgets.md Example of creating a StatCard with title 'جلسات نشطة', value '14', icon Icons.wifi_rounded, color AppColors.success, and subtitle 'من أصل 40 حساباً'. ```dart StatCard( title: 'جلسات نشطة', value: '14', icon: Icons.wifi_rounded, color: AppColors.success, subtitle: 'من أصل 40 حساباً', ) ``` -------------------------------- ### Programmatically fill login form and connect Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/14-screens-login-splash.md Shows how to fill the login form fields programmatically and then invoke the private _connect() method. This is a usage example for the LoginScreen. ```dart // ملء النموذج برمجياً ثم تنفيذ الاتصال state.hostCtrl.text = '10.0.0.2'; state.userCtrl.text = 'admin'; state.passCtrl.text = 'secret'; await state._connect(); // حالة أسلوب خاصة بالشاشة ``` -------------------------------- ### VoucherGenerator usage example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Shows how to import the voucher model and generate 20 vouchers with a 'VIP' prefix, numeric-only usernames, 4-character passwords, a 7-day uptime limit, and a 5GB data limit. Prints each voucher's line. ```dart import 'package:tikplus_ultra/models/voucher.dart'; final cards = VoucherGenerator.generate( count: 20, prefix: 'VIP', numericOnly: true, passwordLength: 4, limitUptime: '7d', limitBytes: 5 * 1024 * 1024 * 1024, ); for (final v in cards) print(v.line); ``` -------------------------------- ### Custom glow shadow example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/12-theme.md Demonstrates using AppShadows.glow with a custom opacity and color inside a widget, with a warning text. ```dart // توهج مع شفافية مخصصة داخل ويدجت Container( decoration: BoxDecoration( boxShadow: AppShadows.glow(AppColors.danger, opacity: 0.4), color: AppColors.bgCard, ), child: Text('تحذير', style: const TextStyle(color: AppColors.danger)), ); ``` -------------------------------- ### Usage example with BusinessGate role check Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/17-screens-business-ai.md Shows how to check role-based access using BusinessService and BusinessGate before navigating to the voucher screen. The role is fetched asynchronously and the gate's allowed list is checked against the current role. ```dart // شرط وصول عبر الدور المحلي: final role = await BusinessService.instance.getRole(); if (BusinessGate(allowed: const [BusinessRole.distributor], child: voucher).allowed.contains(role)) { context.go('/voucher'); } ``` -------------------------------- ### RouterProfile copyWith and JSON round-trip example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Demonstrates using copyWith to update fields, serializing to JSON with toJson, and reconstructing with fromJson, then verifying the host and printing the version label. ```dart final updated = profile.copyWith(useSsl: true, restPort: 443); final json = updated.toJson(); final restored = RouterProfile.fromJson(json); assert(restored.host == '192.168.88.1'); print(restored.version.label); // 'تلقائي' ``` -------------------------------- ### Error handling example with StateError Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/08-router-operation-guard.md Shows catching StateError when backupVerified is false, printing the error message. ```dart try { RouterOperationGuard.requireWriteApproval( explicitlyConfirmed: true, backupVerified: false, // لم يتحقق المستخدم من النسخة الاحتياطية rollbackPlanAvailable: true, ); } on StateError catch (e) { print('ممنوع: ${e.message}'); } ``` -------------------------------- ### Error handling and middleware example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/06-routeros-binary-api.md Adds a hotspot user and handles RouterOsException errors, distinguishing authentication errors, timeouts, and other failures. Useful for robust client code. ```dart try { final id = await api.addHotspotUser( name: 'guest-01', password: '4321', profile: 'default', limitBytesTotal: 300 * 1024 * 1024, ); print('معرّف الحساب: $id'); } on RouterOsException catch (e) { if (e.isAuthError) print('تحقق من بيانات الدخول'); else if (e.kind == RouterOsErrorKind.timeout) print('الراوتر لم يرد خلال المهلة'); else print('فشل: ${e.message}'); } ``` -------------------------------- ### simpleQueues() → Future>> Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/07-mikrotik-service.md Retrieves simple queues. Uses REST GET `/queue/simple` or Binary command. ```APIDOC ## simpleQueues() ### Description Retrieves simple queues. Uses REST GET `/queue/simple` or Binary command. ### Method Future>> simpleQueues() ### Parameters None. ### Endpoint (REST) GET /queue/simple ### Response Returns a list of maps representing simple queues. ### Error Handling Throws `RouterOsException` with message 'اتصل بالراوتر أولاً' (network) if not connected. ``` -------------------------------- ### RouterOsBinaryApi.connect Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/06-routeros-binary-api.md Establishes a connection to a MikroTik RouterOS device using the Binary API protocol. It opens a socket (optionally secure), starts the read loop, and performs MD5 challenge authentication. ```APIDOC ## RouterOsBinaryApi.connect ### Description Establishes a connection to a MikroTik RouterOS device using the Binary API protocol. It opens a socket (optionally secure), starts the read loop, and performs MD5 challenge authentication. ### Method static Future connect(...) ### Parameters - **host** (String) - Required - The host address. - **port** (int) - Required - The port (8728 for plain, 8729 for TLS). - **username** (String) - Required - The username for authentication. - **password** (String) - Required - The password for authentication. - **useSsl** (bool) - Optional (default: false) - If true, uses a SecureSocket connection. - **timeout** (Duration) - Optional (default: 10 seconds) - Connection timeout. ### Behavior Opens a Socket or SecureSocket (accepting certificates for private hosts via onBadCertificate), initializes state, starts the read loop, then performs authentication via _login(). On authentication failure, closes the connection and rethrows the error. ### Return Value Returns a Future that resolves to a RouterOsBinaryApi instance. ``` -------------------------------- ### GET /rest/system/resource Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Retrieves system resource information such as version, board name, CPU load, memory, and uptime. Used by the systemResource() function. ```APIDOC ## GET /rest/system/resource ### Description Retrieves system resource information such as version, board name, CPU load, memory, and uptime. ### Method GET ### Endpoint /rest/system/resource ### Parameters None ### Response #### Success Response (200) - **version** (string) - RouterOS version - **board-name** (string) - Board name - **architecture-name** (string) - Architecture name - **cpu-load** (string) - CPU load percentage - **cpu-count** (string) - Number of CPUs - **cpu-frequency** (string) - CPU frequency - **free-memory** (string) - Free memory - **total-memory** (string) - Total memory - **free-hdd-space** (string) - Free HDD space - **total-hdd-space** (string) - Total HDD space - **uptime** (string) - System uptime #### Response Example { "version": "7.14", "board-name": "CCR1036", "architecture-name": "x86_64", "cpu-load": "5", "cpu-count": "36", "cpu-frequency": "1200", "free-memory": "1048576", "total-memory": "2097152", "free-hdd-space": "1048576", "total-hdd-space": "2097152", "uptime": "1d2h3m4s" } ``` -------------------------------- ### Usage example: error handling and test connection Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/04-connection-provider.md Shows how to test a connection without saving, handle errors, and explicitly disconnect. It uses testConnection, reads the error from state, and shows a snackbar with the result or error. ```dart // اختبار دون حفظ (testConnection لا يحفظ الملف) final probe = RouterProfile( name: 'فحص', host: '192.168.88.2', version: RouterVersion.v7, ); final res = await ref.read(connectionProvider.notifier).testConnection(probe); if (res == null) { // اقرأ رسالة الخطأ من الحالة final err = ref.read(connectionProvider).error ?? 'خطأ غير معروف'; showSnackBar(err); } else { showSnackBar('راوتر ${res.identity} — ${res.protocol.label}'); } // فصل صريح بعد الاستخدام await ref.read(connectionProvider.notifier).disconnect(); ``` -------------------------------- ### VoucherGenerator extreme values example Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Demonstrates automatic clamping: count > 1000 is truncated to 1000, and nameLength > 32 is truncated to 32. The output shows the resulting list length and username length. ```dart // تثبيت تلقائي: count > 1000 يُقتطع إلى 1000، وأطوال رموز > 32 تُقتطع إلى 32 final many = VoucherGenerator.generate(count: 99999, nameLength: 99); print(many.length); // 1000 print(many.first.username.length); // 32 ``` -------------------------------- ### تشغيل أمر من القائمة السريعة أو عبر الخدمة Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/16-screens-tools.md مثال يوضح كيفية تشغيل أمر من القائمة السريعة داخل الشاشة عبر state._run، أو مباشرة عبر الخدمة باستخدام ref.read(mikrotikProvider).runCommand. يُستخدم لأوامر القراءة المعتمدة مثل /system/resource و /ip/route. ```dart // داخل الشاشة: تشغيل أمر من القائمة السريعة await state._run('/system/resource'); // أو عبر الخدمة مباشرة final rows = await ref.read(mikrotikProvider).runCommand('/ip/route'); ``` -------------------------------- ### StorageService Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/09-storage-service.md خدمة التخزين الآمن لحفظ ملفات اتصال الراوترات. نمط singleton: يُعاد دائمًا ذات النسخة. توفر طرقًا لإدارة قائمة ملفات الراوترات، الراوتر النشط، وآخر راوتر مستخدم. ```APIDOC ## StorageService ### Description خدمة التخزين الآمن لحفظ ملفات اتصال الراوترات على التخزين الآمن للجهاز (flutter_secure_storage) مع تشفير على Android و keychain على iOS. نمط singleton: يُعاد دائمًا ذات النسخة. ### Import ```dart import 'package:tikplus_ultra/services/storage_service.dart'; ``` ### Class Signature ```dart class StorageService { StorageService._internal(); static final StorageService _instance = StorageService._internal(); factory StorageService() => _instance; static const _storage = FlutterSecureStorage( aOptions: AndroidOptions(encryptedSharedPreferences: true), iOptions: IOSOptions( accessibility: KeychainAccessibility.first_unlock_this_device, ), ); static const String _keyRouters = 'tikplus.routers'; static const String _keyActiveId = 'tikplus.active_router_id'; static const String _keyLastUsed = 'tikplus.last_used_router_id'; } ``` ### Storage Keys | المفتاح | القيمة | الوصف | |---------|--------|--------| | `tikplus.routers` | JSON array | قائمة `RouterProfile` | | `tikplus.active_router_id` | String | معرّف الراوتر النشط | | `tikplus.last_used_router_id` | String | آخر راوتر استُخدم | ### Methods #### loadAll ```dart Future> loadAll() async; ``` - **Description**: يقرأ `tikplus.routers` ويفك JSON؛ يعيد `[]` على أي قراءة تالفة/غائبة. - **Parameters**: — - **Returns**: Future> #### saveAll ```dart Future saveAll(List routers) async; ``` - **Description**: يكتب كل الملفات كـ JSON. - **Parameters**: - `routers` (List) - Required - قائمة ملفات الراوترات. - **Returns**: Future #### addOrUpdate ```dart Future addOrUpdate(RouterProfile profile) async; ``` - **Description**: يحدّث إن وُجد المعرّف وإلا يضيف. - **Parameters**: - `profile` (RouterProfile) - Required - ملف الراوتر. - **Returns**: Future #### delete ```dart Future delete(String id) async; ``` - **Description**: يحذف؛ إن كان النشط/الأخير يمسح مؤشراته أيضاً. - **Parameters**: - `id` (String) - Required - معرّف الراوتر. - **Returns**: Future #### findById ```dart Future findById(String id) async; ``` - **Description**: يعيد الملف أو `null`. - **Parameters**: - `id` (String) - Required - معرّف الراوتر. - **Returns**: Future #### clearAll ```dart Future clearAll() async; ``` - **Description**: يحذف المفاتيح الثلاثة. - **Parameters**: — - **Returns**: Future #### setActive ```dart Future setActive(String id) async; ``` - **Description**: إدارة الراوتر النشط. - **Parameters**: - `id` (String) - Required - معرّف الراوتر. - **Returns**: Future #### getActiveId ```dart Future getActiveId() async; ``` - **Description**: إدارة الراوتر النشط. - **Parameters**: — - **Returns**: Future #### getActive ```dart Future getActive() async; ``` - **Description**: إدارة الراوتر النشط. - **Parameters**: — - **Returns**: Future #### clearActive ```dart Future clearActive() async; ``` - **Description**: إدارة الراوتر النشط. - **Parameters**: — - **Returns**: Future #### setLastUsed ```dart Future setLastUsed(String id) async; ``` - **Description**: إدارة آخر راوتر مُستخدَم (لإعادة تعبئة نموذج الدخول). - **Parameters**: - `id` (String) - Required - معرّف الراوتر. - **Returns**: Future #### getLastUsedId ```dart Future getLastUsedId() async; ``` - **Description**: إدارة آخر راوتر مُستخدَم (لإعادة تعبئة نموذج الدخول). - **Parameters**: — - **Returns**: Future #### getLastUsed ```dart Future getLastUsed() async; ``` - **Description**: إدارة آخر راوتر مُستخدَم (لإعادة تعبئة نموذج الدخول). - **Parameters**: — - **Returns**: Future ### Example ```dart final storage = ref.read(storageProvider); // أو StorageService() await storage.addOrUpdate(RouterProfile(name: 'فرع 1', host: '10.0.0.1')); final saved = await storage.loadAll(); print(saved.length); ``` ### Error Handling and Separation Example ```dart // delete يعتني بالفهارس المرتبطة await storage.setActive('router-1'); await storage.delete('router-1'); print(await storage.getActiveId()); // null — مسح تلقائياً // الحصول على آخر راوتر مستخدم لإعادة ملء نموذج الدخول final last = await storage.getLastUsed(); if (last != null) { hostCtrl.text = last.host; userCtrl.text = last.username; } ``` ``` -------------------------------- ### مثال مع خيارات غير بديهية للدالة main() Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/01-main-app.md مثال يوضح إعادة بناء نقطة الدخول مع نطاق مزودات يضم تكوينات إضافية (مثل ProviderOverride) قبل تشغيل التطبيق. يمكن إضافة مزودات بديلة مثل MikrotikService وهمي. ```dart // إعادة بناء نقطة الدخول مع نطاق مزودات يضم تكوينات إضافية قبل تشغيل التطبيق void main() { WidgetsFlutterBinding.ensureInitialized(); final scope = ProviderScope( overrides: [ // يمكن إضافة ProviderOverride هنا لتجريب مزودات بديلة (مثلاً MikrotikService وهمي) ], child: const TikPlusApp(), ); runApp(scope); } ``` -------------------------------- ### Public methods: get, post, patch, delete, close Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/05-routeros-rest-api.md Defines the public API methods that wrap the internal _send method. get sends a GET request with optional query parameters, post sends a POST with an optional body (defaults to empty map), patch sends a PATCH with a required body, delete sends a DELETE, and close forcefully closes the Dio client. ```dart Future get(String path, {Map? query}) => _send('GET', path, query: query); Future post(String path, [Map? body]) => _send('POST', path, body: body ?? {}); Future patch(String path, Map body) => _send('PATCH', path, body: body); Future delete(String path) => _send('DELETE', path); void close() => _dio.close(force: true); ``` -------------------------------- ### GET /rest/interface Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists all interfaces. Used by the interfaces() function. ```APIDOC ## GET /rest/interface ### Description Lists all interfaces. ### Method GET ### Endpoint /rest/interface ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Interface ID - **name** (string) - Interface name - **type** (string) - Interface type - **running** (string) - Running status - **disabled** (string) - Disabled flag - **comment** (string) - Comment - **mac-address** (string) - MAC address - **actual-mtu** (string) - Actual MTU - **rx-byte** (string) - Received bytes - **tx-byte** (string) - Transmitted bytes #### Response Example [ { ".id": "*1", "name": "ether1", "type": "ether", "running": "true", "disabled": "false", "comment": "", "mac-address": "00:11:22:33:44:55", "actual-mtu": "1500", "rx-byte": "1024", "tx-byte": "2048" } ] ``` -------------------------------- ### التوقيع الكامل للدالة main() Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/01-main-app.md الدالة main() هي نقطة الدخول التي يشغّلها Flutter تلقائياً. تستدعي WidgetsFlutterBinding.ensureInitialized() ثم runApp مع ProviderScope يحتضن TikPlusApp. ```dart void main() { WidgetsFlutterBinding.ensureInitialized(); runApp(const ProviderScope(child: TikPlusApp())); } ``` -------------------------------- ### GET /rest/queue/simple Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists simple queues. Used by the simpleQueues() function. ```APIDOC ## GET /rest/queue/simple ### Description Lists simple queues. ### Method GET ### Endpoint /rest/queue/simple ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Queue ID - **name** (string) - Queue name - **target** (string) - Target address - **max-limit** (string) - Max limit - ... (other fields) #### Response Example [ { ".id": "*1", "name": "queue1", "target": "192.168.1.0/24", "max-limit": "10M/20M" } ] ``` -------------------------------- ### GET /rest/ip/dhcp-server/lease Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists DHCP leases. Used by the dhcpLeases() function. ```APIDOC ## GET /rest/ip/dhcp-server/lease ### Description Lists DHCP leases. ### Method GET ### Endpoint /rest/ip/dhcp-server/lease ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Lease ID - **address** (string) - IP address - **mac-address** (string) - MAC address - **host-name** (string) - Host name - **status** (string) - Status - **server** (string) - Server name - **expires-after** (string) - Expiration time - **comment** (string) - Comment - **dynamic** (string) - Dynamic flag #### Response Example [ { ".id": "*1", "address": "192.168.1.100", "mac-address": "00:11:22:33:44:55", "host-name": "host1", "status": "bound", "server": "dhcp1", "expires-after": "1d", "comment": "", "dynamic": "false" } ] ``` -------------------------------- ### GET /rest/ip/address Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists IP addresses. Used by the ipAddresses() function. ```APIDOC ## GET /rest/ip/address ### Description Lists IP addresses. ### Method GET ### Endpoint /rest/ip/address ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Address ID - **address** (string) - IP address - **network** (string) - Network - **interface** (string) - Interface name - **disabled** (string) - Disabled flag - **dynamic** (string) - Dynamic flag - **comment** (string) - Comment #### Response Example [ { ".id": "*1", "address": "192.168.1.1/24", "network": "192.168.1.0", "interface": "ether1", "disabled": "false", "dynamic": "false", "comment": "" } ] ``` -------------------------------- ### GET /rest/ppp/secret Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists PPPoE secrets. Used by the pppoeSecrets() function. ```APIDOC ## GET /rest/ppp/secret ### Description Lists PPPoE secrets. ### Method GET ### Endpoint /rest/ppp/secret ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Secret ID - **name** (string) - Username - **password** (string) - Password - **service** (string) - Service type - **profile** (string) - Profile name - **comment** (string) - Comment - **disabled** (string) - Disabled flag - **local-address** (string) - Local address - **remote-address** (string) - Remote address #### Response Example [ { ".id": "*1", "name": "pppoe1", "password": "pass", "service": "pppoe", "profile": "default", "comment": "", "disabled": "false", "local-address": "", "remote-address": "" } ] ``` -------------------------------- ### GET /rest/ip/hotspot/user Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists all hotspot users. Used by the hotspotUsers() function. ```APIDOC ## GET /rest/ip/hotspot/user ### Description Lists all hotspot users. ### Method GET ### Endpoint /rest/ip/hotspot/user ### Parameters None ### Response #### Success Response (200) - **.id** (string) - User ID - **name** (string) - Username - **password** (string) - Password - **profile** (string) - Profile name - **comment** (string) - Comment - **disabled** (string) - Disabled flag - **limit-uptime** (string) - Uptime limit - **limit-bytes-total** (string) - Total bytes limit #### Response Example [ { ".id": "*1", "name": "user1", "password": "pass", "profile": "default", "comment": "", "disabled": "false", "limit-uptime": "", "limit-bytes-total": "" } ] ``` -------------------------------- ### RouterProfile Constructor Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/03-models.md Creates a new RouterProfile instance with optional parameters and defaults. ```APIDOC ## RouterProfile Constructor ### Description Creates a new RouterProfile instance representing a saved connection profile for a MikroTik router. ### Constructor Signature ```dart RouterProfile({ String? id, required this.name, required this.host, this.username = 'admin', this.password = '', this.restPort = 80, this.apiPort = 8728, this.version = RouterVersion.auto, this.useSsl = false, this.lastDetected, }) : id = id ?? const Uuid().v4(); ``` ### Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | id | String? | No | `Uuid().v4()` | Unique identifier | | name | String | Yes | — | Display name of the router | | host | String | Yes | — | Address (IP or domain name) | | username | String | No | `'admin'` | RouterOS username | | password | String | No | `''` | Password | | restPort | int | No | `80` | REST API port (v7) | | apiPort | int | No | `8728` | Binary API port (v6) | | version | RouterVersion | No | `RouterVersion.auto` | Communication protocol version | | useSsl | bool | No | `false` | Enable HTTPS/TLS | | lastDetected | RouterVersion? | No | `null` | Last automatically detected version | ### Example ```dart final profile = RouterProfile( name: 'فرع المدينة', host: '192.168.88.1', username: 'admin', password: 's3cret', ); ``` ``` -------------------------------- ### GET /rest/ip/firewall/filter Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists firewall filter rules. Used by the firewallRules() function. ```APIDOC ## GET /rest/ip/firewall/filter ### Description Lists firewall filter rules. ### Method GET ### Endpoint /rest/ip/firewall/filter ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Rule ID - **chain** (string) - Chain - **action** (string) - Action - **protocol** (string) - Protocol - **src-address** (string) - Source address - **dst-address** (string) - Destination address - **dst-port** (string) - Destination port - **in-interface** (string) - Input interface - **out-interface** (string) - Output interface - **comment** (string) - Comment - **disabled** (string) - Disabled flag - **bytes** (string) - Bytes - **packets** (string) - Packets #### Response Example [ { ".id": "*1", "chain": "input", "action": "accept", "protocol": "tcp", "src-address": "", "dst-address": "", "dst-port": "", "in-interface": "", "out-interface": "", "comment": "", "disabled": "false", "bytes": "0", "packets": "0" } ] ``` -------------------------------- ### Import splash and login screens Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/14-screens-login-splash.md Shows the import statements for the splash and login screen files. ```dart import 'package:tikplus_ultra/screens/splash_screen.dart'; import 'package:tikplus_ultra/screens/login_screen.dart'; ``` -------------------------------- ### command Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/api-reference/06-routeros-binary-api.md Executes a print command on a given path with optional parameters, query, and proplist. Returns the rows from the reply. ```APIDOC ## command ### Description Executes a print command on the given path. Supports optional parameters, query, and proplist. Returns the rows from the reply. ### Method Dart method ### Signature `Future> command(String path, {Map? params, Map? query, String? proplist})` ### Parameters - **path** (String) - Required - The RouterOS path to print, e.g., `/system/resource/print`. - **params** (Map?) - Optional - Additional parameters to include in the sentence. - **query** (Map?) - Optional - Query parameters to filter results. - **proplist** (String?) - Optional - Property list to request specific properties. ### Returns `Future>` - The rows returned by the print command. ``` -------------------------------- ### GET /rest/ppp/active Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists active PPPoE sessions. Used by the pppoeActive() function. ```APIDOC ## GET /rest/ppp/active ### Description Lists active PPPoE sessions. ### Method GET ### Endpoint /rest/ppp/active ### Parameters None ### Response #### Success Response (200) - **name** (string) - Username - **service** (string) - Service type - **address** (string) - IP address - **uptime** (string) - Uptime - **caller-id** (string) - Caller ID #### Response Example [ { "name": "pppoe1", "service": "pppoe", "address": "192.168.1.1", "uptime": "1h", "caller-id": "" } ] ``` -------------------------------- ### GET /rest/ip/hotspot/user/profile Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists hotspot user profiles. Used by the hotspotProfiles() function. ```APIDOC ## GET /rest/ip/hotspot/user/profile ### Description Lists hotspot user profiles. ### Method GET ### Endpoint /rest/ip/hotspot/user/profile ### Parameters None ### Response #### Success Response (200) - **.id** (string) - Profile ID - **name** (string) - Profile name - **rate-limit** (string) - Rate limit - ... (other fields) #### Response Example [ { ".id": "*1", "name": "default", "rate-limit": "1M/1M" } ] ``` -------------------------------- ### GET /rest/ip/hotspot/active Source: https://github.com/alshmryantqam-debug/saif.net-router-manag/blob/main/_autodocs/endpoints.md Lists active hotspot sessions. Used by the hotspotActive() function. ```APIDOC ## GET /rest/ip/hotspot/active ### Description Lists active hotspot sessions. ### Method GET ### Endpoint /rest/ip/hotspot/active ### Parameters None ### Response #### Success Response (200) - **user** (string) - Username - **bytes-in** (string) - Bytes in - **bytes-out** (string) - Bytes out - ... (other fields) #### Response Example [ { "user": "user1", "bytes-in": "1024", "bytes-out": "2048" } ] ```