34 lines
923 B
Dart
34 lines
923 B
Dart
import 'package:flutter/material.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
class SettingsProvider with ChangeNotifier {
|
|
// Default server address for local development.
|
|
// Using 10.0.2.2 for Android emulator or localhost for Desktop.
|
|
String _baseUrl = "http://localhost:8080";
|
|
|
|
String get baseUrl => _baseUrl;
|
|
|
|
SettingsProvider() {
|
|
_loadSettings();
|
|
}
|
|
|
|
void _loadSettings() async {
|
|
final prefs = await SharedPreferences.getInstance();
|
|
_baseUrl = prefs.getString('baseUrl') ?? _baseUrl;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setBaseUrl(String url) async {
|
|
_baseUrl = url;
|
|
final prefs = await SharedPreferences.getInstance();
|
|
await prefs.setString('baseUrl', url);
|
|
notifyListeners();
|
|
}
|
|
|
|
// Also provide the RTMP URL based on the same hostname
|
|
String get rtmpUrl {
|
|
final uri = Uri.parse(_baseUrl);
|
|
return "rtmp://${uri.host}:1935/live";
|
|
}
|
|
}
|