TKK_E32231279/lib/screens/admin_akun_screen.dart

68 lines
2.1 KiB
Dart

import 'package:flutter/material.dart';
import 'package:firebase_auth/firebase_auth.dart';
import 'login_screen.dart'; // pastikan ini ada
class AdminAkunScreen extends StatelessWidget {
const AdminAkunScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.all(20),
child: Column(
children: [
const SizedBox(height: 20),
// ================= PROFILE ICON =================
const CircleAvatar(
radius: 40,
backgroundColor: Colors.black12,
child: Icon(Icons.person, size: 40),
),
const SizedBox(height: 20),
// ================= INFO =================
Text(
FirebaseAuth.instance.currentUser?.email ?? '-',
style: const TextStyle(fontSize: 16),
),
const Spacer(),
// ================= LOGOUT BUTTON =================
SizedBox(
width: double.infinity,
child: ElevatedButton(
style: ElevatedButton.styleFrom(
backgroundColor: Colors.red,
padding: const EdgeInsets.symmetric(vertical: 14),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
onPressed: () async {
await FirebaseAuth.instance.signOut();
// pindah ke login & hapus semua halaman sebelumnya
Navigator.pushAndRemoveUntil(
// ignore: use_build_context_synchronously
context,
MaterialPageRoute(
builder: (context) => const LoginScreen()),
(route) => false,
);
},
child: const Text(
"Logout",
style: TextStyle(fontSize: 16),
),
),
)
],
),
),
);
}
}