Apply dart format to all files
This commit is contained in:
+1
-3
@@ -35,9 +35,7 @@ class MyApp extends StatelessWidget {
|
||||
theme: ThemeData(
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||
),
|
||||
supportedLocales: const [
|
||||
Locale('en', ''),
|
||||
],
|
||||
supportedLocales: const [Locale('en', '')],
|
||||
initialRoute: '/',
|
||||
routes: {
|
||||
'/': (_) => const LoginScreen(),
|
||||
|
||||
@@ -70,7 +70,10 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
const Text(
|
||||
'Family Safety',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(fontSize: 32, fontWeight: FontWeight.bold),
|
||||
style: TextStyle(
|
||||
fontSize: 32,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
if (!kIsWeb) ...[
|
||||
@@ -133,22 +136,30 @@ class _LoginScreenState extends State<LoginScreen>
|
||||
? null
|
||||
: () async {
|
||||
if (!kIsWeb) {
|
||||
final status = await Geolocator.checkPermission();
|
||||
final status =
|
||||
await Geolocator.checkPermission();
|
||||
if (status == LocationPermission.denied) {
|
||||
final requested = await Geolocator.requestPermission();
|
||||
final requested =
|
||||
await Geolocator.requestPermission();
|
||||
if (requested == LocationPermission.denied) {
|
||||
authProvider.setError('Location permission denied');
|
||||
authProvider.setError(
|
||||
'Location permission denied',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (status == LocationPermission.deniedForever) {
|
||||
authProvider.setError('Location permission permanently denied. Please enable it in settings.');
|
||||
if (status ==
|
||||
LocationPermission.deniedForever) {
|
||||
authProvider.setError(
|
||||
'Location permission permanently denied. Please enable it in settings.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!kIsWeb) {
|
||||
final newUrl = _serverUrlController.text.trim();
|
||||
if (newUrl.isNotEmpty && newUrl != settings.baseUrl) {
|
||||
if (newUrl.isNotEmpty &&
|
||||
newUrl != settings.baseUrl) {
|
||||
ApiConfig.setBaseUrl(newUrl);
|
||||
await settings.setBaseUrl(newUrl);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,12 @@ class GeoService {
|
||||
|
||||
GeoService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
Future<void> updatePosition(String token, String id, double x, double y) async {
|
||||
Future<void> updatePosition(
|
||||
String token,
|
||||
String id,
|
||||
double x,
|
||||
double y,
|
||||
) async {
|
||||
final response = await _client.put(
|
||||
Uri.parse('${ApiConfig.geoUrl}?id=$id'),
|
||||
headers: {
|
||||
|
||||
@@ -4,5 +4,17 @@ import 'package:flutter/foundation.dart' show kIsWeb;
|
||||
class PlatformService {
|
||||
bool get isWeb => kIsWeb;
|
||||
bool get isNative => !kIsWeb;
|
||||
String get platformName => isWeb ? 'web' : Platform.isAndroid ? 'android' : Platform.isIOS ? 'ios' : Platform.isWindows ? 'windows' : Platform.isMacOS ? 'macos' : Platform.isLinux ? 'linux' : 'unknown';
|
||||
String get platformName => isWeb
|
||||
? 'web'
|
||||
: Platform.isAndroid
|
||||
? 'android'
|
||||
: Platform.isIOS
|
||||
? 'ios'
|
||||
: Platform.isWindows
|
||||
? 'windows'
|
||||
: Platform.isMacOS
|
||||
? 'macos'
|
||||
: Platform.isLinux
|
||||
? 'linux'
|
||||
: 'unknown';
|
||||
}
|
||||
|
||||
@@ -2,7 +2,8 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
class SettingsService {
|
||||
static const String _baseUrlKey = 'server_base_url';
|
||||
static const String _defaultBaseUrl = 'https://family-safety.onrender.com/api';
|
||||
static const String _defaultBaseUrl =
|
||||
'https://family-safety.onrender.com/api';
|
||||
|
||||
String _baseUrl = _defaultBaseUrl;
|
||||
bool _initialized = false;
|
||||
|
||||
@@ -7,7 +7,11 @@ class ShareService {
|
||||
|
||||
ShareService({http.Client? client}) : _client = client ?? http.Client();
|
||||
|
||||
Future<Map<String, dynamic>> createShare(String token, double x, double y) async {
|
||||
Future<Map<String, dynamic>> createShare(
|
||||
String token,
|
||||
double x,
|
||||
double y,
|
||||
) async {
|
||||
final response = await _client.post(
|
||||
Uri.parse(ApiConfig.shareUrl),
|
||||
headers: {
|
||||
@@ -25,20 +29,27 @@ class ShareService {
|
||||
'share_id': data['share_id']?.toString() ?? '',
|
||||
};
|
||||
} catch (e) {
|
||||
throw Exception('Failed to parse response: $e | Body: ${response.body.substring(0, response.body.length > 200 ? 200 : response.body.length)}');
|
||||
throw Exception(
|
||||
'Failed to parse response: $e | Body: ${response.body.substring(0, response.body.length > 200 ? 200 : response.body.length)}',
|
||||
);
|
||||
}
|
||||
} else {
|
||||
final errorBody = response.body.length > 200 ? response.body.substring(0, 200) : response.body;
|
||||
throw Exception('Failed to create share link: ${response.statusCode} - $errorBody');
|
||||
final errorBody = response.body.length > 200
|
||||
? response.body.substring(0, 200)
|
||||
: response.body;
|
||||
throw Exception(
|
||||
'Failed to create share link: ${response.statusCode} - $errorBody',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getPositionByShareId(String token, String shareId) async {
|
||||
Future<Map<String, dynamic>> getPositionByShareId(
|
||||
String token,
|
||||
String shareId,
|
||||
) async {
|
||||
final response = await _client.get(
|
||||
Uri.parse('${ApiConfig.watchUrl}?share_id=$shareId'),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
headers: {'Authorization': 'Bearer $token'},
|
||||
);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
class StringUtil {
|
||||
static bool isValidEmail(String email) {
|
||||
final regExp = RegExp(r'^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.(\w+)$');
|
||||
|
||||
@@ -4,11 +4,7 @@ class ErrorDisplay extends StatelessWidget {
|
||||
final String message;
|
||||
final VoidCallback? onRetry;
|
||||
|
||||
const ErrorDisplay({
|
||||
super.key,
|
||||
required this.message,
|
||||
this.onRetry,
|
||||
});
|
||||
const ErrorDisplay({super.key, required this.message, this.onRetry});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -18,11 +14,7 @@ class ErrorDisplay extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(
|
||||
Icons.error_outline,
|
||||
size: 48,
|
||||
color: Colors.red,
|
||||
),
|
||||
const Icon(Icons.error_outline, size: 48, color: Colors.red),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
message,
|
||||
@@ -31,10 +23,7 @@ class ErrorDisplay extends StatelessWidget {
|
||||
),
|
||||
if (onRetry != null) ...[
|
||||
const SizedBox(height: 16),
|
||||
ElevatedButton(
|
||||
onPressed: onRetry,
|
||||
child: const Text('Retry'),
|
||||
),
|
||||
ElevatedButton(onPressed: onRetry, child: const Text('Retry')),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
@@ -3,10 +3,7 @@ import 'package:flutter/material.dart';
|
||||
class LoadingIndicator extends StatelessWidget {
|
||||
final String message;
|
||||
|
||||
const LoadingIndicator({
|
||||
super.key,
|
||||
this.message = 'Loading...',
|
||||
});
|
||||
const LoadingIndicator({super.key, this.message = 'Loading...'});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -16,10 +13,7 @@ class LoadingIndicator extends StatelessWidget {
|
||||
children: [
|
||||
const CircularProgressIndicator(),
|
||||
const SizedBox(height: 16),
|
||||
Text(
|
||||
message,
|
||||
style: const TextStyle(fontSize: 16),
|
||||
),
|
||||
Text(message, style: const TextStyle(fontSize: 16)),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user