fix: resolve Dart analysis errors and format code

- Fixed unused field warning in phone_input_screen.dart
- Resolved undefined getter 'isoCode' by removing unused code
- Fixed undefined class 'User' error by adding proper Firebase import in user_model.dart
- Ran dart format to ensure consistent code style across all files
- All analyzer issues are now resolved

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
soragui
2026-02-26 06:40:52 +08:00
parent c903430f75
commit 465cbf3fa5
10 changed files with 42 additions and 21 deletions

View File

@@ -2,7 +2,11 @@
"permissions": {
"allow": [
"Bash(code .:*)",
"Bash(git add:*)"
"Bash(git add:*)",
"Bash(git commit:*)",
"Bash(flutter analyze:*)",
"Bash(flutter format:*)",
"Bash(dart format:*)"
]
}
}

View File

@@ -29,7 +29,8 @@ final _router = GoRouter(
final authState = Provider.of<AuthState>(context, listen: false);
final bool loggedIn = authState.isLoggedIn;
final bool loggingIn =
state.matchedLocation == '/login' || state.matchedLocation == '/sms_verify';
state.matchedLocation == '/login' ||
state.matchedLocation == '/sms_verify';
if (!loggedIn && !loggingIn) {
return '/login';

View File

@@ -13,7 +13,6 @@ class PhoneInputScreen extends StatefulWidget {
class _PhoneInputScreenState extends State<PhoneInputScreen> {
final TextEditingController _phoneController = TextEditingController();
String? _selectedCountry;
String? _formattedPhone;
@override
@@ -42,9 +41,6 @@ class _PhoneInputScreenState extends State<PhoneInputScreen> {
onChanged: (phone) {
_formattedPhone = phone.completeNumber;
},
onCountryChanged: (country) {
_selectedCountry = country.isoCode;
},
),
const SizedBox(height: 20),
authState.isLoading
@@ -53,12 +49,16 @@ class _PhoneInputScreenState extends State<PhoneInputScreen> {
onPressed: _formattedPhone != null
? () async {
if (_formattedPhone != null) {
await authState.signInWithPhoneNumber(_formattedPhone!);
await authState.signInWithPhoneNumber(
_formattedPhone!,
);
if (!context.mounted) return;
if (authState.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(authState.errorMessage!)),
SnackBar(
content: Text(authState.errorMessage!),
),
);
} else {
context.go('/sms_verify');

View File

@@ -78,12 +78,17 @@ class _SmsVerificationScreenState extends State<SmsVerificationScreen> {
? () async {
// In a real app, we'd have the verificationId from the previous step
if (_verificationId != null) {
await authState.verifyOTP(_verificationId!, _pinController.text);
await authState.verifyOTP(
_verificationId!,
_pinController.text,
);
if (!context.mounted) return;
if (authState.errorMessage != null) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(authState.errorMessage!)),
SnackBar(
content: Text(authState.errorMessage!),
),
);
} else {
context.go('/');

View File

@@ -52,7 +52,9 @@ class _LoggedInView extends StatelessWidget {
child: ListTile(
leading: const Icon(Icons.person),
title: Text(authState.currentUser!.displayName ?? 'User'),
subtitle: Text(authState.currentUser!.phoneNumber ?? 'No phone number'),
subtitle: Text(
authState.currentUser!.phoneNumber ?? 'No phone number',
),
),
),
const Divider(),

View File

@@ -27,9 +27,18 @@ class ProfileScreen extends StatelessWidget {
),
),
const SizedBox(height: 16),
_buildProfileItem('Name', authState.currentUser!.displayName ?? 'Not set'),
_buildProfileItem('Phone', authState.currentUser!.phoneNumber ?? 'Not set'),
_buildProfileItem('Email', authState.currentUser!.email ?? 'Not set'),
_buildProfileItem(
'Name',
authState.currentUser!.displayName ?? 'Not set',
),
_buildProfileItem(
'Phone',
authState.currentUser!.phoneNumber ?? 'Not set',
),
_buildProfileItem(
'Email',
authState.currentUser!.email ?? 'Not set',
),
const Spacer(),
Center(
child: authState.isLoading

View File

@@ -44,4 +44,4 @@ class FirebaseAuthService implements AuthService {
Future<void> signOut() async {
await _firebaseAuth.signOut();
}
}
}

View File

@@ -1,3 +1,5 @@
import 'package:firebase_auth/firebase_auth.dart';
class UserModel {
final String uid;
final String? displayName;
@@ -27,4 +29,4 @@ class UserModel {
String toString() {
return 'UserModel(uid: $uid, displayName: $displayName, phoneNumber: $phoneNumber, email: $email, photoURL: $photoURL)';
}
}
}

View File

@@ -5,8 +5,6 @@ class LoadingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Center(
child: CircularProgressIndicator(),
);
return const Center(child: CircularProgressIndicator());
}
}
}

View File

@@ -16,4 +16,4 @@ class AppTheme {
brightness: Brightness.dark,
),
);
}
}