Add BaseUrl

This commit is contained in:
2026-03-05 08:57:16 +01:00
parent bffae6258c
commit 14148aa983

View File

@@ -5,6 +5,7 @@ import 'package:frontend_splatournament_manager/models/tournament.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
class StateProvider extends ChangeNotifier { class StateProvider extends ChangeNotifier {
static const String baseUrl = "http://10.0.2.2:3000";
ThemeMode _themeMode = ThemeMode.system; ThemeMode _themeMode = ThemeMode.system;
ThemeMode get theme => _themeMode; ThemeMode get theme => _themeMode;
@@ -19,7 +20,7 @@ class StateProvider extends ChangeNotifier {
} }
Future<List<Tournament>> fetchAvailableTournaments() async { Future<List<Tournament>> fetchAvailableTournaments() async {
try { try {
var response = await http.get(Uri.parse('http://10.0.2.2:3000/tournaments')); var response = await http.get(Uri.parse('$baseUrl/tournaments'));
if (response.statusCode == 200) { if (response.statusCode == 200) {
final List<dynamic> list = json.decode(response.body); final List<dynamic> list = json.decode(response.body);
_availableTournaments = list.map((json) => Tournament.fromJson(json)).toList(); _availableTournaments = list.map((json) => Tournament.fromJson(json)).toList();