simulacion de estados y flujo de notificacion, modificacion de estilos en todas las vistas
This commit is contained in:
38
recolecta_app/lib/features/alerts/alerts_provider.dart
Normal file
38
recolecta_app/lib/features/alerts/alerts_provider.dart
Normal file
@@ -0,0 +1,38 @@
|
||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||
|
||||
class AppAlert {
|
||||
final String id;
|
||||
final String title;
|
||||
final String body;
|
||||
final DateTime timestamp;
|
||||
|
||||
AppAlert({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.body,
|
||||
required this.timestamp,
|
||||
});
|
||||
}
|
||||
|
||||
class AlertsNotifier extends Notifier<List<AppAlert>> {
|
||||
@override
|
||||
List<AppAlert> build() => [];
|
||||
|
||||
void addAlert(String title, String body) {
|
||||
state = [
|
||||
AppAlert(
|
||||
id: DateTime.now().millisecondsSinceEpoch.toString(),
|
||||
title: title,
|
||||
body: body,
|
||||
timestamp: DateTime.now(),
|
||||
),
|
||||
...state,
|
||||
];
|
||||
}
|
||||
|
||||
void clearAll() => state = [];
|
||||
}
|
||||
|
||||
final alertsProvider = NotifierProvider<AlertsNotifier, List<AppAlert>>(
|
||||
AlertsNotifier.new,
|
||||
);
|
||||
Reference in New Issue
Block a user