@@ -19,7 +19,7 @@ class PeriodsRepository {
1919
2020 final Manager manager;
2121
22- PeriodsRepository () : manager = Manager (AppDatabase .instance);
22+ PeriodsRepository () : manager = Manager (AppDatabase .instance);
2323
2424 Future <void > logPeriodFromWatch () async {
2525 debugPrint ('Received request from watch! Logging period now...' );
@@ -125,7 +125,7 @@ class PeriodsRepository {
125125 debugPrint (entry.toString ());
126126
127127 await _validateLogDate (db, entry.date);
128-
128+
129129 final id = await db.insert ('period_logs' , entry.toMap ());
130130
131131 await _recalculateAndAssignPeriods (db);
@@ -146,8 +146,8 @@ class PeriodsRepository {
146146 final db = await dbProvider.database;
147147
148148 final result = await db.query (
149- 'period_logs' ,
150- where: _whereId,
149+ 'period_logs' ,
150+ where: _whereId,
151151 whereArgs: [id],
152152 );
153153
@@ -218,7 +218,7 @@ class PeriodsRepository {
218218 final allEntries = allEntryMaps.map ((e) => PeriodDay .fromMap (e)).toList ();
219219
220220 if (allEntries.isEmpty) {
221- return ;
221+ return ;
222222 }
223223
224224 List <PeriodDay > currentPeriodLogs = [];
@@ -293,7 +293,7 @@ class PeriodsRepository {
293293
294294 if (flowInts.isNotEmpty) {
295295 final monthKey = DateFormat ('MMM' ).format (period.startDate);
296-
296+
297297 allMonthlyFlows.add (
298298 MonthlyFlowData (
299299 monthLabel: monthKey,
@@ -302,7 +302,7 @@ class PeriodsRepository {
302302 );
303303 }
304304 }
305-
305+
306306 return allMonthlyFlows;
307307 }
308308}
@@ -320,8 +320,8 @@ class Manager {
320320 try {
321321 return jsonDecode (jsonString);
322322 } catch (e) {
323- debugPrint ('Error decoding symptoms JSON: $e ' );
324- return [];
323+ debugPrint ('Error decoding symptoms JSON: $e ' );
324+ return [];
325325 }
326326 }
327327
@@ -330,6 +330,7 @@ class Manager {
330330 String _encodeAndValidateSymptoms (List <dynamic > rawSymptoms) {
331331 final List <String > filteredSymptoms = rawSymptoms
332332 .whereType <String >()
333+ .map ((e) => e.toLowerCase ())
333334 .toList ();
334335
335336 return jsonEncode (filteredSymptoms);
@@ -345,7 +346,7 @@ class Manager {
345346 final dbVersion = await db.getVersion ();
346347
347348 final periodLogs = periodLogsRaw.map ((log) {
348- final mutableLog = Map <String , dynamic >.from (log);
349+ final mutableLog = Map <String , dynamic >.from (log);
349350 mutableLog['symptoms' ] = _decodeSymptoms (mutableLog['symptoms' ] as String ? );
350351 return mutableLog;
351352 }).toList ();
@@ -359,7 +360,7 @@ class Manager {
359360 };
360361
361362 final jsonString = jsonEncode (exportData);
362-
363+
363364 return jsonString;
364365 }
365366
@@ -374,7 +375,7 @@ class Manager {
374375 if (! importData.containsKey ('periods' ) || ! importData.containsKey ('period_logs' )) {
375376 throw const FormatException ('Invalid import file: Missing "periods" or "period_logs" data.' );
376377 }
377-
378+
378379 final importedDbVersion = importData['db_version' ] as int ? ;
379380 final currentDbVersion = await db.getVersion ();
380381
@@ -385,18 +386,18 @@ class Manager {
385386 await db.transaction ((txn) async {
386387 await txn.delete ('period_logs' );
387388 await txn.delete ('periods' );
388-
389+
389390 final List periods = importData['periods' ] as List ;
390391 for (final Map <String , dynamic > period in periods.cast <Map <String , dynamic >>()) {
391- final Map <String , dynamic > dataToInsert = Map .from (period)..remove ('id' );
392+ final Map <String , dynamic > dataToInsert = Map .from (period)..remove ('id' );
392393 await txn.insert ('periods' , dataToInsert, conflictAlgorithm: ConflictAlgorithm .replace);
393394 }
394395
395396 final List periodLogsRaw = importData['period_logs' ] as List ;
396397 for (final Map <String , dynamic > logRaw in periodLogsRaw.cast <Map <String , dynamic >>()) {
397398 final Map <String , dynamic > logToInsert = Map .from (logRaw);
398399 logToInsert.remove ('id' );
399-
400+
400401 final symptomsList = logToInsert['symptoms' ];
401402 if (symptomsList is List ) {
402403 logToInsert['symptoms' ] = _encodeAndValidateSymptoms (symptomsList.cast <dynamic >());
@@ -409,9 +410,9 @@ class Manager {
409410 if (rawFlow is int && rawFlow >= 0 && rawFlow < FlowRate .values.length) {
410411 logToInsert['flow' ] = rawFlow;
411412 } else {
412- logToInsert['flow' ] = 0 ;
413+ logToInsert['flow' ] = 0 ;
413414 }
414-
415+
415416 await txn.insert ('period_logs' , logToInsert, conflictAlgorithm: ConflictAlgorithm .replace);
416417 }
417418 });
0 commit comments