BTC - $102,004.00 -1.07%
ETH - $3,431.18 0.16%
USDT - $1.00 0.03%
XRP - $2.42 1.14%
BNB - $955.02 -0.58%
SOL - $152.84 -0.86%
USDC - $1.00 0.00%
STETH - $3,430.04 0.20%
TRX - $0.29 -1.30%
DOGE - $0.17 -0.26%
ADA - $0.55 -1.06%
FIGR_HELOC - $1.02 -1.97%
WSTETH - $4,179.67 0.01%
WBTC - $101,743.00 -1.23%
WBETH - $3,712.99 0.11%
WBT - $54.57 0.74%
LINK - $15.29 -0.55%
HYPE - $38.46 -1.68%
BCH - $517.02 1.87%
USDS - $1.00 -0.05%

Flutter Google Giriş

Flutter ile Google ile kayıt olma (Google sign-in) işlemi için Firebase Authentication ve Google Sign-In paketlerini kullanabilirsiniz. a. pubspec.yaml Dosyasına Paket Ekleme google_sign_in: ^5.3.0 Main dosyasına void main() async {WidgetsFlutterBinding.ensureInitialized();await Firebase.initializeApp();runApp(MyApp());} He must have tried × bu kodu ekliyoruz daha sonra alttaki kodu sayfamıza ekliyoruz ElevatedButton ekledikten sonra bir ile...

admin
admin tarafından
17 Ocak 2025 yayınlandı / 17 Ocak 2025 20:27 güncellendi
49 sn 49 sn okuma süresi
Flutter Google Giriş

Flutter ile Google ile kayıt olma (Google sign-in) işlemi için Firebase Authentication ve Google Sign-In paketlerini kullanabilirsiniz.

a. pubspec.yaml Dosyasına Paket Ekleme

google_sign_in: ^5.3.0

Main dosyasına

void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}

bu kodu ekliyoruz daha sonra alttaki kodu sayfamıza ekliyoruz

class _GoogleSignInPageState extends State<GoogleSignInPage> {
  final FirebaseAuth _auth = FirebaseAuth.instance;
  final GoogleSignIn _googleSignIn = GoogleSignIn();

  Future<User?> _signInWithGoogle() async {
    final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
    if (googleUser == null) {
      return null; // Kullanıcı giriş yapmayı iptal etti
    }
    
    final GoogleSignInAuthentication googleAuth = await googleUser.authentication;
    
    final OAuthCredential credential = GoogleAuthProvider.credential(
      accessToken: googleAuth.accessToken,
      idToken: googleAuth.idToken,
    );

    UserCredential userCredential = await _auth.signInWithCredential(credential);
    return userCredential.user;

  }
 Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Google Sign-In')),
      body: Center(
        child: ElevatedButton(
          onPressed: () async {
            User? user = await _signInWithGoogle();
            if (user != null) {
              ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                content: Text('Hoş geldiniz, ${user.displayName}'),
              ));
            }
          },
          child: Text('Google ile Giriş Yap'),
        ),
      ),
    );
  }
}

ElevatedButton ekledikten sonra bir ile _signInWithGoogle tetikliyoruz

Yorum Ekle

İLGİNİZİ ÇEKEBİLİR
His saying herb heaven
13 Temmuz 2016

His saying herb heaven

Flutter Google Giriş

Bu Yazıyı Paylaş

Bildirimler
3