-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5396d7e
commit f9af3de
Showing
15 changed files
with
469 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,3 +41,5 @@ app.*.map.json | |
/android/app/debug | ||
/android/app/profile | ||
/android/app/release | ||
|
||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"city_id": "39", | ||
"province_id": "5", | ||
"province": "DI Yogyakarta", | ||
"type": "Kabupaten", | ||
"city_name": "Bantul", | ||
"postal_code": "55700" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"province_id": "12", | ||
"province": "Kalimantan Barat" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"province_id": "12", | ||
"province": "Kalimantan Barat" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import 'package:flutter_dotenv/flutter_dotenv.dart'; | ||
|
||
class Config { | ||
// Inisialisasi variabel yang diambil dari .env | ||
static String get apiUrl => dotenv.env['API_URL'] ?? ''; | ||
static String get apiKey => dotenv.env['API_KEY'] ?? ''; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class City { | ||
String? cityId; | ||
String? provinceId; | ||
String? province; | ||
String? type; | ||
String? cityName; | ||
String? postalCode; | ||
|
||
City( | ||
{this.cityId, | ||
this.provinceId, | ||
this.province, | ||
this.type, | ||
this.cityName, | ||
this.postalCode}); | ||
|
||
City.fromJson(Map<String, dynamic> json) { | ||
cityId = json['city_id']; | ||
provinceId = json['province_id']; | ||
province = json['province']; | ||
type = json['type']; | ||
cityName = json['city_name']; | ||
postalCode = json['postal_code']; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final data = <String, dynamic>{}; | ||
data['city_id'] = cityId; | ||
data['province_id'] = provinceId; | ||
data['province'] = province; | ||
data['type'] = type; | ||
data['city_name'] = cityName; | ||
data['postal_code'] = postalCode; | ||
return data; | ||
} | ||
|
||
static List<City> fromJsonList(List? data){ | ||
if(data == null || data.isEmpty) return []; | ||
return data.map((e)=>City.fromJson(e)).toList(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class Province { | ||
String? provinceId; | ||
String? province; | ||
|
||
Province({this.provinceId, this.province}); | ||
|
||
Province.fromJson(Map<String, dynamic> json) { | ||
provinceId = json['province_id']; | ||
province = json['province']; | ||
} | ||
|
||
Map<String, dynamic> toJson() { | ||
final data = <String, dynamic>{}; | ||
data['province_id'] = provinceId; | ||
data['province'] = province; | ||
return data; | ||
} | ||
|
||
static List<Province> fromJsonList(List? data){ | ||
if(data == null || data.isEmpty) return []; | ||
return data.map((e)=>Province.fromJson(e)).toList(); | ||
} | ||
|
||
@override | ||
String toString() => province!; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import 'package:get/get.dart'; | ||
|
||
import '../models/city_model.dart'; | ||
|
||
class CityProvider extends GetConnect { | ||
@override | ||
void onInit() { | ||
httpClient.defaultDecoder = (map) { | ||
if (map is Map<String, dynamic>) return City.fromJson(map); | ||
if (map is List) return map.map((item) => City.fromJson(item)).toList(); | ||
}; | ||
httpClient.baseUrl = 'YOUR-API-URL'; | ||
} | ||
|
||
Future<City?> getCity(int id) async { | ||
final response = await get('city/$id'); | ||
return response.body; | ||
} | ||
|
||
Future<Response<City>> postCity(City city) async => await post('city', city); | ||
Future<Response> deleteCity(int id) async => await delete('city/$id'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:get/get.dart'; | ||
|
||
import '../models/province_model.dart'; | ||
|
||
class ProvinceProvider extends GetConnect { | ||
@override | ||
void onInit() { | ||
httpClient.defaultDecoder = (map) { | ||
if (map is Map<String, dynamic>) return Province.fromJson(map); | ||
if (map is List) | ||
return map.map((item) => Province.fromJson(item)).toList(); | ||
}; | ||
httpClient.baseUrl = 'YOUR-API-URL'; | ||
} | ||
|
||
Future<Province?> getProvince(int id) async { | ||
final response = await get('province/$id'); | ||
return response.body; | ||
} | ||
|
||
Future<Response<Province>> postProvince(Province province) async => | ||
await post('province', province); | ||
Future<Response> deleteProvince(int id) async => await delete('province/$id'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,9 @@ | ||
import 'package:get/get.dart'; | ||
import 'package:get/get_rx/get_rx.dart'; | ||
|
||
class HomeController extends GetxController { | ||
//TODO: Implement HomeController | ||
|
||
final count = 0.obs; | ||
@override | ||
void onInit() { | ||
super.onInit(); | ||
} | ||
|
||
@override | ||
void onReady() { | ||
super.onReady(); | ||
} | ||
|
||
@override | ||
void onClose() { | ||
super.onClose(); | ||
} | ||
|
||
void increment() => count.value++; | ||
RxString provAsalId="".obs; | ||
RxString cityAsalId="".obs; | ||
RxString provTujuanId="".obs; | ||
RxString cityTujuanId="".obs; | ||
} |
Oops, something went wrong.