feat(data): modèle de données Drift pour la persistance locale
Définit les tables Drift et les identifiants locaux (local_id.dart, tables.dart), régénère app_database.g.dart. build_runner, flutter analyze et build APK debug validés. Versionne les fichiers générés .g.dart : projet solo sans pipeline CI qui relance build_runner, on privilégie un clone immédiatement buildable. Retire la règle **/*.g.dart (et freezed/gr.dart, non utilisés) du .gitignore en conséquence. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
28
lib/infrastructure/local/local_id.dart
Normal file
28
lib/infrastructure/local/local_id.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'dart:math';
|
||||
|
||||
const _crockfordBase32 = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
||||
|
||||
final class LocalIdGenerator {
|
||||
LocalIdGenerator({Random? random}) : _random = random ?? Random.secure();
|
||||
|
||||
final Random _random;
|
||||
|
||||
String newUlid({DateTime? now}) {
|
||||
final timestamp = (now ?? DateTime.now().toUtc()).millisecondsSinceEpoch;
|
||||
final buffer = StringBuffer();
|
||||
|
||||
var remainingTimestamp = timestamp;
|
||||
final timestampChars = List<String>.filled(10, '0');
|
||||
for (var index = 9; index >= 0; index--) {
|
||||
timestampChars[index] = _crockfordBase32[remainingTimestamp & 0x1F];
|
||||
remainingTimestamp >>= 5;
|
||||
}
|
||||
buffer.writeAll(timestampChars);
|
||||
|
||||
for (var index = 0; index < 16; index++) {
|
||||
buffer.write(_crockfordBase32[_random.nextInt(32)]);
|
||||
}
|
||||
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user