Resolve all lints and deprecation warnings

This commit is contained in:
2026-01-09 10:04:51 -06:00
parent 512577b092
commit a799e9cf59
56 changed files with 2819 additions and 3159 deletions

View File

@@ -1,8 +1,7 @@
import 'package:flutter_riverpod/flutter_riverpod.dart';
import '../models/scripture.dart';
import '../models/cycle_entry.dart';
import 'user_provider.dart';
import 'package:collection/collection.dart'; // For IterableExtension
// For IterableExtension
// State for ScriptureProvider
class ScriptureState {
@@ -36,9 +35,8 @@ class ScriptureState {
// StateNotifier for ScriptureProvider
class ScriptureNotifier extends StateNotifier<ScriptureState> {
final ScriptureDatabase _scriptureDatabase;
final Ref _ref;
ScriptureNotifier(this._scriptureDatabase, this._ref) : super(ScriptureState()) {
ScriptureNotifier(this._scriptureDatabase) : super(ScriptureState()) {
// We don't initialize here directly, as we need the phase from other providers.
// Initialization will be triggered by the UI.
}
@@ -48,11 +46,13 @@ class ScriptureNotifier extends StateNotifier<ScriptureState> {
Future<void> initializeScripture(CyclePhase phase) async {
// Only re-initialize if the phase has changed or no scripture is currently set
if (state.currentPhase != phase || state.currentScripture == null) {
final scriptureCount = _scriptureDatabase.getScriptureCountForPhase(phase.name);
final scriptureCount =
_scriptureDatabase.getScriptureCountForPhase(phase.name);
if (scriptureCount > 0) {
// Use day of year to get a stable initial scripture for the day
final dayOfYear =
DateTime.now().difference(DateTime(DateTime.now().year, 1, 1)).inDays;
final dayOfYear = DateTime.now()
.difference(DateTime(DateTime.now().year, 1, 1))
.inDays;
final initialIndex = dayOfYear % scriptureCount;
state = state.copyWith(
currentPhase: phase,
@@ -73,24 +73,38 @@ class ScriptureNotifier extends StateNotifier<ScriptureState> {
}
void getNextScripture() {
if (state.currentPhase == null || state.maxIndex == null || state.maxIndex == 0) return;
if (state.currentPhase == null ||
state.maxIndex == null ||
state.maxIndex == 0) {
return;
}
final nextIndex = (state.currentIndex + 1) % state.maxIndex!;
_updateScripture(nextIndex);
}
void getPreviousScripture() {
if (state.currentPhase == null || state.maxIndex == null || state.maxIndex == 0) return;
if (state.currentPhase == null ||
state.maxIndex == null ||
state.maxIndex == 0) {
return;
}
final prevIndex = (state.currentIndex - 1 + state.maxIndex!) % state.maxIndex!;
final prevIndex =
(state.currentIndex - 1 + state.maxIndex!) % state.maxIndex!;
_updateScripture(prevIndex);
}
void getRandomScripture() {
if (state.currentPhase == null || state.maxIndex == null || state.maxIndex == 0) return;
if (state.currentPhase == null ||
state.maxIndex == null ||
state.maxIndex == 0) {
return;
}
// Use a proper random number generator for better randomness
final randomIndex = DateTime.now().microsecondsSinceEpoch % state.maxIndex!; // Still using timestamp for simplicity
final randomIndex = DateTime.now().microsecondsSinceEpoch %
state.maxIndex!; // Still using timestamp for simplicity
_updateScripture(randomIndex);
}
@@ -109,5 +123,5 @@ final scriptureDatabaseProvider = Provider((ref) => ScriptureDatabase());
final scriptureProvider =
StateNotifierProvider<ScriptureNotifier, ScriptureState>((ref) {
return ScriptureNotifier(ref.watch(scriptureDatabaseProvider), ref);
return ScriptureNotifier(ref.watch(scriptureDatabaseProvider));
});