Files
phone_login/lib/profile/profile_screen.dart
soragui 465cbf3fa5 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>
2026-02-26 06:40:52 +08:00

83 lines
2.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:phone_login/auth/auth_state.dart';
class ProfileScreen extends StatelessWidget {
const ProfileScreen({super.key});
@override
Widget build(BuildContext context) {
final authState = Provider.of<AuthState>(context);
return Scaffold(
appBar: AppBar(title: const Text('Profile')),
body: authState.currentUser != null
? Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
CircleAvatar(
radius: 50,
child: Text(
authState.currentUser!.displayName != null
? authState.currentUser!.displayName![0].toUpperCase()
: '?',
style: const TextStyle(fontSize: 30),
),
),
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',
),
const Spacer(),
Center(
child: authState.isLoading
? const CircularProgressIndicator()
: ElevatedButton.icon(
onPressed: () async {
await authState.logout();
},
icon: const Icon(Icons.logout),
label: const Text('Logout'),
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
foregroundColor: Colors.white,
),
),
),
],
),
)
: const Center(child: Text('Loading...')),
);
}
Widget _buildProfileItem(String label, String value) {
return Padding(
padding: const EdgeInsets.only(bottom: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
label,
style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 16),
),
const SizedBox(height: 4),
Text(value.isEmpty ? 'Not set' : value),
const Divider(),
],
),
);
}
}