Open berkeresvan opened 7 months ago
import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sharedpreferences_login/main.dart';
class Anasayfa extends StatefulWidget { const Anasayfa({super.key});
@override
State
class _AnasayfaState extends State
Future
@override void initState() { // TODO: implement initState super.initState(); OturumBilgisiOku(); }
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Aanasayfa"),
actions: [
IconButton(
onPressed: () {
CikisYap();
},
icon: Icon(Icons.exit_to_app),
)
],
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children:
import 'package:flutter/material.dart'; import 'package:shared_preferences/shared_preferences.dart'; import 'package:sharedpreferences_login/Anasayfa.dart';
void main() { runApp(const MyApp()); }
class MyApp extends StatelessWidget { Future OturumKontrol() async {
var sp = await SharedPreferences.getInstance();
}
const MyApp({super.key});
@override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), home: FutureBuilder(
future: OturumKontrol(),
builder: (context, snapshot) {
if (snapshot.hasData) {
bool? gecisIzni = snapshot.data;
return gecisIzni! ? const Anasayfa() : LoginEkrani();
} else {
return Container();
}
},
),
);
}
}
class LoginEkrani extends StatefulWidget { @override State createState() => _LoginEkraniState();
}
class _LoginEkraniState extends State {
var tfKullaniciadi = TextEditingController();
var tfSifre = TextEditingController();
var scaffoldKey = GlobalKey();
Future girisKontrol() async {
var ka = tfKullaniciadi.text;
var s = tfSifre.text;
}
@override Widget build(BuildContext context) { return Scaffold( key: scaffoldKey, appBar: AppBar( backgroundColor: Theme.of(context).colorScheme.inversePrimary, title: Text("Login Ekranı"), ), body: Padding( padding: const EdgeInsets.all(8.0), child: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children:[
TextField(
controller: tfKullaniciadi,
decoration: InputDecoration(hintText: "Kullanıcı Adı"),
),
TextField(
obscureText: true,
controller: tfSifre,
decoration: InputDecoration(hintText: "Şifre"),
),
ElevatedButton(
onPressed: () {
girisKontrol();
},
child: Text("Giriş Yap"))
],
),
),
),
);
}
}