Facebook Twitter Instagram
    DeepCrazyWorld
    Facebook Twitter Instagram Pinterest YouTube
    • FLUTTER
      • FLUTTER APP
        • QRCode
        • Quiz App
        • Chat GPT
        • PDF App
        • News App
        • Fitness App
        • Weather App
        • BMI Calculator
        • GAME APP
        • Ecommerce App
        • wallpaper App
        • Finance app
        • Chat App
        • Wallet App
        • Taxi App
        • Quran app
        • Music player app
      • FLUTTER UI
        • Splash Screen
        • Onboarding Screen
        • Login Screen
        • Card Design
        • Drawer
    • PROJECT
      • Android Projects
      • College Projects
      • FLUTTER APP
      • Project Ideas
      • PHP Projects
      • Python Projects
    • SOURCE CODE
    • ANDROID
      • ANDROID APP
      • GAME APP
      • ANDROID STUDIO
    • MCQ
      • AKTU MCQ
        • RPA MCQ
        • COA MCQ
        • HPC MCQ
        • SPM MCQ
        • Renewable Energy All MCQ
        • Data Compression MCQ
        • Data Structure MCQ
        • Digital Image Processing MCQ
        • Software Engineering MCQ
        • Machine Learning MCQ
        • Artificial Intelligence MCQ
      • D PHARMA MCQ
        • Pharmaceutics – I MCQ
        • Pharmacognosy MCQ
        • Pharmaceutical Chemistry MCQ
        • Biochemistry and Clinical Pathology MCQ
        • Human Anatomy and Physiology MCQ
        • Heath Education and Community Pharmacy MCQ
    • INTERVIEW QUESTIONS
      • Flutter Interview Questions
      • INTERVIEW QUESTIONS
      • Python Interview Questions
      • Coding ninjas solution
    • MORE
      • WORDPRESS
        • SEO
        • TOP 10 WORDPRESS THEME
      • PRODUCTIVITY
      • Program
      • QUOTES
    DeepCrazyWorld
    Home»FLUTTER APP»Create custom social login button Google, Facebook and Apple ui in Flutter
    FLUTTER APP

    Create custom social login button Google, Facebook and Apple ui in Flutter

    DeepikaBy DeepikaAugust 24, 2024Updated:August 24, 2024No Comments4 Mins Read

    Let’s create custom social login buttons for Google, Facebook, and Apple in Flutter without using any external packages.

    Table of Contents

    Toggle
    • Step 1: Set Up Your Flutter Project
    • Step 2: Design the UI for the Buttons
    • Step 3: Implement the Social Login Buttons
    • Step 4: Add Logo Images to Assets
    • Step 5: Use the Buttons in Your App
    • Step 6: Run Your App
    • Customizations
    • Output
    • Related Articles

    Step 1: Set Up Your Flutter Project

    If you haven’t already, start by creating a new Flutter project.

    flutter create social_login_buttons
    cd social_login_buttons

    Step 2: Design the UI for the Buttons

    We’ll create custom widgets for Google, Facebook, and Apple login buttons.

    Step 3: Implement the Social Login Buttons

    Create a new file called social_login_buttons.dart in the lib directory.

    touch lib/social_login_buttons.dart

    In this file, define custom widgets for each button:

    import 'package:flutter/material.dart';
    
    class SocialLoginButton extends StatelessWidget {
      final String text;
      final Color color;
      final String logo;
      final VoidCallback onPressed;
    
      const SocialLoginButton({
        Key? key,
        required this.text,
        required this.color,
        required this.logo,
        required this.onPressed,
      }) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return ElevatedButton(
          style: ElevatedButton.styleFrom(
            primary: color,
            onPrimary: Colors.white,
            minimumSize: Size(double.infinity, 50),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(8),
            ),
          ),
          onPressed: onPressed,
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Image.asset(
                logo,
                height: 24,
                width: 24,
              ),
              SizedBox(width: 12),
              Text(
                text,
                style: TextStyle(
                  fontSize: 16,
                ),
              ),
            ],
          ),
        );
      }
    }
    
    class GoogleLoginButton extends StatelessWidget {
      final VoidCallback onPressed;
    
      const GoogleLoginButton({Key? key, required this.onPressed}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return SocialLoginButton(
          text: "Continue with Google",
          color: Colors.white,
          logo: 'assets/google_logo.png',  // Add your Google logo image in assets
          onPressed: onPressed,
        );
      }
    }
    
    class FacebookLoginButton extends StatelessWidget {
      final VoidCallback onPressed;
    
      const FacebookLoginButton({Key? key, required this.onPressed}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return SocialLoginButton(
          text: "Continue with Facebook",
          color: Color(0xFF3b5998),
          logo: 'assets/facebook_logo.png',  // Add your Facebook logo image in assets
          onPressed: onPressed,
        );
      }
    }
    
    class AppleLoginButton extends StatelessWidget {
      final VoidCallback onPressed;
    
      const AppleLoginButton({Key? key, required this.onPressed}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return SocialLoginButton(
          text: "Continue with Apple",
          color: Colors.black,
          logo: 'assets/apple_logo.png',  // Add your Apple logo image in assets
          onPressed: onPressed,
        );
      }
    }

    Step 4: Add Logo Images to Assets

    You need to add the logos for Google, Facebook, and Apple to your assets directory. Create an assets directory in the root of your project and add the logo images.

    1. Create the directory: mkdir assets
    2. Add your logo images (e.g., google_logo.png, facebook_logo.png, apple_logo.png) to the assets directory.
    3. Update your pubspec.yaml to include assets: flutter: assets: - assets/google_logo.png - assets/facebook_logo.png - assets/apple_logo.png

    Step 5: Use the Buttons in Your App

    In your main.dart file, use these custom buttons:

    import 'package:flutter/material.dart';
    import 'social_login_buttons.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          home: Scaffold(
            appBar: AppBar(
              title: Text("Social Login Buttons"),
            ),
            body: Padding(
              padding: const EdgeInsets.all(16.0),
              child: Column(
                children: [
                  GoogleLoginButton(
                    onPressed: () {
                      // Handle Google login
                      print("Google login pressed");
                    },
                  ),
                  SizedBox(height: 16),
                  FacebookLoginButton(
                    onPressed: () {
                      // Handle Facebook login
                      print("Facebook login pressed");
                    },
                  ),
                  SizedBox(height: 16),
                  AppleLoginButton(
                    onPressed: () {
                      // Handle Apple login
                      print("Apple login pressed");
                    },
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }

    Step 6: Run Your App

    Run your app to see the custom social login buttons in action.

    flutter run

    Customizations

    • Text and Logo: You can change the text and logo images according to your needs.
    • Colors: Modify the color parameter in each button widget to change the button colors.
    • Button Style: Adjust the ElevatedButton.styleFrom properties to customize the button’s appearance further.

    This guide helps you create custom social login buttons without using external packages, allowing you to have full control over the design.

    Output

    Here is the image of the custom social login buttons for Google, Facebook, and Apple as described in the code.

    Related Articles

    • How to make Ludo app in Flutter with Source Code Step by step
    • How to make PDF Reader app in Flutter with Source Code Step by step
    • How to make QR Scanner app in Flutter with Source Code Step by step
    • How to Make a ToDo App with Flutter with source Code StepWise in 2024
    • What is package in Flutter (Dart) with example in 2024
    • What is class in Flutter(Dart) with example step by step
    • Advantage of Flutter with examples in 2024
    • Top 15 Amazing Applications Built with Flutter Framework
    • Specialized PDF reader designed specifically for music sheets
    • Flutter File Integrity Checker app for checking integrity of a file
    • Christmas Quote Generator app built with flutter source code
    • Create fast food orders and bundle it up into a QR code with flutter

    Share. Facebook Twitter LinkedIn WhatsApp Telegram Pinterest Reddit Email
    Previous ArticleHow to make Advanced Calculator app in flutter with source code stepwise
    Next Article How to make Login Screen with flutter with validation

    Related Posts

    How to make Diary App using flutter stepwise using getx

    FLUTTER APP 4 Mins Read

    How to Create Music Player UI screen with fully functional in flutter

    FLUTTER APP 3 Mins Read

    How to make Heart rate measure app with Flutter stepwise

    FLUTTER APP 5 Mins Read

    How to make ChatGpt App in flutter with source code Stepwise

    Chat GPT 5 Mins Read

    Leave A Reply Cancel Reply

    Recent Posts
    • Implementing a Dynamic FAQ Screen UI in Flutter Using ExpansionTile March 29, 2025
    • Creating an Instruction UI Screen in Flutter Application March 29, 2025
    • Animated Backgrounds in Flutter: A Complete Guide March 15, 2025
    • How to make Diary App using flutter stepwise using getx August 31, 2024
    • How to Create Music Player UI screen with fully functional in flutter August 30, 2024
    • How to make ListView Builder Ui in flutter with Source Code August 29, 2024
    • Create a TabBar View in flutter with fully functional stepwise August 28, 2024
    • How to create TabBar view in flutter with source code step wise August 27, 2024
    • How to make Heart rate measure app with Flutter stepwise August 26, 2024
    • How to make ChatGpt App in flutter with source code Stepwise August 25, 2024
    Facebook Twitter Instagram Pinterest YouTube
    • About
    • Contact
    • Disclaimer
    • Privacy Policy
    Copyright by DeepCrazyWorld © 2025

    Type above and press Enter to search. Press Esc to cancel.