Social Media Buttons in Flutter Web - Android Hire
Coding Tutorials

Social Media Buttons in Flutter Web

Jayant dhingra
Social media buttons on websites are not a new thing. We all are familiar with them somehow. We can find it on every website or now even in mobile apps.

So let’s just focus on how flutter helps us creating these amazing social media buttons.

There may be many websites, videos, or even articles about this very topic. But I am just sharing whats the easiest way to implement Social Media Buttons in Flutter Web.

But before we start with the coding part. Let’s just see what happens behind when we tap or click on these buttons.

Suppose we tap on twitter button above. There will be two logics working behind.

  1. Onpressed: ( ) { }: when we tap on such buttons there is a method like onpressed or ontap that will tell the system that the button has been pressed.
  1. URL launcher: There will be a Url launcher logic working behind the onpressed method. That will take you to the desired link. In this case twitter.

So now the question is where do I get these social media buttons. Well, in this case, we have two methods. Either you make your own buttons which are flexible. Another method is to use a package: flutter_signin_button

Must Read: Current Location in Android using Kotlin

For now, we will use this really helpful package. In fact, two packages remember the URL launcher we need.

Pubsec.yaml dependices:

  1. flutter_signin_button 1.0.0
(link:https://pub.dev/packages/flutter_signin_button )
  1. url_launcher 5.5.0

(link:https://pub.dev/packages/url_launcher)

IMPORTANT NOTE:

Also If you guys are new to Web development through Flutter. There is some prerequisites stuff you need to do. That part, I am dropping some links that might help you.

Resources:

1: PubDev: https://pub.dev/packages/url_launcher

2: Youtube:https://www.youtube.com/watch?v=WkWS5YAwU48

Enough talking, time for coding:

After adding the dependencies and importing both packages. Its time for writing the code.

  • Sign-in Button method from flutter_signin_button 1.0.0 .
......///
          child: SignInButton(
                             Buttons.GitHub,
                             mini: true,
                             onPressed: () {
                               _launchURL('Github');
                             },
                           ),
  • Buttons. // you can add any social media button available in the options.
  • Mini: True // This will provide you with the mini-buttons of social media.
  • onPressed: ( ) { } // When the button is pressed what function it should perform. (In this is have called _launcherURl ( ) )
  • For more buttons re-write this code block for each button.
  • URL Launch function using url_launcher 5.5.0.
.....//// 

_launchURL(String value) async {
   const url = 'https://github.com/atrishabhsharma';
   const url2 = 'http://linkedin.com/in/rishabh-sharma-1a1184160';
   const url3 = 'https://twitter.com/voyager_sage/';
   const url4 = 'https://www.atrishabh1999@gmail.com';
   if (value == 'Github') {
     if (await canLaunch(url)) {
       await launch(url);
     } else {
       throw 'Could not launch $url';
     }
   } else if (value == 'linkedin') {
     if (await canLaunch(url2)) {
       await launch(url2);
     } else {
       throw 'Could not launch $url2';
     }
   } else if (value == 'twitter') {
     if (await canLaunch(url3)) {
       await launch(url3);
     } else {
       throw 'Could not launch $url3';
     }
   } else if (value == 'email') {
     if (await canLaunch(url4)) {
       await launch(url4);
     } else {
       throw 'Could not launch $url4';
     }
   }
 }

In this logic, you can add or subtract as many numbers of buttons according to your need. Mostly we will see this buttons in Rows( ) or Columns( ). So that might give you an idea about it.

Special Thanks to :

Jayant dhingra's profile picture

Jayant dhingra

As an enthusiast of stock markets and a skilled developer specializing in Android and augmented reality technologies, I am constantly driven to experiment with code.

Related Posts

7 Top Samsung Galaxy Ring Alternatives for 2025

7 Top Samsung Galaxy Ring Alternatives for 2025

Tired of waiting for the Samsung Galaxy Ring to hit the market? You’re not alone. While the buzz around Samsung’s smart ring continues, a plethora of impressive alternatives is already available. These devices deliver advanced health tracking, stylish designs, and unique features that cater to various lifestyles. The current lineup of smart rings caters to […]

What Is Quiet Mode on Instagram and How to Activate It

What Is Quiet Mode on Instagram and How to Activate It

Ever wondered what Quiet Mode on Instagram is all about? This simple yet powerful Instagram feature helps you take a break from the constant buzz of notifications and focus on what truly matters. Whether you’re striving for better work-life balance, dedicating time to studying, or simply trying to disconnect from social media distractions, Quiet Mode […]

How to Make a Bed in Minecraft (Step-by-Step Guide)

How to Make a Bed in Minecraft (Step-by-Step Guide)

A bed in Minecraft is very important. It lets you skip the night and set your spawn point, so if you die, you will return to your bed instead of the original world spawn. This guide will show you how to gather materials, craft a bed, and set your spawn point. We’ll also show you how to customize your bed, build bunk […]

10 Best MMORPG Games For Android

10 Best MMORPG Games For Android

Not too long ago, MMORPG games and powerful gaming consoles were mostly exclusive to PCs. They required high-end graphics and systems to deliver their immersive gameplay. But times have changed. With the rise of gaming-oriented smartphones, you can now enjoy PC-like gaming experiences on your Android device. Thanks to these technological advancements and faster internet […]

Roblox: Fruit Battlegrounds codes (January 2025)

Roblox: Fruit Battlegrounds codes (January 2025)

Fruit Battlegrounds codes are all about getting more gems and help you to shoot up your rank in this One Piece anime-inspired game. This Fruit Battlegrounds was made by Popo developer. It is an action-packed game where players battle it out using unique fruit-based abilities. With constant updates, new fruits, and exciting challenges, it’s a fruity frenzy you won’t […]

Roblox: Ultimate Football Codes (January 2025)

Roblox: Ultimate Football Codes (January 2025)

Want to get some extra items for Ultimate Football in Roblox? You’ve come to the right place! Here’s the latest list of codes to help you score touchdowns and look stylish on the field. These codes offer free rewards such as coins and cosmetics to enhance your gameplay. What are Ultimate Football Codes? Ultimate Football […]

Roblox: Da Hood Codes (January 2025)

Roblox: Da Hood Codes (January 2025)

Are you a fan of Roblox games, in this article we will look at the Roblox Da Hood Codes for December 2024 that will help you unlock exclusive items, improve your gameplay and dominate the streets of Da Hood. You can feel that the game is inspired by the Grand Theft Auto series and there […]