- Setting.fromDocument con valores por defecto (null-safe) - SettingsProvider crea Setting vacio si el backend falla - support_view: guard para settings null - profile_view: seccion 'Acceso con correo' con toggle, campos email/password/confirmar, envia OTP, verifica codigo Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
711 B
Dart
29 lines
711 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:prosapp_web_app/models/setting.dart';
|
|
import 'package:prosapp_web_app/services/api_service.dart';
|
|
|
|
class SettingsProvider extends ChangeNotifier {
|
|
Setting? settings;
|
|
bool isLoading = true;
|
|
final _api = ApiService.instance;
|
|
|
|
SettingsProvider() {
|
|
getSettings();
|
|
}
|
|
|
|
getSettings() async {
|
|
try {
|
|
final data = await _api.get('/settings');
|
|
if (data != null) {
|
|
settings = Setting.fromDocument(data as Map<String, dynamic>);
|
|
}
|
|
} catch (e) {
|
|
print('Error obteniendo los settings: $e');
|
|
} finally {
|
|
settings ??= Setting.fromDocument({});
|
|
isLoading = false;
|
|
notifyListeners();
|
|
}
|
|
}
|
|
}
|