<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mayank Variya</title>
    <description>The latest articles on DEV Community by Mayank Variya (@mayank_variya).</description>
    <link>https://dev.to/mayank_variya</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2183034%2Fc66d3338-e1f4-441d-83f7-498de6b52170.jpg</url>
      <title>DEV Community: Mayank Variya</title>
      <link>https://dev.to/mayank_variya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mayank_variya"/>
    <language>en</language>
    <item>
      <title>Khelo: From Streets to Stadiums - A Developer's Guide 🏏</title>
      <dc:creator>Mayank Variya</dc:creator>
      <pubDate>Thu, 24 Oct 2024 09:00:01 +0000</pubDate>
      <link>https://dev.to/mayank_variya/khelo-from-streets-to-stadiums-a-developers-guide-18ka</link>
      <guid>https://dev.to/mayank_variya/khelo-from-streets-to-stadiums-a-developers-guide-18ka</guid>
      <description>&lt;h2&gt;
  
  
  Open-Source, Multi-Platform Cricket Management App Built with Flutter &amp;amp; Firebase
&lt;/h2&gt;

&lt;p&gt;Hello, fellow developers! 👋&lt;/p&gt;

&lt;p&gt;Are you a cricket enthusiast who also loves to build, extend, or explore apps? We’re excited to introduce &lt;strong&gt;Khelo&lt;/strong&gt;, an open-source, multi-platform cricket management app built with &lt;strong&gt;Flutter&lt;/strong&gt;. Whether you’re looking to learn new patterns like &lt;strong&gt;Riverpod&lt;/strong&gt; for state management or want to dive into real-time data handling with &lt;strong&gt;Firebase&lt;/strong&gt;, Khelo offers a great learning opportunity for developers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Khelo?
&lt;/h2&gt;

&lt;p&gt;Khelo isn’t just for end users—it’s for developers who want to see how a modern, multi-platform app can be structured using &lt;strong&gt;Flutter&lt;/strong&gt;. We’ve designed it to serve as a resource for anyone exploring &lt;strong&gt;Flutter&lt;/strong&gt;, &lt;strong&gt;Firebase&lt;/strong&gt;, and state management while utilizing the &lt;strong&gt;MVVM (Model-View-ViewModel)&lt;/strong&gt; architecture to keep the app maintainable and scalable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tech Stack at a Glance
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flutter&lt;/strong&gt; for cross-platform development (iOS &amp;amp; Android)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firebase Firestore&lt;/strong&gt; for real-time database management and &lt;strong&gt;Firebase Authentication&lt;/strong&gt; for user handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Riverpod&lt;/strong&gt; for scalable state management&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;MVVM Architecture&lt;/strong&gt; for a clean separation of concerns between the UI and business logic&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What Can You Learn From Khelo?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;MVVM with Riverpod:&lt;/strong&gt; Discover how the &lt;strong&gt;MVVM architecture&lt;/strong&gt; is combined with Riverpod for state management, ensuring a clean, modular design.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Real-Time Data Handling with Firebase:&lt;/strong&gt; See how Firestore’s real-time features are used for live updates in match stats, player info, and team data.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authentication with Firebase:&lt;/strong&gt; Understand how Firebase Authentication provides seamless user management and security.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modular Architecture:&lt;/strong&gt; Learn how we’ve separated features like Profile Management, Team Creation, and Match Data Recording into manageable components.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Core Features for Developers to Explore
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Player &amp;amp; Team Profiles:&lt;/strong&gt; Learn how to structure data models and implement CRUD operations for profiles and teams.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Match Tracking:&lt;/strong&gt; Dive into the logic behind recording match data, from toss results to performance tracking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Modular UI Components:&lt;/strong&gt; Understand how the UI is built with reusable and extensible components, following the MVVM architecture.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance &amp;amp; Statistics Tracking:&lt;/strong&gt; Explore the logic used to analyze player and team performance over time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explore the Repo
&lt;/h2&gt;

&lt;p&gt;Check out the &lt;strong&gt;Khelo&lt;/strong&gt; GitHub repo to explore the full codebase. It’s a great opportunity to learn from a real-world app built with the latest tools in Flutter, Firebase, and state management practices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/canopas/khelo" rel="noopener noreferrer"&gt;Khelo on GitHub&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Get Started
&lt;/h2&gt;

&lt;p&gt;Ready to dive in? Fork the repo, explore the architecture, and use Khelo as a resource to advance your skills in Flutter development.&lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fassets.dev.to%2Fassets%2Fgithub-logo-5a155e1f9a670af7944dd5e12375bc76ed542ea80224905ecaf878b9157cdefc.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/canopas" rel="noopener noreferrer"&gt;
        canopas
      &lt;/a&gt; / &lt;a href="https://github.com/canopas/khelo" rel="noopener noreferrer"&gt;
        khelo
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Khelo - An open-source app for easy cricket team management and performance tracking.
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt; &lt;a href="https://canopas.com/contact" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fcta%2Fcta_banner.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h1 class="heading-element"&gt;Khelo - From Streets to Stadiums 🏏&lt;/h1&gt;
&lt;/div&gt;
&lt;p&gt;&lt;strong&gt;Your Ultimate Companion for Cricket Management&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/cover-image.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fcover-image.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Overview&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;Welcome to Khelo, an open-source multi-platform app designed to cater to all your cricket needs, whether you're a cricket enthusiast, a team manager, or a player. With a wide array of features, our app simplifies the management of cricket teams, players, matches, and performance records. It's like having a personal assistant for your team!&lt;/p&gt;
&lt;p&gt;Khelo is built using Flutter and Dart, leveraging Firestore for database management and Firebase for authentication. This project employs Riverpod as its state management solution, adhering to a clean architecture approach organized into multiple modules.&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Download App&lt;/h2&gt;
&lt;/div&gt;
&lt;p&gt;&lt;a href="https://play.google.com/store/apps/details?id=com.canopas.khelo" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fcta%2Fgoogle_play.png" width="200"&gt;&lt;/a&gt;
&lt;a href="https://apps.apple.com/us/app/khelo/id6480175424" rel="nofollow noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fcta%2Fapp_store.png" width="200"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Screenshots&lt;/h2&gt;

&lt;/div&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th width="32%"&gt;Matches Record&lt;/th&gt;
    &lt;th width="32%"&gt;Teams List&lt;/th&gt;
    &lt;th width="32%"&gt;Start New Match&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_1.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_1.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_2.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_2.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_3.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_3.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;  
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
  &lt;tbody&gt;
&lt;tr&gt;
    &lt;th width="32%"&gt;Score Board&lt;/th&gt;
    &lt;th width="32%"&gt;Commentary&lt;/th&gt;
    &lt;th width="32%"&gt;Squad&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_4.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_4.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_5.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_5.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
    &lt;td&gt;&lt;a rel="noopener noreferrer" href="https://github.com/canopas/khelo./screenshots/screen_shot_6.png"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fgithub.com%2Fcanopas%2Fkhelo.%2Fscreenshots%2Fscreen_shot_6.png" alt=""&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;  
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;
&lt;div class="markdown-heading"&gt;
&lt;h2 class="heading-element"&gt;Features 🌟🌟&lt;/h2&gt;

&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Profile Management&lt;/strong&gt;: Effortlessly create and manage profiles for players, coaches, and team managers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Team Creation&lt;/strong&gt;: Form your dream team by easily adding players and managing team compositions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Player Management&lt;/strong&gt;…&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/div&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/canopas/khelo" rel="noopener noreferrer"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;


</description>
      <category>opensource</category>
      <category>flutter</category>
      <category>github</category>
      <category>firebase</category>
    </item>
    <item>
      <title>Streaming Real-Time Data in Flutter: A Step-by-Step Guide for Developers</title>
      <dc:creator>Mayank Variya</dc:creator>
      <pubDate>Thu, 24 Oct 2024 08:59:07 +0000</pubDate>
      <link>https://dev.to/mayank_variya/streaming-real-time-data-in-flutter-a-step-by-step-guide-for-developers-34eh</link>
      <guid>https://dev.to/mayank_variya/streaming-real-time-data-in-flutter-a-step-by-step-guide-for-developers-34eh</guid>
      <description>&lt;p&gt;In today’s fast-paced world, providing real-time data updates is crucial for any application. Users expect instant access to live information, whether it’s scores, stats, or any other dynamic data. This guide will demonstrate how to manage real-time data updates in a Flutter application using Firebase, illustrated through an example of streaming cricket match data in our Khelo app—a cricket team management platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Choose Streams?
&lt;/h2&gt;

&lt;p&gt;Streams are an excellent way to handle asynchronous data in Flutter. They allow your app to listen for updates in real time, making them perfect for applications that require live data. With Firebase Firestore, you can easily implement this functionality for any type of data.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Your Flutter Project
&lt;/h2&gt;

&lt;p&gt;Before diving into the code, ensure you have the following set up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flutter SDK:&lt;/strong&gt; &lt;a href="https://docs.flutter.dev/get-started/install?gad_source=1&amp;amp;gclid=Cj0KCQjwmt24BhDPARIsAJFYKk2PhFZ7jV8LB6h0yu03cTX9Y9LTP-bjQ3hBXP8BNOdQKTliNP1FdRoaApadEALw_wcB&amp;amp;gclsrc=aw.ds" rel="noopener noreferrer"&gt;Install and configure the Flutter SDK&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firebase Project:&lt;/strong&gt; &lt;a href="https://firebase.google.com/docs/flutter/setup?platform=ios" rel="noopener noreferrer"&gt;Create and configure your Firebase project&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Firestore Database:&lt;/strong&gt; &lt;a href="https://firebase.flutter.dev/docs/firestore/overview" rel="noopener noreferrer"&gt;Set up your Firestore database&lt;/a&gt; to store your data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Riverpod Package:&lt;/strong&gt; &lt;a href="https://riverpod.dev/" rel="noopener noreferrer"&gt;Add the Riverpod package&lt;/a&gt; to manage state efficiently.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Freezed Package:&lt;/strong&gt; &lt;a href="https://pub.dev/packages/freezed" rel="noopener noreferrer"&gt;Add the Freezed package&lt;/a&gt; to simplify data class creation and immutable state management.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Create Firestore Collection
&lt;/h2&gt;

&lt;p&gt;Start by creating a Firestore collection named &lt;code&gt;matches&lt;/code&gt;, where each document represents a cricket match. Here’s how you might define your Firestore setup in your app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final _dataCollection = FirebaseFirestore.instance.collection('matches');
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 2: Stream Data by ID
&lt;/h2&gt;

&lt;p&gt;Next, implement a function to stream data by its unique ID. This function will listen for changes in the Firestore document and return updated data in real time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Stream&amp;lt;MatchModel&amp;gt; streamDataById(String id) {
  return _dataCollection.doc(id).snapshots().asyncMap((snapshot) async {
    if (snapshot.exists) {
      return MatchModel.fromMap(snapshot.data()!);
    }
    throw Exception('Data not found');
  }).handleError((error, stack) =&amp;gt; throw AppError.fromError(error, stack));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Key Points:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;snapshots():&lt;/strong&gt; Subscribes to real-time updates from Firestore.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;asyncMap:&lt;/strong&gt;  Performs asynchronous transformations on the data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Utilizes &lt;code&gt;handleError&lt;/code&gt; to manage any errors gracefully.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 3: Implement State Management with Riverpod
&lt;/h2&gt;

&lt;p&gt;Create a state class to manage the data state within your application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@freezed
class MatchDetailTabState with _$MatchDetailTabState {
  const factory MatchDetailTabState({
    Object? error,
    MatchModel? match,
    @Default(false) bool loading,
  }) = _MatchDetailTabState;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting Up the Provider
&lt;/h2&gt;

&lt;p&gt;Use a &lt;code&gt;StateNotifierProvider&lt;/code&gt; to expose your data state throughout the app:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final matchDetailTabStateProvider = StateNotifierProvider.autoDispose&amp;lt;
    MatchDetailTabViewNotifier, MatchDetailTabState&amp;gt;(
  (ref) =&amp;gt; MatchDetailTabViewNotifier(ref.read(matchServiceProvider)),
);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Load Data in the Notifier
&lt;/h2&gt;

&lt;p&gt;Implement the logic to load data using the stream within your notifier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MatchDetailTabViewNotifier extends StateNotifier&amp;lt;MatchDetailTabState&amp;gt; {
  MatchDetailTabViewNotifier(this._matchService) : super(const MatchDetailTabState());

  final MatchService _matchService;
  StreamSubscription? _matchStreamSubscription;
  late String _matchId; // Declare _matchId here

  void setData(String matchId) {
    loadMatch(matchId);
  }

  void loadMatch(String matchId) {
    state = state.copyWith(loading: true); // Set loading state

    _matchStreamSubscription = _matchService.streamMatchById(matchId).listen(
      (match) {
        state = state.copyWith(match: match, loading: false);
      },
      onError: (error) {
        state = state.copyWith(error: AppError.fromError(error), loading: false);
      },
    );
  }

  @override
  void dispose() {
    _matchStreamSubscription?.cancel();
    super.dispose();
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Loading State:&lt;/strong&gt; The loading state is set to &lt;code&gt;true&lt;/code&gt; while the data is being fetched and updated to &lt;code&gt;false&lt;/code&gt; once the data is received or if an error occurs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;State Management:&lt;/strong&gt; Updates the state whenever new match data is received.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Captures any errors and updates the state accordingly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Resource Management:&lt;/strong&gt; Cancels the stream subscription when the notifier is disposed to avoid memory leaks.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 5: Building the UI
&lt;/h2&gt;

&lt;p&gt;Create a simple UI to display the data. Show a loading indicator while data is being fetched, and then display the information once it is available.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MatchDetailTabScreen extends ConsumerStatefulWidget {
  final String matchId;

  const MatchDetailTabScreen({super.key, required this.matchId});

  @override
  ConsumerState createState() =&amp;gt; _MatchDetailTabScreenState();
}

class _MatchDetailTabScreenState extends ConsumerState&amp;lt;MatchDetailTabScreen&amp;gt; {
  late MatchDetailTabViewNotifier notifier;

  @override
  void initState() {
    super.initState();
    notifier = ref.read(matchDetailTabStateProvider.notifier);
    runPostFrame(() =&amp;gt; notifier.loadMatch(widget.matchId));
  }

  @override
  Widget build(BuildContext context) {
    final state = ref.watch(matchDetailTabStateProvider);

    return AppPage(
      title: state.match?.name ?? 'Match Details', // Handle null case
      body: Builder(
        builder: (context) {
          if (state.error != null) {
            return ErrorScreen(state.error); // Ensure error is not null
          }
          if (state.loading) {
            return Center(child: AppProgressIndicator());
          }
          return //Show UI;
        },
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Explanation:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Loading Indicator:&lt;/strong&gt; Displays a &lt;code&gt;CircularProgressIndicator&lt;/code&gt; while the data is being fetched.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Handling:&lt;/strong&gt; Shows an error message if something goes wrong.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Display Data:&lt;/strong&gt; Displays the match details once they are loaded.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example Implementation Screenshots
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqilx7s2liul1r5qgz2im.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqilx7s2liul1r5qgz2im.png" alt="Image description" width="411" height="836"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;With these steps, you can successfully manage real-time data updates in your Flutter app using Firebase Firestore. By implementing streams, you ensure that users receive timely updates, enhancing their overall experience in your applications.&lt;/p&gt;

&lt;p&gt;For more detailed code examples and additional information, feel free to check out our &lt;a href="https://github.com/canopas/khelo" rel="noopener noreferrer"&gt;Khelo GitHub repository&lt;/a&gt;. If you find this guide helpful, please give it a star on GitHub!&lt;/p&gt;

</description>
      <category>opensource</category>
      <category>flutter</category>
      <category>dart</category>
      <category>github</category>
    </item>
  </channel>
</rss>
