import 'dart:convert'; import 'package:flutter/material.dart'; import 'package:http/http.dart' as http; import 'package:queue_mgr/backend/DebugHelper.dart'; // DateFormat dateFormat; final String API_ENDPOINT= "https://vps.playpoolstudios.com/qms/api/"; class DataManager{ static _DataManager? m_instance = null; static _DataManager instance(){ m_instance ??= _DataManager(); return m_instance!; } } class _DataManager{ _DataManager(); List services = []; Future GetData() async{ try{ var response = (await http.post( Uri.parse('${API_ENDPOINT}get_services.php'), body: {})); Debug.LogResponse(response.body.toString()); services = jsonDecode(response.body.toString()); Debug.LogResponse(services); }catch(e){ Debug.LogError(e); } } Future AddService(String name, DateTime sTime, DateTime eTime,TimeOfDay duration) async { try{ var response = (await http.post( Uri.parse('${API_ENDPOINT}add_service.php'), body: { 'name':name, 'stime':sTime.toString(), 'etime':eTime.toString(), 'duration':"${duration.hour}:${duration.minute}" })); Debug.LogResponse(response.body.toString()); services = jsonDecode(response.body.toString()); Debug.LogResponse(services); }catch(e){ Debug.LogError(e); } } }