commit before flutter upgrade
parent
e7d5e933dd
commit
3a53445ec6
|
@ -10,7 +10,9 @@ import 'package:unit2/utils/location_utilities.dart';
|
||||||
import 'package:unit2/utils/profile_utilities.dart';
|
import 'package:unit2/utils/profile_utilities.dart';
|
||||||
import '../../model/location/country.dart' as country;
|
import '../../model/location/country.dart' as country;
|
||||||
import '../../model/location/region.dart' as region;
|
import '../../model/location/region.dart' as region;
|
||||||
|
import '../../model/location/provinces.dart' as province;
|
||||||
|
import '../../model/location/city.dart' as city;
|
||||||
|
import '../../model/location/barangay.dart' as barangay;
|
||||||
part 'profile_event.dart';
|
part 'profile_event.dart';
|
||||||
part 'profile_state.dart';
|
part 'profile_state.dart';
|
||||||
|
|
||||||
|
@ -38,7 +40,8 @@ class ProfileBloc extends Bloc<ProfileEvent, ProfileState> {
|
||||||
List<country.Country> countries = await LocationUtils.instance.getCountries();
|
List<country.Country> countries = await LocationUtils.instance.getCountries();
|
||||||
List<region.Region> regions = await LocationUtils.instance.getRegions();
|
List<region.Region> regions = await LocationUtils.instance.getRegions();
|
||||||
List<EligibilityList> eligibilities = await ProfileUtilities.instance.getEligibilities();
|
List<EligibilityList> eligibilities = await ProfileUtilities.instance.getEligibilities();
|
||||||
emit(EditEligibilityState(eligibityCert: event.eligibityCert,countries: countries,regions: regions,eligibilities: eligibilities));
|
List<province.Province> provinces = await LocationUtils.instance.getProvinces(regionCode: event.eligibityCert.examAddress!.cityMunicipality!.province!.region!.code!.toString());
|
||||||
|
emit(EditEligibilityState(provinces: provinces, eligibityCert: event.eligibityCert,countries: countries,regions: regions,eligibilities: eligibilities));
|
||||||
// }catch(e){
|
// }catch(e){
|
||||||
// emit(ProfileErrorState(mesage: e.toString()));
|
// emit(ProfileErrorState(mesage: e.toString()));
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -39,7 +39,8 @@ class EditEligibilityState extends ProfileState{
|
||||||
final List<EligibilityList> eligibilities;
|
final List<EligibilityList> eligibilities;
|
||||||
final List<country.Country> countries;
|
final List<country.Country> countries;
|
||||||
final List<region.Region> regions;
|
final List<region.Region> regions;
|
||||||
const EditEligibilityState({required this.eligibityCert, required this.eligibilities, required this.countries, required this.regions});
|
List<province.Province> provinces;
|
||||||
|
EditEligibilityState({ required this.provinces,required this.eligibityCert, required this.eligibilities, required this.countries, required this.regions});
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [eligibityCert];
|
List<Object> get props => [eligibityCert];
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
import 'package:meta/meta.dart';
|
import 'package:meta/meta.dart';
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
|
|
||||||
|
import 'region.dart';
|
||||||
|
|
||||||
Province provinceFromJson(String str) => Province.fromJson(json.decode(str));
|
Province provinceFromJson(String str) => Province.fromJson(json.decode(str));
|
||||||
|
|
||||||
String provinceToJson(Province data) => json.encode(data.toJson());
|
String provinceToJson(Province data) => json.encode(data.toJson());
|
||||||
|
@ -40,27 +42,3 @@ class Province {
|
||||||
"shortname": shortname,
|
"shortname": shortname,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class Region {
|
|
||||||
Region({
|
|
||||||
required this.code,
|
|
||||||
required this.description,
|
|
||||||
required this.psgcCode,
|
|
||||||
});
|
|
||||||
|
|
||||||
final int? code;
|
|
||||||
final String? description;
|
|
||||||
final String? psgcCode;
|
|
||||||
|
|
||||||
factory Region.fromJson(Map<String, dynamic> json) => Region(
|
|
||||||
code: json["code"],
|
|
||||||
description: json["description"],
|
|
||||||
psgcCode: json["psgc_code"],
|
|
||||||
);
|
|
||||||
|
|
||||||
Map<String, dynamic> toJson() => {
|
|
||||||
"code": code,
|
|
||||||
"description": description,
|
|
||||||
"psgc_code": psgcCode,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ class EligibityCert {
|
||||||
examDate: json['exam_date'] == null? null: DateTime.parse(json["exam_date"]),
|
examDate: json['exam_date'] == null? null: DateTime.parse(json["exam_date"]),
|
||||||
attachments: null,
|
attachments: null,
|
||||||
eligibility: json['eligibility'] == null?null: Eligibility.fromJson(json["eligibility"]),
|
eligibility: json['eligibility'] == null?null: Eligibility.fromJson(json["eligibility"]),
|
||||||
examAddress: json['eligibilty'] == null? null: ExamAddress.fromJson(json["exam_address"]),
|
examAddress: json['exam_address'] == null? null: ExamAddress.fromJson(json["exam_address"]),
|
||||||
validityDate: json["validity_date"],
|
validityDate: json["validity_date"],
|
||||||
licenseNumber: json["license_number"],
|
licenseNumber: json["license_number"],
|
||||||
);
|
);
|
||||||
|
|
|
@ -8,7 +8,10 @@ import 'package:intl/intl.dart';
|
||||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_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 'package:unit2/model/utils/eligibilities_choices.dart';
|
||||||
import '../../../../model/location/country.dart' as c;
|
import '../../../../model/location/country.dart' as c;
|
||||||
|
import '../../../../model/location/region.dart' as r;
|
||||||
|
import '../../../../model/location/provinces.dart' as p;
|
||||||
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';
|
||||||
|
@ -30,12 +33,22 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
c.Country? selectedCountry;
|
c.Country? selectedCountry;
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
//USERBLOC
|
||||||
return BlocBuilder<UserBloc, UserState>(
|
return BlocBuilder<UserBloc, UserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
//LOGGED IN USER STATE
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
|
//PROFIILE BLOC
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
|
//EDIT ELIGIBILITY STATE
|
||||||
if (state is EditEligibilityState) {
|
if (state is EditEligibilityState) {
|
||||||
|
String? region = state.eligibityCert.examAddress!
|
||||||
|
.cityMunicipality!.province!.region!.description;
|
||||||
|
String? eligibiltyTitle =
|
||||||
|
state.eligibityCert.eligibility!.title!;
|
||||||
|
String? province = state.eligibityCert.examAddress!
|
||||||
|
.cityMunicipality!.province!.description!;
|
||||||
return Center(
|
return Center(
|
||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
|
@ -46,20 +59,35 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
FormBuilderTextField(
|
//ELIGIBILITIES DROPDOWN
|
||||||
|
FormBuilderDropdown<dynamic>(
|
||||||
|
initialValue: state.eligibityCert.eligibility,
|
||||||
|
items: state.eligibilities
|
||||||
|
.map<DropdownMenuItem<EligibilityList>>(
|
||||||
|
(EligibilityList eligibility) {
|
||||||
|
return DropdownMenuItem<EligibilityList>(
|
||||||
|
value: eligibility,
|
||||||
|
child: Text(eligibility.title));
|
||||||
|
}).toList(),
|
||||||
name: "eligibility",
|
name: "eligibility",
|
||||||
initialValue:
|
|
||||||
widget.eligibityCert.eligibility!.title!,
|
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Eligibility", "Eligibility"),
|
"Eligibility", eligibiltyTitle)
|
||||||
|
.copyWith(
|
||||||
|
hintStyle: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
labelStyle:
|
||||||
|
const TextStyle(color: Colors.black)),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: screenWidth,
|
width: screenWidth,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
//LICENSE NUMBER
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
|
@ -73,6 +101,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
|
//RATING
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: FormBuilderTextField(
|
child: FormBuilderTextField(
|
||||||
|
@ -93,6 +122,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
width: screenWidth,
|
width: screenWidth,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
|
//EXAM DATE
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: DateTimePicker(
|
child: DateTimePicker(
|
||||||
|
@ -110,6 +140,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 12,
|
width: 12,
|
||||||
),
|
),
|
||||||
|
//VALIDITY DATE
|
||||||
Flexible(
|
Flexible(
|
||||||
flex: 1,
|
flex: 1,
|
||||||
child: DateTimePicker(
|
child: DateTimePicker(
|
||||||
|
@ -141,6 +172,7 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 12,
|
height: 12,
|
||||||
),
|
),
|
||||||
|
//OVERSEAS ADDRESS SWITCH
|
||||||
FormBuilderSwitch(
|
FormBuilderSwitch(
|
||||||
initialValue: overseas,
|
initialValue: overseas,
|
||||||
activeColor: second,
|
activeColor: second,
|
||||||
|
@ -156,13 +188,14 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
//COUNTRY DROPDOWN
|
||||||
|
|
||||||
SizedBox(
|
SizedBox(
|
||||||
child: overseas == true
|
child: overseas == true
|
||||||
? FormBuilderDropdown<dynamic>(
|
? FormBuilderDropdown<dynamic>(
|
||||||
items: state.countries
|
items: state.countries
|
||||||
.map<DropdownMenuItem<c.Country>>(
|
.map<DropdownMenuItem<c.Country>>(
|
||||||
(c.Country country) {
|
(c.Country country) {
|
||||||
|
|
||||||
return DropdownMenuItem<c.Country>(
|
return DropdownMenuItem<c.Country>(
|
||||||
value: country,
|
value: country,
|
||||||
child: Text(country.name!));
|
child: Text(country.name!));
|
||||||
|
@ -178,39 +211,52 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
)
|
)
|
||||||
: Column(
|
: Column(
|
||||||
children: [
|
children: [
|
||||||
FormBuilderDropdown(
|
//REGION DROPDOWN
|
||||||
|
FormBuilderDropdown<dynamic>(
|
||||||
|
// initialValue:state.eligibityCert.examAddress!.cityMunicipality!.province!.description!,
|
||||||
decoration: normalTextFieldStyle(
|
decoration: normalTextFieldStyle(
|
||||||
"Region", "Region"),
|
"Region", region ??
|
||||||
|
"Region*")
|
||||||
|
.copyWith(
|
||||||
|
hintStyle: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black)),
|
||||||
name: 'region',
|
name: 'region',
|
||||||
items: [],
|
items: state.regions.map<
|
||||||
initialValue: widget
|
DropdownMenuItem<r.Region>>(
|
||||||
.eligibityCert
|
(r.Region region) {
|
||||||
.examAddress
|
return DropdownMenuItem<r.Region>(
|
||||||
?.cityMunicipality
|
value: region,
|
||||||
?.province
|
child: Text(
|
||||||
?.region
|
region.description!));
|
||||||
?.description ==
|
}).toList(),
|
||||||
null
|
|
||||||
? 'region'
|
|
||||||
: 'region',
|
|
||||||
),
|
),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
//PROVINCE DROPDOWN
|
||||||
FormBuilderDropdown(
|
FormBuilderDropdown(
|
||||||
decoration: normalTextFieldStyle(
|
|
||||||
'Province', "Province"),
|
|
||||||
name: 'province',
|
name: 'province',
|
||||||
items: [],
|
items: state.provinces.map<
|
||||||
initialValue: widget
|
DropdownMenuItem<
|
||||||
.eligibityCert
|
p.Province>>(
|
||||||
.examAddress
|
(p.Province province) {
|
||||||
?.cityMunicipality
|
return DropdownMenuItem(
|
||||||
?.province
|
value: province,
|
||||||
?.description ==
|
child: Text(
|
||||||
null
|
province.description!));
|
||||||
? 'region'
|
}).toList(),
|
||||||
: 'pprovince'),
|
decoration: normalTextFieldStyle(
|
||||||
|
"Province", province)
|
||||||
|
.copyWith(
|
||||||
|
hintStyle: const TextStyle(
|
||||||
|
color: Colors.black,
|
||||||
|
),
|
||||||
|
labelStyle: const TextStyle(
|
||||||
|
color: Colors.black),
|
||||||
|
)),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 20,
|
height: 20,
|
||||||
),
|
),
|
||||||
|
@ -257,6 +303,5 @@ class _EditEligibilityScreenState extends State<EditEligibilityScreen> {
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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_bloc/flutter_bloc.dart';
|
||||||
|
import 'package:flutter_progress_hud/flutter_progress_hud.dart';
|
||||||
import 'package:fluttericon/font_awesome_icons.dart';
|
import 'package:fluttericon/font_awesome_icons.dart';
|
||||||
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
import 'package:unit2/bloc/profile/profile_bloc.dart';
|
||||||
import 'package:unit2/bloc/user/user_bloc.dart';
|
import 'package:unit2/bloc/user/user_bloc.dart';
|
||||||
|
@ -32,6 +33,16 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
body: BlocBuilder<UserBloc, UserState>(
|
body: BlocBuilder<UserBloc, UserState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is UserLoggedIn) {
|
if (state is UserLoggedIn) {
|
||||||
|
return ProgressHUD(
|
||||||
|
child: BlocConsumer<ProfileBloc, ProfileState>(
|
||||||
|
listener: (context, state) {
|
||||||
|
if (state is EditEligibilityState) {
|
||||||
|
final progress = ProgressHUD.of(context);
|
||||||
|
progress!.dismiss();
|
||||||
|
}
|
||||||
|
// TODO: implement listener
|
||||||
|
},
|
||||||
|
builder: (context, state) {
|
||||||
return BlocBuilder<ProfileBloc, ProfileState>(
|
return BlocBuilder<ProfileBloc, ProfileState>(
|
||||||
builder: (context, state) {
|
builder: (context, state) {
|
||||||
if (state is EligibilityLoaded) {
|
if (state is EligibilityLoaded) {
|
||||||
|
@ -40,8 +51,8 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
vertical: 8, horizontal: 10),
|
vertical: 8, horizontal: 10),
|
||||||
itemCount: state.eligibilities.length,
|
itemCount: state.eligibilities.length,
|
||||||
itemBuilder: (BuildContext context, int index) {
|
itemBuilder: (BuildContext context, int index) {
|
||||||
String title =
|
String title = state
|
||||||
state.eligibilities[index].eligibility!.title!;
|
.eligibilities[index].eligibility!.title!;
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.start,
|
mainAxisAlignment: MainAxisAlignment.start,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
@ -67,7 +78,8 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
.titleMedium!
|
.titleMedium!
|
||||||
.copyWith(
|
.copyWith(
|
||||||
fontWeight:
|
fontWeight:
|
||||||
FontWeight.w500),
|
FontWeight
|
||||||
|
.w500),
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
|
@ -93,14 +105,22 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
elevation: 3,
|
elevation: 3,
|
||||||
onSelected: (value) {
|
onSelected: (value) {
|
||||||
if (value == 2) {
|
if (value == 2) {
|
||||||
confirmAlert(context, () => null,
|
confirmAlert(
|
||||||
"Delete?", "Confirm Delete?");
|
context,
|
||||||
|
() => null,
|
||||||
|
"Delete?",
|
||||||
|
"Confirm Delete?");
|
||||||
}
|
}
|
||||||
if (value == 1) {
|
if (value == 1) {
|
||||||
|
final progress =
|
||||||
|
ProgressHUD.of(context);
|
||||||
|
progress!
|
||||||
|
.showWithText("Loading...");
|
||||||
context.read<ProfileBloc>().add(
|
context.read<ProfileBloc>().add(
|
||||||
EditEligibility(
|
EditEligibility(
|
||||||
eligibityCert: state
|
eligibityCert:
|
||||||
.eligibilities[index]));
|
state.eligibilities[
|
||||||
|
index]));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
menuItems: [
|
menuItems: [
|
||||||
|
@ -140,6 +160,9 @@ class EligibiltyScreen extends StatelessWidget {
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return Container();
|
return Container();
|
||||||
},
|
},
|
||||||
|
|
|
@ -230,8 +230,8 @@ class _UniT2LoginState extends State<UniT2Login> {
|
||||||
|
|
||||||
BlocProvider.of<UserBloc>(context)
|
BlocProvider.of<UserBloc>(context)
|
||||||
.add(UserLogin(
|
.add(UserLogin(
|
||||||
username: "rjvincentlopeplopez",
|
username: "rodolfobacuinjr",
|
||||||
password: "shesthequ33n",
|
password: "nav071394",
|
||||||
// username: _formKey
|
// username: _formKey
|
||||||
// .currentState!
|
// .currentState!
|
||||||
// .value['username'],
|
// .value['username'],
|
||||||
|
|
|
@ -2,6 +2,7 @@ import 'dart:convert';
|
||||||
|
|
||||||
import 'package:unit2/model/location/country.dart';
|
import 'package:unit2/model/location/country.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
|
import 'package:unit2/model/location/provinces.dart';
|
||||||
import 'package:unit2/utils/request.dart';
|
import 'package:unit2/utils/request.dart';
|
||||||
import 'package:unit2/utils/urls.dart';
|
import 'package:unit2/utils/urls.dart';
|
||||||
|
|
||||||
|
@ -10,13 +11,16 @@ class LocationUtils {
|
||||||
static final LocationUtils _instance = LocationUtils();
|
static final LocationUtils _instance = LocationUtils();
|
||||||
static LocationUtils get instance => _instance;
|
static LocationUtils get instance => _instance;
|
||||||
|
|
||||||
Future<List<Country>>getCountries()async{
|
|
||||||
List<Country> countries=[];
|
|
||||||
String path = Url.instance.getCounties();
|
|
||||||
|
|
||||||
Map<String, String> headers = {
|
Map<String, String> headers = {
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
'Content-Type': 'application/json; charset=UTF-8',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Future<List<Country>>getCountries()async{
|
||||||
|
List<Country> countries=[];
|
||||||
|
String path = Url.instance.getCounties();
|
||||||
|
|
||||||
|
|
||||||
// try{
|
// try{
|
||||||
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
||||||
if(response.statusCode == 200){
|
if(response.statusCode == 200){
|
||||||
|
@ -39,9 +43,7 @@ Future<List<Region>>getRegions()async{
|
||||||
List<Region> regions=[];
|
List<Region> regions=[];
|
||||||
String path = Url.instance.getRegions();
|
String path = Url.instance.getRegions();
|
||||||
|
|
||||||
Map<String, String> headers = {
|
|
||||||
'Content-Type': 'application/json; charset=UTF-8',
|
|
||||||
};
|
|
||||||
// try{
|
// try{
|
||||||
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
http.Response response = await Request.instance.getRequest(path: path, param: {},headers: headers);
|
||||||
if(response.statusCode == 200){
|
if(response.statusCode == 200){
|
||||||
|
@ -58,4 +60,24 @@ Future<List<Region>>getRegions()async{
|
||||||
// }
|
// }
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<List<Province>>getProvinces({required String regionCode})async{
|
||||||
|
List<Province> provinces = [];
|
||||||
|
String path = Url.instance.getProvinces()+regionCode;
|
||||||
|
|
||||||
|
try{
|
||||||
|
http.Response response = await Request.instance.getRequest(path: path,param:{},headers: headers);
|
||||||
|
Map data = jsonDecode(response.body);
|
||||||
|
if(data['data'] != null){
|
||||||
|
data['data'].forEach((var province){
|
||||||
|
Province newProvince = Province.fromJson(province);
|
||||||
|
provinces.add(newProvince);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}catch(e){
|
||||||
|
throw(e.toString());
|
||||||
|
}
|
||||||
|
return provinces;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -26,4 +26,7 @@ String eligibilities(){
|
||||||
String getRegions(){
|
String getRegions(){
|
||||||
return "/api/web_app/location/region/";
|
return "/api/web_app/location/region/";
|
||||||
}
|
}
|
||||||
|
String getProvinces(){
|
||||||
|
return "api/web_app/location/province/";
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue