perform patch

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-09-05 14:43:57 +08:00
parent 3bfef21678
commit d80b36ed8f
15 changed files with 179 additions and 170 deletions

View File

@ -29,7 +29,7 @@ class ReferencesBloc extends Bloc<ReferencesEvent, ReferencesState> {
references = refs;
emit(ReferencesLoadedState(references: references));
}
emit(ReferencesLoadedState(references: references));
} catch (e) {
emit( ReferencesErrorState(message: e.toString()));
}

View File

@ -5,6 +5,7 @@ import 'package:equatable/equatable.dart';
import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:unit2/model/roles/pass_check/passer_info.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
import 'package:unit2/sevices/roles/pass_check_services.dart';
import '../../../utils/scanner.dart';
part 'pass_check_event.dart';
@ -12,7 +13,7 @@ part 'pass_check_state.dart';
class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
PassCheckBloc() : super(PassCheckInitial()) {
int? roleId;
RoleIdRoleName? roleIdRoleName;
String? uuid;
bool? otherInputs;
String? io;
@ -25,9 +26,8 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
try {
emit(PassCheckLoadingState());
List<dynamic> response = await PassCheckServices.instance
.getPassCheckArea(roleId: event.roleId, userId: event.userId);
roleId = event.roleId;
emit(AssignAreaLoaded(assignedArea: response, roleId: roleId!));
.getPassCheckArea(roleIdRoleName:RoleIdRoleName(roleId: event.roleIdRoleName.roleId, roleName: event.roleIdRoleName.roleName), userId: event.userId);
emit(AssignAreaLoaded(assignedArea: response, roleIdRoleName: RoleIdRoleName(roleId: event.roleIdRoleName.roleId, roleName: event.roleIdRoleName.roleName)));
} catch (e) {
emit(PassCheckErrorState(message: e.toString()));
}
@ -37,14 +37,14 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checkerId = event.checkerId;
io = event.entranceExit;
token = event.token;
roleId = event.roleId;
roleIdRoleName = event.roleIdRoleName;
assignedArea = event.assignedArea;
emit(SettingSaved(
assignedArea: assignedArea,
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
});
on<ScanError>((event, emit) {
@ -53,7 +53,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
});
on<PerformIncomingPostLog>((event, emit) {
@ -64,7 +64,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: event.temp));
});
@ -77,7 +77,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: null));
});
@ -89,13 +89,13 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
try {
PasserInfo? passerInfo = await PassCheckServices.instance
.getPasserInfo(uuid: uuid!, token: event.token);
if (roleId == 41 || roleId == 13 || roleId == 17 || roleId == 22) {
if (roleIdRoleName!.roleName.toLowerCase() == "41" || roleIdRoleName!.roleName.toLowerCase() == 'qr code scanner' || roleIdRoleName!.roleName.toLowerCase() == 'office/branch chief' || roleIdRoleName!.roleName.toLowerCase() == 'registration in-charge') {
stationId = assignedArea.id;
} else if (roleId == 7) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'barangay chairperson') {
cpId = assignedArea.brgycode;
} else if (roleId == 10) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'purok pres') {
cpId = assignedArea.purokdesc;
} else if (roleId == 16) {
} else if (roleIdRoleName!.roleName.toLowerCase() == 'establishment point-person') {
cpId = assignedArea.id;
}
if (passerInfo == null) {
@ -122,7 +122,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
io: io!.toLowerCase() == "incoming" ? "i" : "o",
otherInputs: otherInputs!,
passerId: uuid!,
roleId: roleId!,
roleId: roleIdRoleName!.roleId,
stationId: stationId,
temp: null));
}
@ -136,7 +136,7 @@ class PassCheckBloc extends Bloc<PassCheckEvent, PassCheckState> {
checker: checkerId!,
io: io!,
otherInputs: otherInputs!,
roleId: roleId!,
roleIdRoleName: roleIdRoleName!,
token: token!));
}
});

View File

@ -8,13 +8,13 @@ abstract class PassCheckEvent extends Equatable {
}
class GetPassCheckAreas extends PassCheckEvent {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final int userId;
const GetPassCheckAreas({required this.roleId, required this.userId});
const GetPassCheckAreas({required this.roleIdRoleName, required this.userId});
}
class SetScannerSettings extends PassCheckEvent {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final String token;
final dynamic assignedArea;
final bool includeOtherInputs;
@ -25,7 +25,7 @@ class SetScannerSettings extends PassCheckEvent {
required this.checkerId,
required this.entranceExit,
required this.includeOtherInputs,
required this.roleId,
required this.roleIdRoleName,
required this.token});
}

View File

@ -23,8 +23,8 @@ class PassCheckLoadingState extends PassCheckState {}
class AssignAreaLoaded extends PassCheckState {
final List<dynamic> assignedArea;
final int roleId;
const AssignAreaLoaded({required this.assignedArea, required this.roleId});
final RoleIdRoleName roleIdRoleName;
const AssignAreaLoaded({required this.assignedArea, required this.roleIdRoleName});
}
class SettingSaved extends PassCheckState {
@ -33,13 +33,13 @@ class SettingSaved extends PassCheckState {
final String io;
final int checker;
final bool otherInputs;
final int roleId;
final RoleIdRoleName roleIdRoleName;
const SettingSaved(
{required this.assignedArea,
required this.checker,
required this.io,
required this.otherInputs,
required this.roleId,
required this.roleIdRoleName,
required this.token});
}

View File

@ -107,6 +107,8 @@ class UserBloc extends Bloc<UserEvent, UserState> {
emit(InternetTimeout(message: timeoutError));
} on Error catch (e) {
emit(LoginErrorState(message: e.toString()));
}catch(e){
emit(LoginErrorState(message: e.toString()));
}
});
on<UuidLogin>((event, emit) async {

View File

@ -35,7 +35,7 @@ class RbacRoleAssignment extends StatelessWidget {
elevation: 0,
centerTitle: true,
backgroundColor: primary,
title: const Text("User Roles Screenss"),
title: const Text("User Roles Screens"),
actions: [
AddLeading(onPressed: () {
BuildContext parent = context;

View File

@ -3,6 +3,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_staggered_animations/flutter_staggered_animations.dart';
import 'package:fluttericon/font_awesome5_icons.dart';
import 'package:unit2/model/login_data/user_info/assigned_area.dart';
import 'package:unit2/model/rbac/assigned_role.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard_icon_generator.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/superadmin_expanded_menu.dart';
import 'package:unit2/screens/unit2/homepage.dart/module-screen.dart';
@ -68,10 +69,6 @@ class _DashBoardState extends State<DashBoard> {
docSmsCards.add(e);
}
});
unit2Cards.forEach((element) {
print(
"${element.moduleName} - ${element.object.name!} - ${element.roleName} ");
});
if (superadminCards.length > 3) {
tempSuperAdminCards = superadminCards.sublist(0, 4);
}
@ -79,6 +76,10 @@ class _DashBoardState extends State<DashBoard> {
tempUnit2Cards = unit2Cards.sublist(0, 4);
}
superadminCards.forEach((el) {
print(el.object.name);
});
return Container(
padding:
const EdgeInsetsDirectional.symmetric(vertical: 24, horizontal: 24),
@ -196,7 +197,7 @@ class _DashBoardState extends State<DashBoard> {
: e.object.name!,
ontap: () {
if (e.object.name!.toLowerCase() == 'pass check') {
PassCheckArguments passCheckArguments = PassCheckArguments(roleId: e.roleId, userId: widget.userId);
PassCheckArguments passCheckArguments = PassCheckArguments(roleIdRoleName: RoleIdRoleName(roleId: e.roleId, roleName: e.roleName), userId: widget.userId);
Navigator.pushNamed(context, '/pass-check', arguments: passCheckArguments);
}
if (e.object.name!.toLowerCase() == 'role based access control') {
@ -312,7 +313,7 @@ class _DashBoardState extends State<DashBoard> {
PassCheckArguments
passCheckArguments =
PassCheckArguments(
roleId: 10,
roleIdRoleName: RoleIdRoleName(roleId: e.roleId, roleName: e.roleName),
userId:
widget.userId);
Navigator.pushNamed(
@ -386,7 +387,7 @@ class _DashBoardState extends State<DashBoard> {
PassCheckArguments
passCheckArguments =
PassCheckArguments(
roleId: 10,
roleIdRoleName: RoleIdRoleName(roleId: e.roleId,roleName: e.roleName),
userId: widget.userId);
Navigator.pushNamed(
context, '/pass-check',
@ -647,7 +648,8 @@ class _DashBoardState extends State<DashBoard> {
? "Field Surveyor"
: e.object.name!,
ontap: () {
Navigator.pushNamed(context, '/passo-home');
Navigator.pushNamed(
context, '/passo-home');
})
: Container(
color: Colors.black,
@ -706,7 +708,13 @@ class _DashBoardState extends State<DashBoard> {
}
class PassCheckArguments {
final int roleId;
final RoleIdRoleName roleIdRoleName;
final int userId;
const PassCheckArguments({required this.roleId, required this.userId});
const PassCheckArguments({required this.roleIdRoleName, required this.userId});
}
class RoleIdRoleName{
final int roleId;
final String roleName;
const RoleIdRoleName({required this.roleId, required this.roleName});
}

View File

@ -271,6 +271,7 @@ class SuperAdminMenu extends StatelessWidget {
roleAssignmentKey
.currentState!
.value['lastname'];
Navigator.of(context).pop();
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext

View File

@ -47,7 +47,7 @@ class _UniT2LoginState extends State<UniT2Login> {
indicatorWidget: const SpinKitFadingCircle(color: Colors.white),
child: BlocConsumer<UserBloc, UserState>(listener: (context, state) {
print(state);
if (state is UserLoggedIn || state is UuidLoaded) {
if (state is UserLoggedIn || state is UuidLoaded || state is LoginErrorState) {
final progress = ProgressHUD.of(context);
progress!.dismiss();
}
@ -94,6 +94,7 @@ class _UniT2LoginState extends State<UniT2Login> {
}));
}
}, builder: (context, state) {
print(state);
if (state is VersionLoaded) {
return Builder(builder: (context) {
if (state.versionInfo!.version != state.apkVersion) {
@ -251,9 +252,7 @@ class _UniT2LoginState extends State<UniT2Login> {
onPressed: () {
final progress =
ProgressHUD.of(context);
FocusScope.of(context).unfocus();
if (_formKey.currentState!
.saveAndValidate()) {
password = _formKey.currentState!
@ -263,7 +262,6 @@ class _UniT2LoginState extends State<UniT2Login> {
progress?.showWithText(
'Logging in...',
);
BlocProvider.of<UserBloc>(context)
.add(UserLogin(
username: username,

View File

@ -302,28 +302,28 @@ class _QRCodeScannerState extends State<QRCodeScanner> {
children: [
SelectedState(
//TODO add api data
title: state.roleId == 41 ||
state.roleId == 13 ||
state.roleId == 17 ||
state.roleId == 22
title: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? state.assignedArea.stationName
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
? state.assignedArea.brgydesc
: state.roleId == 10
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
? state.assignedArea.purokdesc
: state.roleId == 16
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? "Agency"
: "",
subtitle: state.roleId == 41 ||
state.roleId == 13 ||
state.roleId == 17 ||
state.roleId == 22
subtitle: state.roleIdRoleName.roleName.toLowerCase() == "41" ||
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner' ||
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief' ||
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? "Station"
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay chairperson'
? "Barangay"
: state.roleId == 10
: state.roleIdRoleName.roleName.toLowerCase() == 'purok president'
? "Purok"
: state.roleId == 16
: state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? "Agency"
: "",
),

View File

@ -20,9 +20,9 @@ import '../../../../theme-data.dart/form-style.dart';
import '../../../../utils/global.dart';
class QRCodeScannerSettings extends StatefulWidget {
final int roleId;
final int userId;
const QRCodeScannerSettings({super.key, required this.roleId, required this.userId});
final RoleIdRoleName roleIdRoleName;
final int userId;
const QRCodeScannerSettings({super.key, required this.roleIdRoleName, required this.userId});
@override
State<QRCodeScannerSettings> createState() => _QRCodeScannerSettingsState();
@ -172,7 +172,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
////STATION
Container(
child: state.roleId == 41
child: state.roleIdRoleName.roleName.toLowerCase() == "41"
? DropdownButtonFormField(
isExpanded: true,
validator: FormBuilderValidators
@ -219,7 +219,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
},
////BARANGAY
)
: state.roleId == 7
: state.roleIdRoleName.roleName.toLowerCase() == 'barangay nurse'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -270,7 +270,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////PUROK
state.roleId == 10
state.roleIdRoleName.roleName.toLowerCase() == 'checkpoint in-charge'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -323,7 +323,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////Registration InCharge
state.roleId == 22
state.roleIdRoleName.roleName.toLowerCase() == 'registration in-charge'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -398,7 +398,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
],
)
: ////QR Code Scanner
state.roleId == 13
state.roleIdRoleName.roleName.toLowerCase() == 'qr code scanner'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -469,7 +469,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
)
:
////Establishment Point-Person
state.roleId == 16
state.roleIdRoleName.roleName.toLowerCase() == 'establishment point-person'
? Column(
crossAxisAlignment:
CrossAxisAlignment
@ -516,8 +516,8 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
],
)
: ////Office Branch Chief
state.roleId ==
17
state.roleIdRoleName.roleName.toLowerCase() == 'office/branch chief'
? Column(
crossAxisAlignment:
CrossAxisAlignment.start,
@ -578,10 +578,6 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
onPressed: () {
if (_formKey.currentState!
.saveAndValidate()) {
print(scanMode);
print(_includeOtherInputs);
print(checkerId);
print(assignedArea);
Navigator.push(context,
MaterialPageRoute(builder:
(BuildContext context) {
@ -595,7 +591,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
entranceExit: scanMode,
includeOtherInputs:
_includeOtherInputs,
roleId: state.roleId)),
roleIdRoleName: widget.roleIdRoleName)),
child: const QRCodeScanner(),
);
}));
@ -615,7 +611,7 @@ class _QRCodeScannerSettingsState extends State<QRCodeScannerSettings> {
return SomethingWentWrong(
message: state.message, onpressed: () {
context.read<PassCheckBloc>().add(GetPassCheckAreas(roleId: widget.roleId, userId: widget.userId));
context.read<PassCheckBloc>().add(GetPassCheckAreas(roleIdRoleName: widget.roleIdRoleName, userId: widget.userId));
});
}
return Container();

View File

@ -39,16 +39,16 @@ class AuthService {
Map<String, String> baseHeaders = {'Content-Type': 'application/json'};
Map<dynamic, dynamic> responseStatus = {};
String path = Url.instance.authentication();
// try {
try {
http.Response response = await Request.instance
.postRequest(path: path, param: {}, headers: baseHeaders, body: body);
Map data = jsonDecode(response.body);
responseStatus = data;
return responseStatus;
// } catch (e) {
// throw (e.toString());
// }
} catch (e) {
throw (e.toString());
}
}
Future<Map<dynamic,dynamic>> qrLogin({String? uuid, String? password}) async {

View File

@ -8,6 +8,7 @@ import 'package:unit2/model/roles/pass_check/agency_area_type.dart';
import 'package:unit2/model/roles/pass_check/assign_role_area_type.dart';
import 'package:unit2/model/roles/pass_check/barangay_assign_area.dart';
import 'package:unit2/model/roles/pass_check/passer_info.dart';
import 'package:unit2/screens/unit2/homepage.dart/components/dashboard/dashboard.dart';
import 'package:unit2/utils/global.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/utils/request.dart';
@ -20,10 +21,10 @@ class PassCheckServices {
static PassCheckServices get instance => _instance;
Future<List<dynamic>> getPassCheckArea(
{required int roleId, required int userId}) async {
{required RoleIdRoleName roleIdRoleName, required int userId}) async {
String path = Url.instance.getAssignAreas();
Map<String, String> params = {
"assigned_role__role__id": roleId.toString(),
"assigned_role__role__name__icontains": roleIdRoleName.roleName,
"assigned_role__user__id": userId.toString()
};
List<dynamic>? statusResponse;

View File

@ -67,9 +67,12 @@ class AppRouter {
return BlocProvider(
create: (context) => PassCheckBloc()
..add(GetPassCheckAreas(
roleId: arguments.roleId, userId: arguments.userId)),
roleIdRoleName: RoleIdRoleName(
roleId: arguments.roleIdRoleName.roleId,
roleName: arguments.roleIdRoleName.roleName),
userId: arguments.userId)),
child: QRCodeScannerSettings(
roleId: arguments.roleId,
roleIdRoleName: arguments.roleIdRoleName,
userId: arguments.userId,
),
);

View File

@ -22,20 +22,20 @@ class Request {
response = await get(Uri.https(host, path!, param), headers: headers)
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -43,12 +43,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("get request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (onError);
}
return response;
@ -65,20 +65,20 @@ class Request {
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -86,12 +86,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -107,20 +107,20 @@ class Request {
response = await put(Uri.https(host, path, param),
headers: headers, body: jsonEncode(body));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -128,12 +128,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -149,20 +149,20 @@ class Request {
response = await patch(
path: host + path, headers: headers, body: body, param: param);
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
@ -170,12 +170,12 @@ class Request {
throw const HttpException(httpError);
} on Error catch (e) {
debugPrint("post request error: $e");
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;
@ -192,32 +192,32 @@ class Request {
headers: headers, body: jsonEncode(body))
.timeout(Duration(seconds: requestTimeout));
} on TimeoutException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on SocketException catch (_) {
Fluttertoast.showToast(
msg: timeoutError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: timeoutError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (timeoutError);
} on FormatException catch (_) {
throw const FormatException(formatError);
} on HttpException catch (_) {
throw const HttpException(httpError);
} on Error catch (e) {
Fluttertoast.showToast(
msg: onError,
toastLength: Toast.LENGTH_LONG,
gravity: ToastGravity.BOTTOM,
backgroundColor: Colors.black,
);
// Fluttertoast.showToast(
// msg: onError,
// toastLength: Toast.LENGTH_LONG,
// gravity: ToastGravity.BOTTOM,
// backgroundColor: Colors.black,
// );
throw (e.toString());
}
return response;