<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rahul Arya on Medium]]></title>
        <description><![CDATA[Stories by Rahul Arya on Medium]]></description>
        <link>https://medium.com/@rahul-arya?source=rss-9b555f5c7043------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*pXxt7QWQnS3pxyRj</url>
            <title>Stories by Rahul Arya on Medium</title>
            <link>https://medium.com/@rahul-arya?source=rss-9b555f5c7043------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 18:05:35 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahul-arya/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Add Memory to Your AI Agent]]></title>
            <link>https://medium.com/@rahul-arya/add-memory-to-your-ai-agent-7ed7b2bf860e?source=rss-9b555f5c7043------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ed7b2bf860e</guid>
            <dc:creator><![CDATA[Rahul Arya]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 09:40:48 GMT</pubDate>
            <atom:updated>2025-10-16T09:40:48.416Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Prequisite: H<a href="https://medium.com/@rahul-arya/how-ai-agents-remember-a-beginners-simple-guide-5da2db085ce2">ow AI agents remember: A beginners simple guide</a></blockquote><p>In this article, I’ll demonstrate two real-world ways of implementing memory in agents, with some hands-on code and their advantages/disadvantages. Once you’ve read this, you can try implementing one of the approaches yourself.</p><p>The Two Types of Memory We’ll Implement</p><ul><li><strong>Short‑Term (Session) Memory: </strong>Remembers during a single conversation / session.</li><li><strong>Long‑Term (Persistent) Memory: </strong>Persists through sessions, restarts, or extended time.</li></ul><p>We will contrast them, demonstrate how to use, and when to apply which.</p><h3>Approach A: Short‑Term Memory</h3><p>The memory that exists while the agent is talking / in a session. When the session ends, this memory is lost. It helps with context by remembering what user has said previously in the same conversation so agent does not repeat or ask again.</p><p>Simple Implementation Idea — You can use a buffer or queue data structure. For instance in Python:</p><pre>MAX_CONTEXT_LEN = 5<br>short_term_history = []<br><br>def add_to_history(user_msg, agent_msg):<br>    short_term_history.append((&quot;user&quot;, user_msg))<br>    short_term_history.append((&quot;agent&quot;, agent_msg))<br>    while len(short_term_history) &gt; MAX_CONTEXT_LEN * 2:  <br>        short_term_history.pop(0)<br><br>def build_prompt(user_msg):<br>    context = &quot;&quot;<br>    for speaker, msg in short_term_history:<br>        context += f&quot;{speaker}: {msg}\n&quot;<br>    context += f&quot;user: {user_msg}\nagent:&quot;<br>    return context</pre><ul><li>Each time user sends something, you contribute to history.</li><li>When sending prompt to LLM, append current history.</li><li>Should not be too long so LLM’s context window is not full / costly.</li></ul><p><strong>Pros</strong>: <br>- Easy to deploy<br>- Low storage / infrastructure required<br>- Quick to recall (only memory in-process)</p><p><strong>Cons</strong>:<br>- If conversation is lengthy, older parts lost<br>- Can lose critical information<br>- Does not persist outside this session<br>- Memory is volatile; you lose everything on process restart</p><h3>Approach B: Long‑Term Persistent Memory</h3><p>It is used for storing memory somewhere (e.g. database, files, vector stores). An agent can fetch pieces of this memory later even after sessions terminate or system reboot. It is good for remembering user preferences, repeated facts, learning between interactions.</p><h4><strong>How to Build It?</strong></h4><ul><li><strong>Choose Storage Backend<br>- Vector Database: </strong>To store embeddings (semantic representation) so agent can fetch “similar” memory to given query. Tools like Chroma DB, FAISS(Facebook AI Similarity Search) etc.<br>- <strong>Metadata/Relational Store: </strong>Keep structured data (user name, schema preferences) in relational db or even JSON file.</li><li><strong>Embedding / Vector Representation<br>- </strong>To store text (memory content) you embed using an embedding model (OpenAI, Sentence‑Transformer etc.).<br>- These embeddings assist in similarity search: given new user input, agent embeds it, and subsequently locates previously stored memory items which are semantically equivalent.</li><li><strong>Memory Retriever<br>- Query vector database</strong>: By current context, return top‑k memory items matching.<br>- Maybe use thresholds (similarity score) or metadata filters (e.g. only memories of type “preference”, or “project X”) to exclude irrelevant memory.</li><li><strong>Updating Memory<br>- </strong>Adding new memory.<br>- Maybe summarization or deleting old/less useful items.<br>- <strong>Structuring memory</strong>: Tag, classify, link similar memories together. Example: A-MEM framework generates tags, keywords, links for memory items.</li></ul><p>Example Code Sketch (Python + Vector DB + LangChain style)</p><pre>from langchain.embeddings import OpenAIEmbeddings<br>from langchain.vectorstores import FAISS<br>from langchain.chat_models import ChatOpenAI<br>from langchain.chains import RetrievalQA<br><br>embedder = OpenAIEmbeddings()<br>vector_store = FAISS.from_texts(texts=[], embedding=embedder)<br><br>def add_memory(text):<br>    emb = embedder.embed_query(text)<br>    vector_store.add_documents([text])<br><br>def retrieve_memory(query, k=3):<br>    return vector_store.similarity_search(query, k=k)<br><br>def agent_respond(user_input):<br>    past_memories = retrieve_memory(user_input)<br>    prompt = &quot;Here are some things I remember:\n&quot;<br>    for mem in past_memories:<br>        prompt += &quot;- &quot; + mem + &quot;\n&quot;<br>    prompt += f&quot;User: {user_input}\nAgent:&quot;<br>    response = ChatOpenAI().generate(prompt)  <br>    add_memory(f&quot;user said: {user_input}. Agent answered: {response}&quot;)<br>    return response</pre><p><strong>Pros</strong>:<br>- Agent recalls across restarts / sessions<br>- Better personalization: can leverage past preferences, history<br>- Agents can give richer responses because have more “background”.</p><p><strong>Cons</strong>:<br>- More infra: need a vector database, embedding models, maybe persistence<br>- Storage cost, embedding computation, retrieval latency<br>- Risk of irrelevant or stale memory: needs pruning / summarization / clean‑up.</p><h3>Wrap Up</h3><p>Short‑Term Memory is sufficient for session‑only requirements, fast, easy, cheap.</p><p>Long‑Term Memory is stronger but more setup to do (vector databases, embeddings, storage).</p><p>If you are new, begin with short‑term. Later, if you’re okay, then attempt to merge: apply short‑term + long‑term both so that your agent is smart but not so slow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ed7b2bf860e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How AI Agents Remember: A Beginner’s Simple Guide]]></title>
            <link>https://medium.com/@rahul-arya/how-ai-agents-remember-a-beginners-simple-guide-5da2db085ce2?source=rss-9b555f5c7043------2</link>
            <guid isPermaLink="false">https://medium.com/p/5da2db085ce2</guid>
            <dc:creator><![CDATA[Rahul Arya]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 08:02:04 GMT</pubDate>
            <atom:updated>2025-10-16T08:02:04.199Z</atom:updated>
            <content:encoded><![CDATA[<p>Here we’ll discuss how AI agents can remember, why they need to, and how you can give simple memory to your own agents without needing to be technologically expert.</p><h3>What Is an AI Agent?</h3><p>An AI agent is software programmed to accomplish tasks on its own. Unlike older chatbots that do not remember anything past a single conversation, memory-based AI agents keep records of previous conversations and can therefore be more useful and personalized.</p><h4>Memory Matters</h4><p>Imagine bringing in a chatbot to know your name, and then it repeating the question within the same chat. Harassing, right? Memory assists AI agents to:</p><ol><li>Remember your name or liking.</li><li>Keep context throughout consecutive interactions.</li><li>Provide more customized responses.</li></ol><h4>Types of Memory in AI Agents</h4><p>AI agents typically have two types of memory:</p><ul><li><strong>Short-Term Memory</strong>: Temporarily stores information, like the current conversation.</li><li><strong>Long-Term Memory</strong>: Remembers information for long periods, like your favorite interests or hobbies.</li></ul><h4>Incorporating Memory into Your AI Agent</h4><ul><li><strong>Short-Term Memory</strong>: Store a history of previous conversations to keep context.</li><li><strong>Long-term Memory</strong>: Store user preferences in a database or file to recall data.</li></ul><h4>Memory Trade-Offs</h4><p>Memory enhances personalization but with some cost:</p><ul><li><strong>Storage</strong>: Larger memory uses more storage.</li><li><strong>Performance</strong>: Reading and writing memory affects response time.</li><li><strong>Privacy</strong>: Storage of user information entails cautious management to safeguard user data.</li></ul><h4>Simple Example: Python Code Snippet</h4><p>Here is an example of how you mimic placing memory into a Python-based AI agent:</p><pre>short_term_memory = []<br>long_term_memory = {}<br><br>def update_memory(user_input):<br>    short_term_memory.append(user_input)<br>    if len(short_term_memory) &gt; 5:<br>        short_term_memory.pop(0)<br><br>    if &quot;name&quot; in user_input:<br>        long_term_memory[&quot;name&quot;] = user_input.split()[-1]<br><br>def generate_response():<br>    if &quot;name&quot; in long_term_memory:<br>        return f&quot;Hello, {long_term_memory[&#39;name&#39;]}!&quot;<br>    return &quot;Hello!&quot;</pre><h4>Conclusion</h4><p>Adding memory to your AI agents can make them more useful and entertaining to work with. By beginning with easy methods and then experimenting with increasingly complex methods, you can create agents that learn and remember over time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5da2db085ce2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Google Login in your Flutter App with Error Handling]]></title>
            <link>https://medium.com/@rahul-arya/implementing-google-login-in-your-flutter-app-with-error-handling-23b2a06fdd7b?source=rss-9b555f5c7043------2</link>
            <guid isPermaLink="false">https://medium.com/p/23b2a06fdd7b</guid>
            <category><![CDATA[google-authentication]]></category>
            <category><![CDATA[google-login]]></category>
            <category><![CDATA[login]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[firebaseauthentication]]></category>
            <dc:creator><![CDATA[Rahul Arya]]></dc:creator>
            <pubDate>Tue, 03 Sep 2024 07:42:33 GMT</pubDate>
            <atom:updated>2024-09-03T07:42:33.914Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will walk you through implementing Google Login in a Flutter application for Android, iOS, and Web using the latest versions of Flutter and Dart 3.</p><h4>Step 1: Set Up Your Flutter Project</h4><ol><li><strong>Create a new Flutter project:</strong> Open your terminal and run the following commands:</li></ol><pre>flutter create google_login_demo<br>cd google_login_demo</pre><p>2. <strong>Add dependencies in </strong><strong>pubspec.yaml:</strong> Open the pubspec.yaml file and add the following dependencies:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  firebase_core: ^2.4.1<br>  firebase_auth: ^4.2.0<br>  google_sign_in: ^6.1.0</pre><p>3. <strong>Install the dependencies:</strong> Run the following command to install the dependencies:</p><pre>flutter pub get</pre><h4>Step 2: Configure Firebase</h4><ol><li><strong>Create a Firebase project:</strong></li></ol><ul><li>Go to the <a href="https://console.firebase.google.com/">Firebase Console</a>.</li><li>Click on “Add project” and follow the steps to create a new project.</li></ul><p><strong>2. Add your app to Firebase:</strong></p><ul><li>In the Firebase Console, click on the project you created.</li><li>Click on the Android icon to add an Android app, and follow the instructions to register your app.</li><li>Download the google-services.json file and place it in the android/app/ directory.</li><li>Similarly, click on the iOS icon to add an iOS app, and follow the instructions to register your app.</li><li>Download the GoogleService-Info.plist file and place it in the ios/Runner/ directory.</li><li>For Web, click on the Web icon to add a web app, and follow the instructions.</li></ul><p><strong>3. Configure Android:</strong></p><ul><li>Open android/build.gradle and add the following classpath:</li></ul><pre>dependencies {<br>    classpath &#39;com.google.gms:google-services:4.3.15&#39;<br>}</pre><ul><li>Open android/app/build.gradle and add the following line at the bottom:</li></ul><pre>apply plugin: &#39;com.google.gms.google-services&#39;</pre><p><strong>4. Configure iOS:</strong></p><ul><li>Open ios/Runner.xcworkspace in Xcode.</li><li>Drag and drop the GoogleService-Info.plist file into the Runner project in Xcode.</li></ul><p><strong>5. Configure Web:</strong></p><ul><li>Open web/index.html and add the following Firebase SDK scripts:</li></ul><pre>&lt;script src=&quot;https://www.gstatic.com/firebasejs/9.15.0/firebase-app.js&quot;&gt;&lt;/script&gt;<br>&lt;script src=&quot;https://www.gstatic.com/firebasejs/9.15.0/firebase-auth.js&quot;&gt;&lt;/script&gt;</pre><h4>Step 3: Initialize Firebase in Flutter</h4><ol><li><strong>Update </strong><strong>main.dart:</strong> Create or update the main.dart file to initialize Firebase:</li></ol><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:firebase_core/firebase_core.dart&#39;;<br>import &#39;package:google_sign_in/google_sign_in.dart&#39;;<br>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br><br>void main() async {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  await Firebase.initializeApp();<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp();<br>  }<br>}</pre><h4>Step 4: Implement Google Sign-In</h4><ol><li><strong>Create </strong><strong>sign_in_screen.dart:</strong> Create a new file lib/sign_in_screen.dart and add the following code:</li></ol><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:google_sign_in/google_sign_in.dart&#39;;<br>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br><br>class SignInScreen extends StatefulWidget {<br>  @override<br>  _SignInScreenState createState() =&gt; _SignInScreenState();<br>}<br><br>class _SignInScreenState extends State&lt;SignInScreen&gt; {<br>  final GoogleSignIn _googleSignIn = GoogleSignIn();<br>  final FirebaseAuth _auth = FirebaseAuth.instance;<br><br>  Future&lt;User?&gt; _signInWithGoogle() async {<br>    final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();<br>    if (googleUser == null) {<br>      return null;<br>    }<br><br>    final GoogleSignInAuthentication googleAuth = await googleUser.authentication;<br>    final AuthCredential credential = GoogleAuthProvider.credential(<br>      accessToken: googleAuth.accessToken,<br>      idToken: googleAuth.idToken,<br>    );<br><br>    final UserCredential userCredential = await _auth.signInWithCredential(credential);<br>    return userCredential.user;<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Google Sign-In Demo&#39;),<br>      ),<br>      body: Center(<br>        child: ElevatedButton(<br>          onPressed: () async {<br>            User? user = await _signInWithGoogle();<br>            if (user != null) {<br>              ScaffoldMessenger.of(context).showSnackBar(<br>                SnackBar(content: Text(&#39;Sign In Successful: ${user.displayName}&#39;)),<br>              );<br>            }<br>          },<br>          child: Text(&#39;Sign In with Google&#39;),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p><strong>2. Update </strong><strong>main.dart to include </strong><strong>SignInScreen:</strong> Ensure that main.dart imports and uses SignInScreen:</p><pre>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: SignInScreen(),<br>    );<br>  }<br>}</pre><h4>Step 5: Run Your App</h4><ol><li><strong>Run the app on Android/iOS:</strong></li></ol><pre>flutter run</pre><p>2. <strong>Run the app on Web:</strong></p><pre>flutter run -d chrome</pre><p>This guide covers the basic setup for implementing Google Login in Flutter for Android, iOS, and Web. Make sure to follow the Firebase setup instructions carefully for each platform.</p><h3><strong>BONUS: Handle errors during Google Sign-In process in Flutter</strong></h3><p>Handling errors during the Google Sign-In process in Flutter is crucial to provide a smooth user experience. You can handle errors by catching exceptions and displaying appropriate messages to the user. Here’s how you can do it:</p><h3>Step-by-Step Guide to Handling Errors</h3><ol><li><strong>Update the </strong><strong>_signInWithGoogle method to handle errors: </strong>Modify the _signInWithGoogle method to catch exceptions and handle different error scenarios.</li></ol><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:google_sign_in/google_sign_in.dart&#39;;<br>import &#39;package:firebase_auth/firebase_auth.dart&#39;;<br><br>class SignInScreen extends StatefulWidget {<br>  @override<br>  _SignInScreenState createState() =&gt; _SignInScreenState();<br>}<br><br>class _SignInScreenState extends State&lt;SignInScreen&gt; {<br>  final GoogleSignIn _googleSignIn = GoogleSignIn();<br>  final FirebaseAuth _auth = FirebaseAuth.instance;<br><br>  Future&lt;User?&gt; _signInWithGoogle() async {<br>    try {<br>      final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();<br>      if (googleUser == null) {<br>        // The user canceled the sign-in<br>        return null;<br>      }<br><br>      final GoogleSignInAuthentication googleAuth = await googleUser.authentication;<br>      final AuthCredential credential = GoogleAuthProvider.credential(<br>        accessToken: googleAuth.accessToken,<br>        idToken: googleAuth.idToken,<br>      );<br><br>      final UserCredential userCredential = await _auth.signInWithCredential(credential);<br>      return userCredential.user;<br>    } catch (e) {<br>      // Handle different error scenarios<br>      if (e is FirebaseAuthException) {<br>        switch (e.code) {<br>          case &#39;account-exists-with-different-credential&#39;:<br>            _showErrorDialog(&#39;The account already exists with a different credential.&#39;);<br>            break;<br>          case &#39;invalid-credential&#39;:<br>            _showErrorDialog(&#39;The credential is invalid.&#39;);<br>            break;<br>          case &#39;operation-not-allowed&#39;:<br>            _showErrorDialog(&#39;Operation not allowed.&#39;);<br>            break;<br>          case &#39;user-disabled&#39;:<br>            _showErrorDialog(&#39;The user has been disabled.&#39;);<br>            break;<br>          case &#39;user-not-found&#39;:<br>            _showErrorDialog(&#39;The user was not found.&#39;);<br>            break;<br>          case &#39;wrong-password&#39;:<br>            _showErrorDialog(&#39;Wrong password.&#39;);<br>            break;<br>          default:<br>            _showErrorDialog(&#39;An unknown error occurred.&#39;);<br>        }<br>      } else {<br>        _showErrorDialog(&#39;An unknown error occurred.&#39;);<br>      }<br>      return null;<br>    }<br>  }<br><br>  void _showErrorDialog(String message) {<br>    showDialog(<br>      context: context,<br>      builder: (context) {<br>        return AlertDialog(<br>          title: Text(&#39;Error&#39;),<br>          content: Text(message),<br>          actions: [<br>            TextButton(<br>              onPressed: () {<br>                Navigator.of(context).pop();<br>              },<br>              child: Text(&#39;OK&#39;),<br>            ),<br>          ],<br>        );<br>      },<br>    );<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Google Sign-In Demo&#39;),<br>      ),<br>      body: Center(<br>        child: ElevatedButton(<br>          onPressed: () async {<br>            User? user = await _signInWithGoogle();<br>            if (user != null) {<br>              ScaffoldMessenger.of(context).showSnackBar(<br>                SnackBar(content: Text(&#39;Sign In Successful: ${user.displayName}&#39;)),<br>              );<br>            }<br>          },<br>          child: Text(&#39;Sign In with Google&#39;),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>2. <strong>Explanation of Error Handling:</strong></p><ul><li><strong>Try-Catch Block:</strong> The _signInWithGoogle method is wrapped in a try-catch block to catch any exceptions that may occur during the sign-in process.</li><li><strong>FirebaseAuthException:</strong> Specific Firebase authentication errors are handled by checking the exception type and its code.</li><li><strong>General Exception:</strong> Any other exceptions are caught and handled by displaying a generic error message.</li><li><strong>Error Dialog:</strong> The _showErrorDialog method is used to display error messages in a dialog box.</li></ul><p>By implementing these error-handling mechanisms, you can provide a better user experience and handle various error scenarios gracefully during the Google Sign-In process in your Flutter application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23b2a06fdd7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Implementing Facebook Login in Your Flutter App]]></title>
            <link>https://medium.com/@rahul-arya/implementing-facebook-login-in-your-flutter-app-0cdf1d04e50a?source=rss-9b555f5c7043------2</link>
            <guid isPermaLink="false">https://medium.com/p/0cdf1d04e50a</guid>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[facebook-developer]]></category>
            <category><![CDATA[facebook-login]]></category>
            <dc:creator><![CDATA[Rahul Arya]]></dc:creator>
            <pubDate>Thu, 12 Oct 2023 18:34:27 GMT</pubDate>
            <atom:updated>2023-10-12T18:34:27.730Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction:</strong></p><p>Facebook Login is a popular way to allow users to log in to your Flutter app. In this tutorial, we will guide you through the steps to implement Facebook Login in your Flutter app using the latest dependencies.</p><p><strong>Prerequisites:</strong></p><p>Before we start, make sure you have the following prerequisites in place:</p><ol><li>A Flutter development environment set up.</li><li>A Facebook Developer account.</li><li>A Flutter project is created.</li></ol><p><strong>Step 1: Create a Facebook App:</strong></p><ul><li>Go to the <a href="https://developers.facebook.com/">Facebook Developers portal</a> and create a new app.</li><li>Note down your App ID.</li></ul><p><strong>Step 2: Adding Dependencies:</strong></p><p>In your Flutter project’s <strong>pubspec.yaml</strong> file, add the following dependencies:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_facebook_login: ^4.2.0</pre><p>Run <strong>flutter pub get</strong> to install the dependencies.</p><p><strong>Step 3: Configure Android and iOS:</strong></p><ul><li>For Android, add your Facebook App ID and the necessary permissions to your <strong>android/app/src/main/AndroidManifest.xml</strong> file. Here&#39;s an example:</li></ul><pre>&lt;meta-data<br>    android:name=&quot;com.facebook.sdk.ApplicationId&quot;<br>    android:value=&quot;@string/facebook_app_id&quot;/&gt;<br><br>&lt;activity<br>    android:name=&quot;com.facebook.FacebookActivity&quot;<br>    android:configChanges=<br>        &quot;keyboard|keyboardHidden|screenLayout|screenSize|orientation&quot;<br>    android:label=&quot;@string/app_name&quot; /&gt;<br><br>&lt;activity<br>    android:name=&quot;com.facebook.CustomTabActivity&quot;<br>    android:exported=&quot;true&quot;&gt;<br>    &lt;intent-filter&gt;<br>        &lt;action android:name=&quot;android.intent.action.VIEW&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;<br>        &lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;<br>        &lt;data android:scheme=&quot;@string/fb_login_protocol_scheme&quot; /&gt;<br>    &lt;/intent-filter&gt;<br>&lt;/activity&gt;</pre><ul><li>For iOS, add your Facebook App ID and the URL Scheme in your <strong>ios/Runner/Info.plist</strong> file:</li></ul><pre>&lt;key&gt;CFBundleURLTypes&lt;/key&gt;<br>&lt;array&gt;<br>    &lt;dict&gt;<br>        &lt;key&gt;CFBundleURLSchemes&lt;/key&gt;<br>        &lt;array&gt;<br>            &lt;string&gt;fbYOUR_APP_ID&lt;/string&gt;<br>        &lt;/array&gt;<br>    &lt;/dict&gt;<br>&lt;/array&gt;<br>&lt;key&gt;FacebookAppID&lt;/key&gt;<br>&lt;string&gt;YOUR_APP_ID&lt;/string&gt;<br>&lt;key&gt;FacebookDisplayName&lt;/key&gt;<br>&lt;string&gt;Your App Name&lt;/string&gt;</pre><p><strong>Step 4: Implement Facebook Login:</strong></p><p>In your Flutter app, create a function to handle Facebook login. Here’s an example:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:flutter_facebook_login/flutter_facebook_login.dart&#39;;<br><br>void main() {<br>  runApp(MyApp());<br>}<br><br>class MyApp extends StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    return MaterialApp(<br>      home: MyHomePage(),<br>    );<br>  }<br>}<br><br>class MyHomePage extends StatelessWidget {<br>  final facebookLogin = FacebookLogin();<br><br>  Future&lt;void&gt; _loginWithFacebook() async {<br>    final result = await facebookLogin.logIn([&#39;email&#39;]);<br>    switch (result.status) {<br>      case FacebookLoginStatus.loggedIn:<br>        // You&#39;re logged in with Facebook, use result.accessToken to make API calls.<br>        break;<br>      case FacebookLoginStatus.cancelledByUser:<br>        // User cancelled the login.<br>        break;<br>      case FacebookLoginStatus.error:<br>        // There was an error during login.<br>        break;<br>    }<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(<br>        title: Text(&#39;Facebook Login Demo&#39;),<br>      ),<br>      body: Center(<br>        child: ElevatedButton(<br>          onPressed: _loginWithFacebook,<br>          child: Text(&#39;Login with Facebook&#39;),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p><strong>Step 5: Test Your App:</strong></p><p>Run your Flutter app and test the Facebook login functionality. Users will be able to log in using their Facebook credentials.</p><p><strong>Conclusion:</strong></p><p>In this tutorial, we’ve walked through the steps to implement Facebook Login in your Flutter app using the latest dependencies. By following these steps, you can enhance the user experience and increase user engagement in your Flutter app.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0cdf1d04e50a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>