add location utilities and profile utilities services

feature/passo/PASSO-#1-Sync-data-from-device-to-postgre-and-vice-versa
PGAN-MIS 2023-02-15 16:48:34 +08:00
parent 4418107f21
commit e7d5e933dd
13 changed files with 418 additions and 253 deletions

View File

@ -4,7 +4,12 @@ import 'package:unit2/model/profile/basic_info.dart';
import 'package:unit2/model/profile/basic_information/primary-information.dart'; import 'package:unit2/model/profile/basic_information/primary-information.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
import 'package:unit2/model/profile/profileInfomation.dart'; import 'package:unit2/model/profile/profileInfomation.dart';
import 'package:unit2/model/utils/eligibilities_choices.dart';
import 'package:unit2/sevices/profile/profile_service.dart'; import 'package:unit2/sevices/profile/profile_service.dart';
import 'package:unit2/utils/location_utilities.dart';
import 'package:unit2/utils/profile_utilities.dart';
import '../../model/location/country.dart' as country;
import '../../model/location/region.dart' as region;
part 'profile_event.dart'; part 'profile_event.dart';
part 'profile_state.dart'; part 'profile_state.dart';
@ -28,8 +33,16 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
emit(ProfileLoading()); emit(ProfileLoading());
emit(EligibilityLoaded(eligibilities: event.eligibilities)); emit(EligibilityLoaded(eligibilities: event.eligibilities));
}); });
on<EditEligibility>((event, emit) { on<EditEligibility>((event, emit) async{
emit(EditEligibilityState(eligibityCert: event.eligibityCert)); // try{
List<country.Country> countries = await LocationUtils.instance.getCountries();
List<region.Region> regions = await LocationUtils.instance.getRegions();
List<EligibilityList> eligibilities = await ProfileUtilities.instance.getEligibilities();
emit(EditEligibilityState(eligibityCert: event.eligibityCert,countries: countries,regions: regions,eligibilities: eligibilities));
// }catch(e){
// emit(ProfileErrorState(mesage: e.toString()));
// }
}); });
} }
} }

View File

@ -36,7 +36,10 @@ class EligibilityLoaded extends ProfileState{
class EditEligibilityState extends ProfileState{ class EditEligibilityState extends ProfileState{
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
const EditEligibilityState({required this.eligibityCert}); final List<EligibilityList> eligibilities;
final List<country.Country> countries;
final List<region.Region> regions;
const EditEligibilityState({required this.eligibityCert, required this.eligibilities, required this.countries, required this.regions});
@override @override
List<Object> get props => [eligibityCert]; List<Object> get props => [eligibityCert];
} }

View File

@ -16,20 +16,20 @@ class Barangay {
required this.cityMunicipality, required this.cityMunicipality,
}); });
final String code; final String? code;
final String description; final String? description;
final CityMunicipality cityMunicipality; final CityMunicipality? cityMunicipality;
factory Barangay.fromJson(Map<String, dynamic> json) => Barangay( factory Barangay.fromJson(Map<String, dynamic> json) => Barangay(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
cityMunicipality: CityMunicipality.fromJson(json["city_municipality"]), cityMunicipality: json['city_municipality'] == null? null: CityMunicipality.fromJson(json["city_municipality"]),
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"city_municipality": cityMunicipality.toJson(), "city_municipality": cityMunicipality!.toJson(),
}; };
} }
@ -42,16 +42,16 @@ class CityMunicipality {
required this.zipcode, required this.zipcode,
}); });
final String code; final String? code;
final String description; final String? description;
final Province province; final Province? province;
final String psgcCode; final String? psgcCode;
final String zipcode; final String? zipcode;
factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality( factory CityMunicipality.fromJson(Map<String, dynamic> json) => CityMunicipality(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
province: Province.fromJson(json["province"]), province: json['province'] == null? null:Province.fromJson(json["province"]),
psgcCode: json["psgc_code"], psgcCode: json["psgc_code"],
zipcode: json["zipcode"], zipcode: json["zipcode"],
); );
@ -59,7 +59,7 @@ class CityMunicipality {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"province": province.toJson(), "province": province!.toJson(),
"psgc_code": psgcCode, "psgc_code": psgcCode,
"zipcode": zipcode, "zipcode": zipcode,
}; };
@ -74,16 +74,16 @@ class Province {
required this.shortname, required this.shortname,
}); });
final String code; final String? code;
final String description; final String? description;
final Region region; final Region? region;
final String psgcCode; final String? psgcCode;
final String shortname; final String? shortname;
factory Province.fromJson(Map<String, dynamic> json) => Province( factory Province.fromJson(Map<String, dynamic> json) => Province(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
region: Region.fromJson(json["region"]), region: json['region'] == null? null: Region.fromJson(json["region"]),
psgcCode: json["psgc_code"], psgcCode: json["psgc_code"],
shortname: json["shortname"], shortname: json["shortname"],
); );
@ -91,7 +91,7 @@ class Province {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"region": region.toJson(), "region": region!.toJson(),
"psgc_code": psgcCode, "psgc_code": psgcCode,
"shortname": shortname, "shortname": shortname,
}; };
@ -104,9 +104,9 @@ class Region {
required this.psgcCode, required this.psgcCode,
}); });
final int code; final int? code;
final String description; final String? description;
final String psgcCode; final String? psgcCode;
factory Region.fromJson(Map<String, dynamic> json) => Region( factory Region.fromJson(Map<String, dynamic> json) => Region(
code: json["code"], code: json["code"],

View File

@ -18,16 +18,16 @@ class City {
required this.zipcode, required this.zipcode,
}); });
final String code; final String? code;
final String description; final String? description;
final Province province; final Province? province;
final String psgcCode; final String? psgcCode;
final String zipcode; final String? zipcode;
factory City.fromJson(Map<String, dynamic> json) => City( factory City.fromJson(Map<String, dynamic> json) => City(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
province: Province.fromJson(json["province"]), province: json['province'] == null? null : Province.fromJson(json["province"]),
psgcCode: json["psgc_code"], psgcCode: json["psgc_code"],
zipcode: json["zipcode"], zipcode: json["zipcode"],
); );
@ -35,7 +35,7 @@ class City {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"province": province.toJson(), "province": province!.toJson(),
"psgc_code": psgcCode, "psgc_code": psgcCode,
"zipcode": zipcode, "zipcode": zipcode,
}; };
@ -50,16 +50,16 @@ class Province {
required this.shortname, required this.shortname,
}); });
final String code; final String? code;
final String description; final String? description;
final Region region; final Region? region;
final String psgcCode; final String? psgcCode;
final String shortname; final String? shortname;
factory Province.fromJson(Map<String, dynamic> json) => Province( factory Province.fromJson(Map<String, dynamic> json) => Province(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
region: Region.fromJson(json["region"]), region: json['region'] == null ? null : Region.fromJson(json["region"]),
psgcCode: json["psgc_code"], psgcCode: json["psgc_code"],
shortname: json["shortname"], shortname: json["shortname"],
); );
@ -67,7 +67,7 @@ class Province {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"region": region.toJson(), "region": region!.toJson(),
"psgc_code": psgcCode, "psgc_code": psgcCode,
"shortname": shortname, "shortname": shortname,
}; };
@ -80,9 +80,9 @@ class Region {
required this.psgcCode, required this.psgcCode,
}); });
final int code; final int? code;
final String description; final String? description;
final String psgcCode; final String? psgcCode;
factory Region.fromJson(Map<String, dynamic> json) => Region( factory Region.fromJson(Map<String, dynamic> json) => Region(
code: json["code"], code: json["code"],

View File

@ -16,14 +16,14 @@ class Country {
required this.code, required this.code,
}); });
final int id; final int? id;
final String name; final String? name;
final String code; final String? code;
factory Country.fromJson(Map<String, dynamic> json) => Country( factory Country.fromJson(Map<String, dynamic> json) => Country(
id: json["id"], id: json["id"],
name: json["name"], name: json["name"],
code: json["code"], code: json["code"].toString(),
); );
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {

View File

@ -18,16 +18,16 @@ class Province {
required this.shortname, required this.shortname,
}); });
final String code; final String? code;
final String description; final String? description;
final Region region; final Region? region;
final String psgcCode; final String? psgcCode;
final String shortname; final String? shortname;
factory Province.fromJson(Map<String, dynamic> json) => Province( factory Province.fromJson(Map<String, dynamic> json) => Province(
code: json["code"], code: json["code"],
description: json["description"], description: json["description"],
region: Region.fromJson(json["region"]), region: json['region'] == null? null: Region.fromJson(json["region"]),
psgcCode: json["psgc_code"], psgcCode: json["psgc_code"],
shortname: json["shortname"], shortname: json["shortname"],
); );
@ -35,7 +35,7 @@ class Province {
Map<String, dynamic> toJson() => { Map<String, dynamic> toJson() => {
"code": code, "code": code,
"description": description, "description": description,
"region": region.toJson(), "region": region!.toJson(),
"psgc_code": psgcCode, "psgc_code": psgcCode,
"shortname": shortname, "shortname": shortname,
}; };
@ -48,9 +48,9 @@ class Region {
required this.psgcCode, required this.psgcCode,
}); });
final int code; final int? code;
final String description; final String? description;
final String psgcCode; final String? psgcCode;
factory Region.fromJson(Map<String, dynamic> json) => Region( factory Region.fromJson(Map<String, dynamic> json) => Region(
code: json["code"], code: json["code"],

View File

@ -16,9 +16,9 @@ class Region {
required this.psgcCode, required this.psgcCode,
}); });
final int code; final int? code;
final String description; final String? description;
final String psgcCode; final String? psgcCode;
factory Region.fromJson(Map<String, dynamic> json) => Region( factory Region.fromJson(Map<String, dynamic> json) => Region(
code: json["code"], code: json["code"],

View File

@ -5,12 +5,12 @@
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
import 'dart:convert'; import 'dart:convert';
Eligibilities eligibilitiesFromJson(String str) => Eligibilities.fromJson(json.decode(str)); EligibilityList eligibilitiesFromJson(String str) => EligibilityList.fromJson(json.decode(str));
String eligibilitiesToJson(Eligibilities data) => json.encode(data.toJson()); String eligibilitiesToJson(EligibilityList data) => json.encode(data.toJson());
class Eligibilities { class EligibilityList {
Eligibilities({ EligibilityList({
required this.id, required this.id,
required this.title, required this.title,
required this.type, required this.type,
@ -20,7 +20,7 @@ class Eligibilities {
final String title; final String title;
final String type; final String type;
factory Eligibilities.fromJson(Map<String, dynamic> json) => Eligibilities( factory EligibilityList.fromJson(Map<String, dynamic> json) => EligibilityList(
id: json["id"], id: json["id"],
title: json["title"], title: json["title"],
type: json["type"], type: json["type"],

View File

@ -2,10 +2,13 @@ import 'package:date_time_picker/date_time_picker.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart'; import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter/src/widgets/placeholder.dart'; import 'package:flutter/src/widgets/placeholder.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart'; import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';
import 'package:unit2/bloc/profile/profile_bloc.dart';
import 'package:unit2/bloc/user/user_bloc.dart';
import 'package:unit2/model/profile/eligibility.dart'; import 'package:unit2/model/profile/eligibility.dart';
import '../../../../model/location/country.dart' as c;
import '../../../../theme-data.dart/btn-style.dart'; import '../../../../theme-data.dart/btn-style.dart';
import '../../../../theme-data.dart/colors.dart'; import '../../../../theme-data.dart/colors.dart';
import '../../../../theme-data.dart/form-style.dart'; import '../../../../theme-data.dart/form-style.dart';
@ -14,212 +17,246 @@ import '../../../../utils/text_container.dart';
class EditEligibilityScreen extends StatefulWidget { class EditEligibilityScreen extends StatefulWidget {
final EligibityCert eligibityCert; final EligibityCert eligibityCert;
const EditEligibilityScreen({super.key,required this.eligibityCert}); const EditEligibilityScreen({super.key, required this.eligibityCert});
@override @override
State<EditEligibilityScreen> createState() => _EditEligibilityScreenState(); State<EditEligibilityScreen> createState() => _EditEligibilityScreenState();
} }
class _EditEligibilityScreenState extends State<EditEligibilityScreen> { class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
final formKey = GlobalKey<FormBuilderState>(); final formKey = GlobalKey<FormBuilderState>();
bool overseas =false; bool overseas = false;
DateFormat dteFormat2 = DateFormat.yMMMMd('en_US'); DateFormat dteFormat2 = DateFormat.yMMMMd('en_US');
c.Country? selectedCountry;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Center( return BlocBuilder<UserBloc, UserState>(
child: Padding( builder: (context, state) {
padding: const EdgeInsets.symmetric(vertical: 25, horizontal: 18), if (state is UserLoggedIn) {
child: FormBuilder( return BlocBuilder<ProfileBloc, ProfileState>(
key: formKey, builder: (context, state) {
child: Column( if (state is EditEligibilityState) {
mainAxisAlignment: MainAxisAlignment.center, return Center(
crossAxisAlignment: CrossAxisAlignment.center, child: Padding(
children: [ padding: const EdgeInsets.symmetric(
FormBuilderTextField( vertical: 25, horizontal: 18),
name: "eligibility", child: FormBuilder(
initialValue: widget.eligibityCert.eligibility!.title!, key: formKey,
decoration: child: Column(
normalTextFieldStyle("Eligibility", "Eligibility"), mainAxisAlignment: MainAxisAlignment.center,
), crossAxisAlignment: CrossAxisAlignment.center,
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [ children: [
Flexible( FormBuilderTextField(
flex: 1, name: "eligibility",
child: FormBuilderTextField( initialValue:
name: 'license number', widget.eligibityCert.eligibility!.title!,
initialValue: decoration: normalTextFieldStyle(
widget.eligibityCert.licenseNumber, "Eligibility", "Eligibility"),
decoration: normalTextFieldStyle(
"license number", "license number"),
),
), ),
const SizedBox( const SizedBox(
width: 12, height: 20,
), ),
Flexible( SizedBox(
flex: 1, width: screenWidth,
child: FormBuilderTextField( child: Row(
name: 'rating', children: [
initialValue: Flexible(
widget.eligibityCert.rating.toString(), flex: 1,
decoration: child: FormBuilderTextField(
normalTextFieldStyle('rating', 'rating'), name: 'license number',
), initialValue:
), widget.eligibityCert.licenseNumber,
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Exam date", "Exam date"),
initialValue:
widget.eligibityCert.examDate == null
? ''
: dteFormat2.format(
widget.eligibityCert.examDate!),
)),
const SizedBox(
width: 12,
),
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle(
"Validity date", "Validity date"),
initialValue:
widget.eligibityCert.validityDate == null
? ''
: dteFormat2.format(
widget.eligibityCert.validityDate!),
),
),
],
),
),
const SizedBox(
height: 20,
),
Text(
"Placement of Examination/Confinement",
style: Theme.of(context)
.textTheme
.displaySmall!
.copyWith(fontSize: blockSizeVertical * 2),
),
const SizedBox(
height: 12,
),
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value!;
});
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 20,
),
SizedBox(
child: overseas == true
? FormBuilderTextField(
name: 'country',
decoration: normalTextFieldStyle(
"Country", "Country"),
)
: Column(
children: [
FormBuilderDropdown(
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Region", "Region"), "license number", "license number"),
name: 'region',
items: [],
initialValue: widget
.eligibityCert
.examAddress
?.cityMunicipality
?.province
?.region
?.description ==
null
? 'region'
: 'region',
), ),
const SizedBox( ),
height: 20, const SizedBox(
width: 12,
),
Flexible(
flex: 1,
child: FormBuilderTextField(
name: 'rating',
initialValue: widget.eligibityCert.rating
.toString(),
decoration: normalTextFieldStyle(
'rating', 'rating'),
), ),
FormBuilderDropdown( ),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
child: Row(
children: [
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
'Province', "Province"), "Exam date", "Exam date"),
name: 'province',
items: [],
initialValue: widget initialValue: widget
.eligibityCert .eligibityCert.examDate ==
.examAddress
?.cityMunicipality
?.province
?.description ==
null null
? 'region' ? ''
: 'pprovince'), : dteFormat2.format(
const SizedBox( widget.eligibityCert.examDate!),
height: 20, )),
), const SizedBox(
FormBuilderDropdown( width: 12,
),
Flexible(
flex: 1,
child: DateTimePicker(
firstDate: DateTime(2000),
lastDate: DateTime(2100),
decoration: normalTextFieldStyle( decoration: normalTextFieldStyle(
"Municipality", "Municipality"), "Validity date", "Validity date"),
name: 'municipality', initialValue:
items: [], widget.eligibityCert.validityDate ==
initialValue: widget null
.eligibityCert ? ''
.examAddress : dteFormat2.format(widget
?.cityMunicipality .eligibityCert.validityDate!),
?.description ==
null
? 'region'
: 'municipality',
), ),
], ),
)), ],
const SizedBox( ),
height: 20, ),
), const SizedBox(
SizedBox( height: 20,
width: screenWidth, ),
height: 60, Text(
child: ElevatedButton( "Placement of Examination/Confinement",
style: mainBtnStyle( style: Theme.of(context)
primary, Colors.transparent, second), .textTheme
onPressed: () {}, .displaySmall!
child: const Text(submit)), .copyWith(fontSize: blockSizeVertical * 2),
), ),
const SizedBox(height: 20,), const SizedBox(
height: 12,
),
FormBuilderSwitch(
initialValue: overseas,
activeColor: second,
onChanged: (value) {
setState(() {
overseas = value!;
});
},
decoration: normalTextFieldStyle("", ''),
name: 'overseas',
title: const Text("Overseas Address?"),
),
const SizedBox(
height: 20,
),
SizedBox(
child: overseas == true
? FormBuilderDropdown<dynamic>(
items: state.countries
.map<DropdownMenuItem<c.Country>>(
(c.Country country) {
]), return DropdownMenuItem<c.Country>(
), value: country,
), child: Text(country.name!));
);; }).toList(),
name: 'country',
decoration: normalTextFieldStyle(
"Country", "Country"),
onChanged: (value) {
setState(() {
selectedCountry = value;
});
},
)
: Column(
children: [
FormBuilderDropdown(
decoration: normalTextFieldStyle(
"Region", "Region"),
name: 'region',
items: [],
initialValue: widget
.eligibityCert
.examAddress
?.cityMunicipality
?.province
?.region
?.description ==
null
? 'region'
: 'region',
),
const SizedBox(
height: 20,
),
FormBuilderDropdown(
decoration: normalTextFieldStyle(
'Province', "Province"),
name: 'province',
items: [],
initialValue: widget
.eligibityCert
.examAddress
?.cityMunicipality
?.province
?.description ==
null
? 'region'
: 'pprovince'),
const SizedBox(
height: 20,
),
FormBuilderDropdown(
decoration: normalTextFieldStyle(
"Municipality", "Municipality"),
name: 'municipality',
items: [],
initialValue: widget
.eligibityCert
.examAddress
?.cityMunicipality
?.description ==
null
? 'region'
: 'municipality',
),
],
)),
const SizedBox(
height: 20,
),
SizedBox(
width: screenWidth,
height: 60,
child: ElevatedButton(
style: mainBtnStyle(
primary, Colors.transparent, second),
onPressed: () {},
child: const Text(submit)),
),
const SizedBox(
height: 20,
),
]),
),
),
);
}
return Container();
},
);
}
return Container();
},
);
;
} }
} }

View File

@ -18,6 +18,8 @@ import 'package:unit2/widgets/empty_data.dart';
import '../../../utils/alerts.dart'; import '../../../utils/alerts.dart';
class EligibiltyScreen extends StatelessWidget { class EligibiltyScreen extends StatelessWidget {
const EligibiltyScreen({super.key});
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(

View File

@ -0,0 +1,61 @@
import 'dart:convert';
import 'package:unit2/model/location/country.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart';
import '../model/location/region.dart';
class LocationUtils {
static final LocationUtils _instance = LocationUtils();
static LocationUtils get instance => _instance;
Future<List<Country>>getCountries()async{
List<Country> countries=[];
String path = Url.instance.getCounties();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
// try{
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
if(response.statusCode == 200){
Map data = jsonDecode(response.body);
if(data['data'] != null){
data['data'].forEach((var country){
Country newCOuntry = Country.fromJson(country);
countries.add(newCOuntry);
});
}
}
// }catch(e){
// throw(e.toString());
// }
return countries;
}
Future<List<Region>>getRegions()async{
List<Region> regions=[];
String path = Url.instance.getRegions();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
// try{
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
if(response.statusCode == 200){
Map data = jsonDecode(response.body);
if(data['data'] != null){
data['data'].forEach((var region){
Region newRegion = Region.fromJson(region);
regions.add(newRegion);
});
}
}
// }catch(e){
// throw(e.toString());
// }
return regions;
}
}

View File

@ -0,0 +1,38 @@
import 'dart:convert';
import 'package:unit2/model/location/country.dart';
import 'package:http/http.dart' as http;
import 'package:unit2/model/location/region.dart';
import 'package:unit2/model/utils/eligibilities_choices.dart';
import 'package:unit2/utils/request.dart';
import 'package:unit2/utils/urls.dart';
class ProfileUtilities {
static final ProfileUtilities _instance = ProfileUtilities();
static ProfileUtilities get instance => _instance;
Future<List<EligibilityList>>getEligibilities()async{
List<EligibilityList> eligibilities=[];
String path = Url.instance.eligibilities();
Map<String, String> headers = {
'Content-Type': 'application/json; charset=UTF-8',
};
// try{
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
if(response.statusCode == 200){
Map data = jsonDecode(response.body);
if(data['data'] != null){
data['data'].forEach((var eligibility){
EligibilityList newEligibilities = EligibilityList.fromJson(eligibility);
eligibilities.add(newEligibilities);
});
}
}
// }catch(e){
// throw(e.toString());
// }
return eligibilities;
}
}

View File

@ -15,4 +15,15 @@ class Url {
String profileInformation(){ String profileInformation(){
return '/api/jobnet_app/profile/pds/'; return '/api/jobnet_app/profile/pds/';
} }
String eligibilities(){
return "/api/jobnet_app/eligibilities/";
}
// location utils path
String getCounties(){
return "/api/jobnet_app/countries/";
}
String getRegions(){
return "/api/web_app/location/region/";
}
} }