Phase 3 completed: Flutter MVP with live streaming and auto-refresh

This commit is contained in:
2026-03-18 11:07:21 +08:00
parent 1ca24b61a8
commit 8b0cdd4744
55 changed files with 3015 additions and 98 deletions

View File

@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:shared_preferences/shared_preferences.dart';
class AuthProvider with ChangeNotifier {
String? _token;
bool _isAuthenticated = false;
bool get isAuthenticated => _isAuthenticated;
String? get token => _token;
AuthProvider() {
_loadToken();
}
void _loadToken() async {
final prefs = await SharedPreferences.getInstance();
_token = prefs.getString('token');
_isAuthenticated = _token != null;
notifyListeners();
}
Future<void> login(String token) async {
_token = token;
_isAuthenticated = true;
final prefs = await SharedPreferences.getInstance();
await prefs.setString('token', token);
notifyListeners();
}
Future<void> logout() async {
_token = null;
_isAuthenticated = false;
final prefs = await SharedPreferences.getInstance();
await prefs.remove('token');
notifyListeners();
}
}