import 'package:flutter/material.dart'; import '../../models/located_address.dart'; import '../../models/cart_info.dart'; import '../../models/user.dart'; @immutable class AppState { final BuildContext context; final Locale locale; final User user; final String redirectRoute; final List cartInfos; final LocatedAddress locatedAddress; final String fcmToken; final List lastVisit; final String deviceId; final String tableNumber; AppState({this.context, this.locale, this.user, this.redirectRoute, this.cartInfos, this.locatedAddress, this.fcmToken, this.lastVisit, this.deviceId, this.tableNumber}); factory AppState.init() => AppState(); AppState copyWith({ BuildContext context, Locale locale}) { return AppState( context: context ?? this.context, locale: locale ?? this.locale, user: user ?? this.user, redirectRoute: redirectRoute ?? this.redirectRoute, cartInfos: cartInfos ?? this.cartInfos, locatedAddress: locatedAddress ?? this.locatedAddress, fcmToken: fcmToken ?? this.fcmToken, lastVisit: lastVisit ?? this.lastVisit, deviceId: deviceId ?? this.deviceId, tableNumber: tableNumber ?? this.tableNumber ); } @override int get hashCode => context.hashCode ^ locale.hashCode ^ user.hashCode ^ redirectRoute.hashCode ^ cartInfos.hashCode ^ locatedAddress.hashCode ^ fcmToken.hashCode ^ lastVisit.hashCode ^ deviceId.hashCode ^ tableNumber.hashCode; @override bool operator ==(Object other) => identical(this, other) || other is AppState && context == other.context && locale == other.locale && user == other.user && redirectRoute == other.redirectRoute && cartInfos == other.cartInfos && locatedAddress == other.locatedAddress && fcmToken == other.fcmToken && lastVisit == other.lastVisit && deviceId == other.deviceId && tableNumber == other.tableNumber; @override String toString() => 'AppState(context: $context, locale: $locale), user: $user, ' 'redirectRoute: $redirectRoute, cart info: $cartInfos, ' 'locate address: $locatedAddress, fcm: $fcmToken, ' 'last visit: $lastVisit, deviceId: $deviceId, ' 'tableNumber: $tableNumber'; }