first commit
This commit is contained in:
82
lib/services/checkpoint_service.dart
Normal file
82
lib/services/checkpoint_service.dart
Normal file
@ -0,0 +1,82 @@
|
||||
import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||
import 'package:rogaining_jp/models/check_points.dart';
|
||||
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
|
||||
class CheckpointService {
|
||||
|
||||
static Future<CheckPoint> syncIncident(CheckPoint incident) async {
|
||||
print(jsonEncode(incident.toFeatureMap()));
|
||||
String url = 'http://front.lk:8100/api/v1/incidents/';
|
||||
final response = await http.post(Uri.parse(url),
|
||||
headers: <String, String>{
|
||||
'Content-Type': 'application/json; charset=UTF-8',
|
||||
},
|
||||
body: jsonEncode(incident.toFeatureMap()),
|
||||
);
|
||||
|
||||
if (response.statusCode == 201) {
|
||||
return CheckPoint.fromMap(jsonDecode(response.body));
|
||||
} else {
|
||||
throw Exception('Failed to create album.');
|
||||
}
|
||||
}
|
||||
|
||||
static List<CheckPoint> getDistricts() {
|
||||
return <CheckPoint>[
|
||||
CheckPoint(
|
||||
id:1,
|
||||
lat: 35.3411516,
|
||||
long: 137.1275938,
|
||||
title: "日本、〒507-0028 岐阜県多治見市弁天町1丁目47−1"
|
||||
),
|
||||
CheckPoint(
|
||||
id:2,
|
||||
lat: 35.3681674,
|
||||
long: 137.2014657,
|
||||
title: "岐阜県土岐市泉町河合849−1 はま寿司 土岐店",
|
||||
),
|
||||
CheckPoint(
|
||||
id:3,
|
||||
lat: 35.357564,
|
||||
long: 137.2430125,
|
||||
title: "岐阜県瑞浪市南小田町1丁目141 マクドナルド 19号瑞浪店",
|
||||
),
|
||||
CheckPoint(
|
||||
id:4,
|
||||
lat: 35.3238775,
|
||||
long: 137.2028726,
|
||||
title: "岐阜県土岐市下石町1937−3 蕎麦 秋新",
|
||||
),
|
||||
CheckPoint(
|
||||
id:5,
|
||||
lat: 35.2993208,
|
||||
long: 137.1594189,
|
||||
title: "岐阜県多治見市笠原町2082−5 多治見市モザイクタイルミュージアム",
|
||||
),
|
||||
CheckPoint(
|
||||
id:6,
|
||||
lat: 35.2999321,
|
||||
long: 137.1268954,
|
||||
title: "岐阜県多治見市市之倉町4丁目6−30−1 市之倉さかづき美術館",
|
||||
),
|
||||
CheckPoint(
|
||||
id:7,
|
||||
lat: 35.3180639,
|
||||
long: 137.13031620000001,
|
||||
title: "岐阜県多治見市大畑町2丁目150 感謝と挑戦のTYK体育館(多治見市総合体育館)",
|
||||
),
|
||||
CheckPoint(
|
||||
id:7,
|
||||
lat: 35.3411375,
|
||||
long: 137.1276928,
|
||||
title: "岐阜県多治見市大畑町2丁目150 感謝と挑戦のTYK体育館(多治見市総合体育館)",
|
||||
),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user