third_party_login 1.0.0 copy "third_party_login: ^1.0.0" to clipboard
third_party_login: ^1.0.0 copied to clipboard

outdated

Third Party Login is simple way to sign-in with different types of third party login systems.

example/lib/main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:third_party_login/third_party_login.dart';

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  late ThirdPartyLoginMethods thirdPartyLoginMethods;
  late UserCredential? userCredential;
  String photoUrl = "";
  String displayName = "";
  String uuid = "";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (photoUrl.isNotEmpty)
              CircleAvatar(
                backgroundImage: NetworkImage(photoUrl),
                radius: 32,
                backgroundColor: Colors.black,
              ),
            const SizedBox(
              height: 10,
            ),
            if (photoUrl.isNotEmpty)
              Text(
                displayName,
                style: const TextStyle(
                    fontWeight: FontWeight.bold, fontSize: 20.0),
              ),
            const SizedBox(
              height: 10,
            ),
            Container(
              color: Colors.amber,
              child: TextButton(
                child: const Text(
                  'SignIn With Google',
                ),
                onPressed: () => signInWithGoogle(),
              ),
            ),
          ],
        ),
      ),
    );
  }

  Future<UserCredential?> signInWithGoogle() async {
    thirdPartyLoginMethods = ThirdPartyLoginMethods();
    final credential = await thirdPartyLoginMethods.socialMediaLogin(
        authType: AuthType.google);
    setState(() {
      userCredential = credential;
      photoUrl = credential?.user?.photoURL ?? "";
      displayName = credential?.user?.displayName ?? "";
    });
    // print(googleSignIn.onTap());
  }
}
10
likes
0
pub points
68%
popularity

Publisher

unverified uploader

Third Party Login is simple way to sign-in with different types of third party login systems.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

firebase_auth, flutter, font_awesome_flutter, get, google_sign_in

More

Packages that depend on third_party_login