fix: resolve 2 remaining strict analysis errors

- introPage.dart: Convert fireItems to proper static function closure
- mainDrawer.dart: Convert unreadCount int to String for Text widget
This commit is contained in:
vjrj 2026-03-06 11:21:06 +01:00
parent 1864e5b105
commit 7a4c9fb3bc
61 changed files with 1386 additions and 1202 deletions

View file

@ -1,4 +1,4 @@
export 'appActions.dart';
export 'yourLocationActions.dart';
export 'fireMapActions.dart';
export 'fireNotificationActions.dart';
export 'fireNotificationActions.dart';
export 'yourLocationActions.dart';

View file

@ -1,23 +1,25 @@
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'dart:async';
import 'package:flutter_map/flutter_map.dart';
import 'package:connectivity_plus/connectivity_plus.dart';
import 'package:flutter_map/flutter_map.dart';
import '../models/fireNotification.dart';
import '../models/yourLocation.dart';
abstract class AppActions {}
class FetchYourLocationsAction extends AppActions {
Completer<Null>? refreshCallback;
FetchYourLocationsAction([this.refreshCallback]);
Completer<void>? refreshCallback;
}
class PersistAppStateAction extends AppActions {}
class FetchYourLocationsSucceededAction extends AppActions {
final List<YourLocation> fetchedYourLocations;
FetchYourLocationsSucceededAction(this.fetchedYourLocations);
final List<YourLocation> fetchedYourLocations;
}
class FetchFireNotificationsAction extends AppActions {}
@ -25,45 +27,45 @@ class FetchFireNotificationsAction extends AppActions {}
class FetchMonitoredAreasAction extends AppActions {}
class FetchYourLocationsFailedAction extends AppActions {
final Exception error;
FetchYourLocationsFailedAction(this.error);
final Exception error;
}
class OnUserTokenAction extends AppActions {
final String token;
OnUserTokenAction(this.token);
final String token;
}
class OnUserCreatedAction extends AppActions {
final String userId;
OnUserCreatedAction(this.userId);
final String userId;
}
class OnUserLangAction extends AppActions {
final String lang;
OnUserLangAction(this.lang);
final String lang;
}
class FetchFireNotificationsSucceededAction extends AppActions {
final List<FireNotification> fetchedFireNotifications;
final int unreadCount;
FetchFireNotificationsSucceededAction(
this.fetchedFireNotifications, this.unreadCount);
final List<FireNotification> fetchedFireNotifications;
final int unreadCount;
}
class FetchMonitoredAreasSucceededAction extends AppActions {
final List<Polyline> monitoredAreas;
FetchMonitoredAreasSucceededAction(this.monitoredAreas);
final List<Polyline> monitoredAreas;
}
class OnConnectivityChanged extends AppActions {
final List<ConnectivityResult> connectionStatus;
OnConnectivityChanged(this.connectionStatus);
final List<ConnectivityResult> connectionStatus;
}

View file

@ -1,5 +1,5 @@
import 'actions.dart';
import '../models/appState.dart';
import 'actions.dart';
AppState appReducer(AppState state, action) {
if (action is FetchYourLocationsSucceededAction) {

View file

@ -1,14 +1,15 @@
import 'dart:async';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:flutter_map/src/layer/polyline_layer.dart';
import 'package:get_it/get_it.dart';
import 'package:objectid/objectid.dart';
import 'package:redux/redux.dart';
import '../models/appState.dart';
import '../models/fireNotification.dart';
import '../models/fireNotificationsPersist.dart';
import '../models/firesApi.dart';
import '../models/yourLocation.dart';
import '../models/yourLocationPersist.dart';
import '../objectIdUtils.dart';
import 'actions.dart';
@ -55,20 +56,20 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
if (action is AddYourLocationAction) {
if (action.loc.subscribed) {
subscribeViaApi(store, action.loc, (sub) {
store.dispatch(new AddedYourLocationAction(sub));
subscribeViaApi(store, action.loc, (YourLocation sub) {
store.dispatch(AddedYourLocationAction(sub));
persistYourLocations(store.state.yourLocations);
});
} else {
// No subscribed (only local)
store.dispatch(new AddedYourLocationAction(action.loc));
store.dispatch(AddedYourLocationAction(action.loc));
persistYourLocations(store.state.yourLocations);
}
getFiresStatsInLocation(store, action.loc);
}
if (action is DeleteYourLocationAction) {
store.dispatch(new DeletedYourLocationAction(action.loc.id));
store.dispatch(DeletedYourLocationAction(action.loc.id));
if (action.loc.subscribed) {
unsubsViaApi(store, action.loc.id, () {
persistYourLocations(store.state.yourLocations);
@ -79,17 +80,17 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
}
if (action is DeleteFireNotificationAction) {
store.dispatch(new DeletedFireNotificationAction(action.notif));
store.dispatch(DeletedFireNotificationAction(action.notif));
persistFireNotifications(store.state.fireNotifications);
}
if (action is DeleteAllFireNotificationAction) {
store.dispatch(new DeletedAllFireNotificationAction());
store.dispatch(DeletedAllFireNotificationAction());
persistFireNotifications(store.state.fireNotifications);
}
if (action is AddFireNotificationAction) {
store.dispatch(new AddedFireNotificationAction(action.notif));
store.dispatch(AddedFireNotificationAction(action.notif));
persistFireNotifications(store.state.fireNotifications);
}
@ -104,28 +105,28 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
if (action is UpdateYourLocationAction) {
if (action.loc.subscribed)
debounceLocationUpdate(
Duration(seconds: 2),
const Duration(seconds: 2),
() => api
.getFiresInLocation(
state: store.state,
lat: action.loc.lat,
lon: action.loc.lon,
distance: action.loc.distance)
.then((result) => store.dispatch(result)));
store.dispatch(new UpdatedYourLocationAction(action.loc));
.then((UpdateFireMapStatsAction result) => store.dispatch(result)));
store.dispatch(UpdatedYourLocationAction(action.loc));
persistYourLocations(store.state.yourLocations);
}
if (action is SubscribeConfirmAction) {
subscribeViaApi(store, action.loc, (sub) {
store.dispatch(new UpdateYourLocationAction(action.loc));
subscribeViaApi(store, action.loc, (YourLocation sub) {
store.dispatch(UpdateYourLocationAction(action.loc));
persistYourLocations(store.state.yourLocations);
});
}
if (action is UnSubscribeAction) {
unsubsViaApi(store, action.loc.id, () {
store.dispatch(new UpdateYourLocationAction(action.loc));
store.dispatch(UpdateYourLocationAction(action.loc));
persistYourLocations(store.state.yourLocations);
});
}
@ -133,21 +134,21 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
if (action is ToggleSubscriptionAction) {
if (action.loc.subscribed) {
subscribeViaApi(store, action.loc,
(sub) => store.dispatch(new ToggledSubscriptionAction(sub)));
(YourLocation sub) => store.dispatch(ToggledSubscriptionAction(sub)));
} else {
unsubsViaApi(store, action.loc.id,
() => store.dispatch(new ToggledSubscriptionAction(action.loc)));
() => store.dispatch(ToggledSubscriptionAction(action.loc)));
}
}
if (action is ReadFireNotificationAction) {
store.dispatch(new ReadedFireNotificationAction(action.notif));
store.dispatch(ReadedFireNotificationAction(action.notif));
persistFireNotifications(store.state.fireNotifications);
}
if (action is FetchYourLocationsAction) {
// Use the api to fetch the YourLocations
loadYourLocations().then((localLocations) {
loadYourLocations().then((List<YourLocation> localLocations) {
api
.fetchYourLocations(store.state)
.then((List<YourLocation> subscribedLocations) {
@ -155,61 +156,63 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
// Our reducer will then update the State using these YourLocations.
print('Subscribed to: ${subscribedLocations.length}');
// unsubscribe all locally to sync the subs state
localLocations.forEach((location) => location.subscribed = false);
for (final YourLocation location in localLocations) {
location.subscribed = false;
}
print('Local persisted: ${localLocations.length}');
subscribedLocations.forEach((subsLoc) {
var locSubs = localLocations.firstWhere(
(localLocation) => localLocation.id == subsLoc.id, orElse: () {
for (final YourLocation subsLoc in subscribedLocations) {
final YourLocation locSubs = localLocations.firstWhere(
(YourLocation localLocation) => localLocation.id == subsLoc.id, orElse: () {
localLocations.add(subsLoc);
return subsLoc;
});
locSubs.subscribed = true;
});
}
store.dispatch(new FetchYourLocationsSucceededAction(localLocations));
store.dispatch(FetchYourLocationsSucceededAction(localLocations));
persistYourLocations(localLocations);
localLocations.forEach((yl) {
for (final YourLocation yl in localLocations) {
api
.getFiresInLocation(
state: store.state,
lat: yl.lat,
lon: yl.lon,
distance: yl.distance)
.then((value) {
.then((UpdateFireMapStatsAction value) {
yl.currentNumFires = value.numFires;
store.dispatch(new UpdateYourLocationAction(yl));
store.dispatch(UpdateYourLocationAction(yl));
});
});
}
final Completer<Null>? completer = action.refreshCallback;
final Completer<void>? completer = action.refreshCallback;
completer?.complete(null);
});
}).catchError((Exception onError) {
// If it fails, dispatch a failure action. The reducer will
// update the state with the error.
store.dispatch(new FetchYourLocationsFailedAction(onError));
store.dispatch(FetchYourLocationsFailedAction(onError));
});
}
if (action is FetchFireNotificationsAction) {
loadFireNotifications().then((fireNotifications) {
loadFireNotifications().then((List<FireNotification> fireNotifications) {
int unread = 0;
for (FireNotification notif in fireNotifications) {
for (final FireNotification notif in fireNotifications) {
if (!notif.read) {
unread++;
}
}
store.dispatch(
new FetchFireNotificationsSucceededAction(fireNotifications, unread));
FetchFireNotificationsSucceededAction(fireNotifications, unread));
persistFireNotifications(fireNotifications);
});
}
if (action is FetchMonitoredAreasAction) {
api.getMonitoredAreas(state: store.state).then((result) {
api.getMonitoredAreas(state: store.state).then((List<Polyline> result) {
// store.dispatch()
store.dispatch(new FetchMonitoredAreasSucceededAction(result));
store.dispatch(FetchMonitoredAreasSucceededAction(result));
});
}
@ -217,11 +220,11 @@ void fetchDataMiddleware(Store<AppState> store, action, NextDispatcher next) {
api
.markFalsePositive(store.state, store.state.user.token,
action.notif.sealed, action.type)
.then((result) {
.then((bool result) {
if (result) {
// Not necessary
getFiresStatsInFire(store, action.notif);
store.dispatch(new UpdatedFireNotificationAction(action.notif));
store.dispatch(UpdatedFireNotificationAction(action.notif));
}
});
}
@ -237,10 +240,10 @@ void getFiresStatsInLocation(Store<AppState> store, YourLocation loc) {
lat: loc.lat,
lon: loc.lon,
distance: loc.distance)
.then((result) {
.then((UpdateFireMapStatsAction result) {
store.dispatch(result);
loc.currentNumFires = result.numFires;
store.dispatch(new UpdateYourLocationAction(loc));
store.dispatch(UpdateYourLocationAction(loc));
});
}
@ -251,11 +254,11 @@ void getFiresStatsInFire(Store<AppState> store, FireNotification notif) {
lat: notif.lat,
lon: notif.lon,
distance: 1) // FalsePositive/server/publications.js
.then((result) => store.dispatch(result));
.then((UpdateFireMapStatsAction result) => store.dispatch(result));
}
void unsubsViaApi(Store<AppState> store, ObjectId id, onUnsubs) {
api.unsubscribe(store.state, id.hexString).then((res) {
api.unsubscribe(store.state, id.hexString).then((bool res) {
onUnsubs();
persistYourLocations(store.state.yourLocations);
});
@ -263,8 +266,8 @@ void unsubsViaApi(Store<AppState> store, ObjectId id, onUnsubs) {
void subscribeViaApi(
Store<AppState> store, YourLocation loc, Function(YourLocation) onSubs) {
api.subscribe(store.state, loc).then((subsId) {
YourLocation sub = loc;
api.subscribe(store.state, loc).then((String subsId) {
final YourLocation sub = loc;
// if (loc.id != subsId) {
sub.id = objectIdFromJson(subsId);
// }
@ -274,12 +277,12 @@ void subscribeViaApi(
}
void createUser(Store<AppState> store, String lang, String token) {
assert(token != null, "User lang is null");
assert(token != null, "User mobile token is null");
api.createUser(store.state, token, lang).then((userId) {
store.dispatch(new OnUserCreatedAction(userId));
store.dispatch(new FetchYourLocationsAction());
store.dispatch(new FetchFireNotificationsAction());
store.dispatch(new FetchMonitoredAreasAction());
assert(token != null, 'User lang is null');
assert(token != null, 'User mobile token is null');
api.createUser(store.state, token, lang).then((String userId) {
store.dispatch(OnUserCreatedAction(userId));
store.dispatch(FetchYourLocationsAction());
store.dispatch(FetchFireNotificationsAction());
store.dispatch(FetchMonitoredAreasAction());
});
}

View file

@ -1,61 +1,61 @@
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:fires_flutter/models/fireMapState.dart';
import '../models/fireMapState.dart';
import '../models/fireNotification.dart';
import '../models/yourLocation.dart';
abstract class FiresMapActions {}
class UpdateYourLocationMapAction extends FiresMapActions {
final YourLocation loc;
UpdateYourLocationMapAction(
this.loc,
);
final YourLocation loc;
}
class UpdateFireMapStatsAction extends FiresMapActions {
int numFires;
List<dynamic> fires = [];
List<dynamic> falsePos = [];
List<dynamic> industries = [];
UpdateFireMapStatsAction(
{required this.numFires,
required this.fires,
required this.falsePos,
required this.industries});
int numFires;
List<dynamic> fires = <dynamic>[];
List<dynamic> falsePos = <dynamic>[];
List<dynamic> industries = <dynamic>[];
}
class ShowYourLocationMapAction extends FiresMapActions {
YourLocation loc;
ShowYourLocationMapAction(this.loc);
YourLocation loc;
}
class ShowFireNotificationMapAction extends FiresMapActions {
FireNotification notif;
ShowFireNotificationMapAction(this.notif);
FireNotification notif;
}
class EditYourLocationAction extends FiresMapActions {
YourLocation loc;
EditYourLocationAction(this.loc);
YourLocation loc;
}
class EditConfirmYourLocationAction extends FiresMapActions {
YourLocation loc;
EditConfirmYourLocationAction(this.loc);
YourLocation loc;
}
class EditCancelYourLocationAction extends FiresMapActions {
YourLocation loc;
EditCancelYourLocationAction(this.loc);
YourLocation loc;
}
class SelectMapLayerAction extends FiresMapActions {
final FireMapLayer layer;
SelectMapLayerAction(this.layer);
final FireMapLayer layer;
}

View file

@ -1,28 +1,29 @@
import 'package:redux/redux.dart';
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:objectid/objectid.dart';
import 'package:redux/redux.dart';
import '../models/fireMapState.dart';
import '../models/yourLocation.dart';
import 'actions.dart';
final fireMapReducer = combineReducers<FireMapState>([
new TypedReducer<FireMapState, ShowYourLocationMapAction>(
final Reducer<FireMapState> fireMapReducer = combineReducers<FireMapState>(<Reducer<FireMapState>>[
TypedReducer<FireMapState, ShowYourLocationMapAction>(
_showYourLocationMap),
new TypedReducer<FireMapState, ShowFireNotificationMapAction>(
TypedReducer<FireMapState, ShowFireNotificationMapAction>(
_showFireNotificationMap),
new TypedReducer<FireMapState, UpdateFireMapStatsAction>(
TypedReducer<FireMapState, UpdateFireMapStatsAction>(
_updateYourLocationMapStats),
new TypedReducer<FireMapState, SubscribeAction>(_subscribeYourLocationMap),
new TypedReducer<FireMapState, SubscribeConfirmAction>(
TypedReducer<FireMapState, SubscribeAction>(_subscribeYourLocationMap),
TypedReducer<FireMapState, SubscribeConfirmAction>(
_subscribeConfirmYourLocationMap),
new TypedReducer<FireMapState, UnSubscribeAction>(
TypedReducer<FireMapState, UnSubscribeAction>(
_unsubscribeYourLocationMap),
new TypedReducer<FireMapState, EditYourLocationAction>(_editYourLocationMap),
new TypedReducer<FireMapState, EditConfirmYourLocationAction>(
TypedReducer<FireMapState, EditYourLocationAction>(_editYourLocationMap),
TypedReducer<FireMapState, EditConfirmYourLocationAction>(
_editConfirmYourLocationMap),
new TypedReducer<FireMapState, EditCancelYourLocationAction>(
TypedReducer<FireMapState, EditCancelYourLocationAction>(
_editCancelYourLocationMap),
new TypedReducer<FireMapState, SelectMapLayerAction>(_selectMapLayer),
new TypedReducer<FireMapState, UpdateYourLocationMapAction>(
TypedReducer<FireMapState, SelectMapLayerAction>(_selectMapLayer),
TypedReducer<FireMapState, UpdateYourLocationMapAction>(
_updateYourLocationMap)
]);
@ -46,14 +47,13 @@ FireMapState _showYourLocationMap(
status: action.loc.subscribed
? FireMapStatus.unsubscribe
: FireMapStatus.view,
yourLocation: action.loc,
fireNotication: null);
yourLocation: action.loc);
}
FireMapState _showFireNotificationMap(
FireMapState state, ShowFireNotificationMapAction action) {
// TODO: use here you real location?
YourLocation pseudoLoc = new YourLocation(
final YourLocation pseudoLoc = YourLocation(
id: ObjectId(),
lat: action.notif.lat,
lon: action.notif.lon,

View file

@ -1,12 +1,12 @@
import 'package:fires_flutter/models/fireNotification.dart';
import '../models/falsePositiveTypes.dart';
import '../models/fireNotification.dart';
abstract class FireNotificationActions {}
class DeleteFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
DeleteFireNotificationAction(this.notif);
final FireNotification notif;
}
class DeleteAllFireNotificationAction extends FireNotificationActions {
@ -14,15 +14,15 @@ class DeleteAllFireNotificationAction extends FireNotificationActions {
}
class AddFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
AddFireNotificationAction(this.notif);
final FireNotification notif;
}
class DeletedFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
DeletedFireNotificationAction(this.notif);
final FireNotification notif;
}
class DeletedAllFireNotificationAction extends FireNotificationActions {
@ -30,32 +30,32 @@ class DeletedAllFireNotificationAction extends FireNotificationActions {
}
class AddedFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
AddedFireNotificationAction(this.notif);
final FireNotification notif;
}
class ReadFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
ReadFireNotificationAction(this.notif);
final FireNotification notif;
}
class ReadedFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
ReadedFireNotificationAction(this.notif);
final FireNotification notif;
}
class MarkFireAsFalsePositiveAction extends FireNotificationActions {
final FireNotification notif;
final FalsePositiveType type;
MarkFireAsFalsePositiveAction(this.notif, this.type);
final FireNotification notif;
final FalsePositiveType type;
}
class UpdatedFireNotificationAction extends FireNotificationActions {
final FireNotification notif;
UpdatedFireNotificationAction(this.notif);
final FireNotification notif;
}

View file

@ -1,44 +1,44 @@
import 'package:fires_flutter/models/fireNotification.dart';
import 'package:redux/redux.dart';
import '../models/fireNotification.dart';
import 'actions.dart';
final fireNotificationReducer = combineReducers<List<FireNotification>>([
new TypedReducer<List<FireNotification>, AddedFireNotificationAction>(
final Reducer<List<FireNotification>> fireNotificationReducer = combineReducers<List<FireNotification>>(<Reducer<List<FireNotification>>>[
TypedReducer<List<FireNotification>, AddedFireNotificationAction>(
_addedFireNotification),
new TypedReducer<List<FireNotification>, DeletedFireNotificationAction>(
TypedReducer<List<FireNotification>, DeletedFireNotificationAction>(
_deletedFireNotification),
new TypedReducer<List<FireNotification>, UpdatedFireNotificationAction>(
TypedReducer<List<FireNotification>, UpdatedFireNotificationAction>(
_updatedFireNotification),
new TypedReducer<List<FireNotification>, DeletedAllFireNotificationAction>(
TypedReducer<List<FireNotification>, DeletedAllFireNotificationAction>(
_deletedAllFireNotifications),
new TypedReducer<List<FireNotification>, ReadedFireNotificationAction>(
TypedReducer<List<FireNotification>, ReadedFireNotificationAction>(
_readedFireNotification)
]);
List<FireNotification> _addedFireNotification(
List<FireNotification> notifications, AddedFireNotificationAction action) {
return new List.from(notifications)..insert(0, action.notif);
return List.from(notifications)..insert(0, action.notif);
}
List<FireNotification> _deletedFireNotification(
List<FireNotification> notifications,
DeletedFireNotificationAction action) {
return new List.from(notifications)..remove(action.notif);
return List.from(notifications)..remove(action.notif);
}
List<FireNotification> _updatedFireNotification(
List<FireNotification> notifications,
UpdatedFireNotificationAction action) {
return notifications
.map((notif) => notif.id == action.notif.id ? action.notif : notif)
.map((FireNotification notif) => notif.id == action.notif.id ? action.notif : notif)
.toList();
}
List<FireNotification> _readedFireNotification(
List<FireNotification> notifications, ReadedFireNotificationAction action) {
return notifications
.map((yourLocation) =>
.map((FireNotification yourLocation) =>
yourLocation.id == action.notif.id ? action.notif : yourLocation)
.toList();
}
@ -46,5 +46,5 @@ List<FireNotification> _readedFireNotification(
List<FireNotification> _deletedAllFireNotifications(
List<FireNotification> notifications,
DeletedAllFireNotificationAction action) {
return [];
return <FireNotification>[];
}

View file

@ -10,7 +10,7 @@ import 'yourLocationsReducer.dart';
// We create the State reducer by combining many smaller reducers into one!
AppState appStateReducer(AppState prevState, action) {
var state = appReducer(prevState, action);
final AppState state = appReducer(prevState, action);
return AppState(
yourLocations: yourLocationsReducer(state.yourLocations, action),
fireNotifications:

View file

@ -1,5 +1,5 @@
import 'actions.dart';
import '../models/user.dart';
import 'actions.dart';
User userReducer(User user, action) {
if (action is OnUserCreatedAction) return user.copyWith(userId: action.userId);

View file

@ -1,66 +1,67 @@
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:objectid/objectid.dart';
import '../models/yourLocation.dart';
abstract class YourLocationActions {}
class AddYourLocationAction extends YourLocationActions {
YourLocation loc;
AddYourLocationAction(this.loc);
YourLocation loc;
}
class AddedYourLocationAction extends YourLocationActions {
YourLocation loc;
AddedYourLocationAction(this.loc);
YourLocation loc;
}
class DeleteYourLocationAction extends YourLocationActions {
YourLocation loc;
DeleteYourLocationAction(this.loc);
YourLocation loc;
}
class DeletedYourLocationAction extends YourLocationActions {
ObjectId id;
DeletedYourLocationAction(this.id);
ObjectId id;
}
class UpdateYourLocationAction extends YourLocationActions {
YourLocation loc;
UpdateYourLocationAction(this.loc);
YourLocation loc;
}
class UpdatedYourLocationAction extends YourLocationActions {
YourLocation loc;
UpdatedYourLocationAction(this.loc);
YourLocation loc;
}
class ToggleSubscriptionAction extends YourLocationActions {
YourLocation loc;
ToggleSubscriptionAction(this.loc);
YourLocation loc;
}
class ToggledSubscriptionAction extends YourLocationActions {
YourLocation loc;
ToggledSubscriptionAction(this.loc);
YourLocation loc;
}
class SubscribeAction extends YourLocationActions {}
class SubscribeConfirmAction extends YourLocationActions {
YourLocation loc;
SubscribeConfirmAction(this.loc);
YourLocation loc;
}
class UnSubscribeAction extends YourLocationActions {
YourLocation loc;
UnSubscribeAction(this.loc);
YourLocation loc;
}

View file

@ -1,35 +1,35 @@
import 'package:fires_flutter/models/yourLocation.dart';
import 'package:redux/redux.dart';
import '../models/yourLocation.dart';
import 'actions.dart';
final yourLocationsReducer = combineReducers<List<YourLocation>>([
new TypedReducer<List<YourLocation>, AddedYourLocationAction>(
final Reducer<List<YourLocation>> yourLocationsReducer = combineReducers<List<YourLocation>>(<Reducer<List<YourLocation>>>[
TypedReducer<List<YourLocation>, AddedYourLocationAction>(
_addedYourLocation),
new TypedReducer<List<YourLocation>, DeletedYourLocationAction>(
TypedReducer<List<YourLocation>, DeletedYourLocationAction>(
_deletedYourLocation),
new TypedReducer<List<YourLocation>, UpdatedYourLocationAction>(
TypedReducer<List<YourLocation>, UpdatedYourLocationAction>(
_updatedYourLocation),
new TypedReducer<List<YourLocation>, ToggledSubscriptionAction>(
TypedReducer<List<YourLocation>, ToggledSubscriptionAction>(
_toggledSubscriptionAction)
]);
List<YourLocation> _addedYourLocation(
List<YourLocation> yourLocations, AddedYourLocationAction action) {
return new List.from(yourLocations)..add(action.loc);
return List.from(yourLocations)..add(action.loc);
}
List<YourLocation> _deletedYourLocation(
List<YourLocation> yourLocations, DeletedYourLocationAction action) {
return yourLocations
.where((yourLocation) => yourLocation.id != action.id)
.where((YourLocation yourLocation) => yourLocation.id != action.id)
.toList();
}
List<YourLocation> _updatedYourLocation(
List<YourLocation> yourLocations, UpdatedYourLocationAction action) {
return yourLocations
.map((yourLocation) =>
.map((YourLocation yourLocation) =>
yourLocation.id == action.loc.id ? action.loc : yourLocation)
.toList();
}
@ -37,7 +37,7 @@ List<YourLocation> _updatedYourLocation(
List<YourLocation> _toggledSubscriptionAction(
List<YourLocation> yourLocations, ToggledSubscriptionAction action) {
return yourLocations
.map((yourLocation) =>
.map((YourLocation yourLocation) =>
yourLocation.id == action.loc.id ? action.loc : yourLocation)
.toList();
}