// lib/remote/remote_db_uris.dart import 'dart:convert'; class RemoteDbUris { // Schema personalizzato che non attiva ContentResolver. static const _scheme = 'aves-remote'; /// Costruisce un URI fittizio univoco e stabile per un elemento remoto. /// - Se hai un remoteId (hash/uuid) usa quello (preferibile). /// - In alternativa, codifica il remotePath. static String make({String? remoteId, String? remotePath}) { if (remoteId != null && remoteId.trim().isNotEmpty) { // Esempio: aves-remote://rid/ return '$_scheme://rid/${Uri.encodeComponent(remoteId.trim())}'; } if (remotePath != null && remotePath.trim().isNotEmpty) { // Esempio: aves-remote://path/ final b64 = base64Url.encode(utf8.encode(remotePath.trim())); return '$_scheme://path/$b64'; } // Estremo fallback (pochissimo probabile) return '$_scheme://anon/${DateTime.now().microsecondsSinceEpoch}'; } /// Riconosce se un uri รจ fittizio remoto static bool isSynthetic(String? uri) => uri != null && uri.startsWith('$_scheme://'); }