diff --git a/lib/services/report_service.dart b/lib/services/report_service.dart index 93e7dfb..6cfb37f 100644 --- a/lib/services/report_service.dart +++ b/lib/services/report_service.dart @@ -1,7 +1,10 @@ import 'dart:convert'; import 'package:http/http.dart' as http; +import 'package:logger/logger.dart'; import '../models/traffic_violation.dart'; +var logger = Logger(); + class ReportService { final String apiUrl = 'https://your-api-url.com/reports'; @@ -30,11 +33,11 @@ class ReportService { if (response.statusCode == 200) { return true; } else { - print('Failed to create report: ${response.statusCode}'); + logger.d('Failed to create report: ${response.statusCode}'); return false; } } catch (e) { - print('Caught error: $e'); + logger.d('Caught error: $e'); return false; } } diff --git a/lib/services/social_service.dart b/lib/services/social_service.dart index 7d32e22..64087d9 100644 --- a/lib/services/social_service.dart +++ b/lib/services/social_service.dart @@ -51,7 +51,7 @@ class SocialService { final String loginUrl = '$baseUrl/social/login/${provider.id}'; // 使用 url_launcher 打开浏览器窗口 - if (await canLaunch(loginUrl)) { + if (await canLaunchUrl(loginUrl)) { await launch(loginUrl); } else { throw 'Could not launch $loginUrl'; diff --git a/pubspec.yaml b/pubspec.yaml index aeacda1..9cfa05c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -42,6 +42,7 @@ dependencies: intl: ^0.17.0 provider: ^6.0.1 http: ^0.13.3 + logger: ^1.1.0 dev_dependencies: flutter_test: