<?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>Forem: Chandram Dutta </title>
    <description>The latest articles on Forem by Chandram Dutta  (@chandramdutta).</description>
    <link>https://forem.com/chandramdutta</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%2F822141%2F3bf573df-640a-4763-a59b-c6deba6b922b.jpg</url>
      <title>Forem: Chandram Dutta </title>
      <link>https://forem.com/chandramdutta</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/chandramdutta"/>
    <language>en</language>
    <item>
      <title>Appwrite + Flutter: The Pilot Blog.</title>
      <dc:creator>Chandram Dutta </dc:creator>
      <pubDate>Thu, 05 Jan 2023 08:55:39 +0000</pubDate>
      <link>https://forem.com/chandramdutta/appwrite-flutter-the-pilot-blog-i1i</link>
      <guid>https://forem.com/chandramdutta/appwrite-flutter-the-pilot-blog-i1i</guid>
      <description>&lt;h3&gt;
  
  
  Let's learn to work with the best of the BaaS world and undoubtedly the best cross-platform UI toolkit.
&lt;/h3&gt;

&lt;p&gt;Hello, let's fasten our seatbelts cause this blog series will take you through creating your next billion-dollar startup full-stack app based on the best of the Open-source World. We will be learning to use &lt;a href="https://appwrite.io/" rel="noopener noreferrer"&gt;Appwrite&lt;/a&gt;, the Open-source Backend-as-a-Service, with &lt;a href="https://flutter.dev/" rel="noopener noreferrer"&gt;Flutter&lt;/a&gt;, the almighty UI toolkit to build an app which we will talk about in a moment.&lt;br&gt;
But first, let's install Appwrite and Flutter.&lt;/p&gt;
&lt;h2&gt;
  
  
  Appwrite Installation
&lt;/h2&gt;

&lt;p&gt;To install Appwrite, make sure you have &lt;a href="https://www.docker.com/" rel="noopener noreferrer"&gt;Docker&lt;/a&gt;. Here are the links to download and install Docker properly&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.docker.com/desktop/install/mac-install/" rel="noopener noreferrer"&gt;On a Mac&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.docker.com/desktop/install/windows-install/" rel="noopener noreferrer"&gt;On Windows&lt;/a&gt; (make sure you have WSL2 installed)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.docker.com/desktop/install/linux-install/" rel="noopener noreferrer"&gt;On Linux for Docker Desktop&lt;/a&gt;, tho I personally prefer downloading the &lt;a href="https://docs.docker.com/engine/install/ubuntu/" rel="noopener noreferrer"&gt;Docker Engine for Linux&lt;/a&gt;(and don't forget the &lt;a href="https://docs.docker.com/engine/install/linux-postinstall/" rel="noopener noreferrer"&gt;post-installation steps&lt;/a&gt;)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once installed, let's install Appwrite image which is pasting just one line of script on your terminal!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linux/Mac
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --rm \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
    --entrypoint="install" \
    appwrite/appwrite:1.2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;CMD
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --rm ^
    --volume //var/run/docker.sock:/var/run/docker.sock ^
    --volume "%cd%"/appwrite:/usr/src/code/appwrite:rw ^
    --entrypoint="install" ^
    appwrite/appwrite:1.2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Powershell
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;docker run -it --rm `
    --volume /var/run/docker.sock:/var/run/docker.sock `
    --volume ${pwd}/appwrite:/usr/src/code/appwrite:rw `
    --entrypoint="install" `
    appwrite/appwrite:1.2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Note: This scripts are for Appwrite version 1.2.0 which we will be using for the project! For the latest versions go to &lt;a href="https://appwrite.io/" rel="noopener noreferrer"&gt;Appwrite&lt;/a&gt; and click on Get Started.&lt;br&gt;
At the end of the installation, it will prompt you to many inputs, going for the default options is my recommendation and if you did it, go to your &lt;code&gt;http://localhost:80&lt;/code&gt; and voila! you will be greeted with the beautiful Appwrite Console(made using &lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;,my favourite). Create an account and sign in.&lt;/p&gt;
&lt;h2&gt;
  
  
  Flutter Installation
&lt;/h2&gt;

&lt;p&gt;As for flutter, installing it through its &lt;a href="https://docs.flutter.dev/get-started/install" rel="noopener noreferrer"&gt;official documentation&lt;/a&gt; is the best way!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.flutter.dev/get-started/install/macos" rel="noopener noreferrer"&gt;macOS&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.flutter.dev/get-started/install/linux" rel="noopener noreferrer"&gt;Linux&lt;/a&gt; (Don't install the snap version)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://docs.flutter.dev/get-started/install/windows" rel="noopener noreferrer"&gt;Windows&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now, run &lt;code&gt;flutter doctor&lt;/code&gt; and you should see all ticks green, if not, copy the red text and paste it on stack overflow and you should get your answers&lt;/p&gt;
&lt;h2&gt;
  
  
  The app
&lt;/h2&gt;

&lt;p&gt;So, a couple of days ago, I posted an app I was building as a side project on Twitter&lt;/p&gt;

&lt;p&gt;&lt;iframe class="tweet-embed" id="tweet-1609575130832965632-74" src="https://platform.twitter.com/embed/Tweet.html?id=1609575130832965632"&gt;
&lt;/iframe&gt;

  // Detect dark theme
  var iframe = document.getElementById('tweet-1609575130832965632-74');
  if (document.body.className.includes('dark-theme')) {
    iframe.src = "https://platform.twitter.com/embed/Tweet.html?id=1609575130832965632&amp;amp;theme=dark"
  }



&lt;/p&gt;

&lt;p&gt;and realised there aren't any great Tutorials for the appwrite+flutter community. One resource worth mentioning is the &lt;a href="https://youtube.com/playlist?list=PLUiueC0kTFqI9WIeUSkKvM-a_3fyaIiuk" rel="noopener noreferrer"&gt;React Bits (Damodar Lohani) Flutter + Appwrite Tutorial Series on YouTube&lt;/a&gt; however it's based on a very old version of Appwrite which isn't compatible with the latest version. The other and best resource is the &lt;a href="https://appwrite.io/docs" rel="noopener noreferrer"&gt;Official Appwrite Docs&lt;/a&gt; which is the main source of knowledge in this blog series. To create a strong resource on integrating Appwrite perfectly with Flutter, I decided to document the entire process of developing the &lt;strong&gt;Recipe App&lt;/strong&gt;, a social media for sharing your mouthwatering recipes to the world, in this blog series and mind you, I am still building the app at the time of writing this blog so let's learn together and build in public.&lt;/p&gt;

&lt;p&gt;That's all to get you started with this blog series! In the next blog, we will talk about setting up our flutter apps, discussing the architecture and things like state management (will be Riverpod 2.0). Hope, the blog series will succeed in the prime objective of becoming the go-to resource for creating Flutter+Appwrite apps. See y'all soon in the next blog and do share it for the greater good of the community😁😁!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>help</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Flutter Riverpod - Part 2</title>
      <dc:creator>Chandram Dutta </dc:creator>
      <pubDate>Mon, 21 Mar 2022 06:19:53 +0000</pubDate>
      <link>https://forem.com/chandramdutta/flutter-riverpod-part-2-54dp</link>
      <guid>https://forem.com/chandramdutta/flutter-riverpod-part-2-54dp</guid>
      <description>&lt;p&gt;In the last &lt;a href="https://chandramcodes.hashnode.dev/hello-flutter-with-riverpod-100/"&gt;blog&lt;/a&gt;, we learned to set up Riverpod for a Flutter Project and how to use the basic of all Riverpod Provider, the &lt;code&gt;Provider()&lt;/code&gt;. In this blog we will learn to use the most useful and basic Provider, the &lt;code&gt;StateProvider()&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's dig into why do we need a Provider?
&lt;/h2&gt;

&lt;p&gt;Let's say you have an A Flutter(Riverpod) Project with the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

int counter = 0;

void main() {
  runApp(
    const ProviderScope(
      child: MyApp(),
    ),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Riverpod',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Riverpod'),
    );
  }
}

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

  final String title;

  @override
  State&amp;lt;MyHomePage&amp;gt; createState() =&amp;gt; _MyHomePageState();
}

class _MyHomePageState extends State&amp;lt;MyHomePage&amp;gt; {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &amp;lt;Widget&amp;gt;[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            const CounterCard()
          ],
        ),
      ),
    );
  }
}

class CounterCard extends StatefulWidget {
  const CounterCard({
    Key? key,
  }) : super(key: key);

  @override
  State&amp;lt;CounterCard&amp;gt; createState() =&amp;gt; _CounterCardState();
}

class _CounterCardState extends State&amp;lt;CounterCard&amp;gt; {
  void _incrementCounter() {
    setState(() {
      counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Card(
        child: ListTile(
      title: Text("$counter"),
      trailing: IconButton(
        icon: const Icon(Icons.plus_one),
        onPressed: _incrementCounter,
      ),
    ));
  }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Whats all this Provider Scope? Read my &lt;a href="https://chandramcodes.hashnode.dev/hello-flutter-with-riverpod-100"&gt;previous blog&lt;/a&gt; on setting up Riverpod for your Project!&lt;/p&gt;

&lt;p&gt;So what's going on in the code above?&lt;br&gt;
Its the similar Default Flutter Counter Application that we get when we create a new Flutter Project, but with Riverpod and some Changes to display the problem with state. &lt;br&gt;
We have a global variable &lt;code&gt;int counter&lt;/code&gt; which is initialised to Zero. Then that &lt;code&gt;counter&lt;/code&gt; is used at two places, one in the upper &lt;code&gt;MyHomePage&lt;/code&gt; Class and second in &lt;code&gt;CounterCard&lt;/code&gt; Class. In the &lt;code&gt;CounterCard&lt;/code&gt;, there's an &lt;code&gt;IconButton&lt;/code&gt; with the function &lt;code&gt;_incrementCounter()&lt;/code&gt; which increments the &lt;code&gt;counter&lt;/code&gt; variable. Now Ideally, on pressing the button, we should see the &lt;code&gt;counter&lt;/code&gt; getting incremented at both the places. But this doesn't happen. This is because the &lt;code&gt;setState()&lt;/code&gt; method only refreshes the &lt;code&gt;CounterCard&lt;/code&gt; Contents and not of &lt;code&gt;MyHomePage&lt;/code&gt;. Flutter State works in this way to improve performance, imagine the entire screen refreshing everytime for small changes and you don't own an M1 Device. To solve this problem we have State Management Solutions. Let's figure it all out using some diagrams!! Who doesn't love diagrams right?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DwC0aRw6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647773435190/x5AEi9TdI.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DwC0aRw6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647773435190/x5AEi9TdI.png" alt="Instagram post - 1.png" width="880" height="880"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cc8fjydP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647773427447/gCe0I0B-Y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cc8fjydP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1647773427447/gCe0I0B-Y.png" alt="Instagram post - 2.png" width="880" height="880"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So if you want to change the state of a base class from a derived class(which happens quite frequently), it becomes quite tedious, we are gonna solve this problem with Riverpod, more specifically with a &lt;code&gt;Provider&lt;/code&gt; that contains state or &lt;code&gt;StateProvider()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;So we have a &lt;code&gt;counter&lt;/code&gt; variable right? We are going to convert it into &lt;code&gt;Provider&lt;/code&gt; just how we learned in the &lt;a href="https://chandramcodes.hashnode.dev/hello-flutter-with-riverpod-100"&gt;previous blog&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//int counter = 0; This Changes to
final counterProvider = Provider&amp;lt;int&amp;gt;((ref) {
  return 0;
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And half the Magic is Done!!&lt;/p&gt;

&lt;p&gt;Change the &lt;code&gt;MyHomePage&lt;/code&gt; to a Stateless Widget...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &amp;lt;Widget&amp;gt;[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$counter',
              style: Theme.of(context).textTheme.headline4,
            ),
            const CounterCard()
          ],
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Again cahnge the &lt;code&gt;MyHomePage&lt;/code&gt; to a &lt;code&gt;ConsumerWidget&lt;/code&gt; just like we learned in the &lt;a href="https://chandramcodes.hashnode.dev/hello-flutter-with-riverpod-100"&gt;previous blog&lt;/a&gt; and let the &lt;code&gt;Text&lt;/code&gt; Widget watch the &lt;code&gt;counterProvider()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
class MyHomePage extends ConsumerWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  Widget build(BuildContext context,WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: &amp;lt;Widget&amp;gt;[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              ref.watch(counterProvider).toString(),
              style: Theme.of(context).textTheme.headline4,
            ),
            const CounterCard()
          ],
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now sometimes you need to read a provider from a &lt;code&gt;StatefulWidget&lt;/code&gt;, and we do this using &lt;code&gt;ConsumerStatefulWidget&lt;/code&gt; which we will do to the &lt;code&gt;CounterCard&lt;/code&gt; StatefulWidget.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Add Consumer to StatefulWidget
class CounterCard extends ConsumerStatefulWidget {
  const CounterCard({
    Key? key,
  }) : super(key: key);

  @override
//    Changes here 
  ConsumerState&amp;lt;CounterCard&amp;gt; createState() =&amp;gt; _CounterCardState();
}
//    Changes here 
class _CounterCardState extends ConsumerState&amp;lt;CounterCard&amp;gt; {
 ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that's it!&lt;br&gt;
Now remember before I talked about a different kind of Provider and it was the &lt;code&gt;StateProvider&lt;/code&gt;, it basically is an a &lt;code&gt;Provider&lt;/code&gt; but it can maintain the State of its contents.&lt;br&gt;
Now go above and add &lt;code&gt;State&lt;/code&gt; to the &lt;code&gt;counterProvider&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//                                    Over Here
final counterProvider = StateProvider&amp;lt;int&amp;gt;((ref) {
  return 0;
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now go to &lt;code&gt;CounterCard&lt;/code&gt; and let the &lt;code&gt;Text&lt;/code&gt; watch the &lt;code&gt;counterProvider&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class _CounterCardState extends ConsumerState&amp;lt;CounterCard&amp;gt; {


  @override
  Widget build(BuildContext context) {
    return Card(
        child: ListTile(
      title: Text(ref.watch(counterProvider).toString()),
      trailing: IconButton(
        icon: const Icon(Icons.plus_one),
        onPressed: (){
          ...
        },
      ),
    ));
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now in the &lt;code&gt;onPressed&lt;/code&gt; we have to increment the "state" of &lt;code&gt;counterProvider&lt;/code&gt;.&lt;br&gt;
To do this we use &lt;code&gt;ref.read()&lt;/code&gt; instead of &lt;code&gt;ref.watch&lt;/code&gt;, so here it should be,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onPressed: () {
          setState(() {
            ref.read(counterProvider.state).state++;
          });
        },
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Note that here it will still work if you don't use a &lt;code&gt;setState&lt;/code&gt; Function.&lt;br&gt;
That's it and now run the program to solve the State Mangement Problem we faced earlier.&lt;/p&gt;

&lt;p&gt;I will be soon starting a Riverpod Series on Youtube so don't forget to subscribe my &lt;a href="https://www.youtube.com/channel/UCLmgkjCcj5t0QCZ9Ip-vpgw"&gt;Youtube Channel&lt;/a&gt; and Also follow me on &lt;a href="https://www.twitter.com/ChandramDutta"&gt;Twitter&lt;/a&gt; and &lt;a href="https://www.instagram.com/flutter.zed"&gt;Instagram&lt;/a&gt; to get the latest updates and Tips and Tricks using Flutter.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>android</category>
      <category>ios</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Hello Flutter with Riverpod 1.0.0!</title>
      <dc:creator>Chandram Dutta </dc:creator>
      <pubDate>Sun, 20 Mar 2022 10:04:42 +0000</pubDate>
      <link>https://forem.com/chandramdutta/hello-flutter-with-riverpod-100-3hm7</link>
      <guid>https://forem.com/chandramdutta/hello-flutter-with-riverpod-100-3hm7</guid>
      <description>&lt;p&gt;State Management in Flutter is an important topic not to be overlooked. Obviously, you can't just use &lt;code&gt;set state();&lt;/code&gt; throughout a project consisting of 3000 lines of code over 20 different files! There are many approaches in Flutter that you can use for managing your state and for dependency injection.&lt;/p&gt;

&lt;p&gt;Some of the Darttastical State Management Approaches are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;BLoC&lt;/li&gt;
&lt;li&gt;Riverpod&lt;/li&gt;
&lt;li&gt;GetX
And many more...&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;em&gt;Note: I am not including Provider as Riverpod is a better version of Provider itself.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  So Now let's understand &lt;a href="https://riverpod.dev"&gt;Riverpod.&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;As I mentioned before, Riverpod is an improved version of Providers and hence, Providers play an important role in Riverpod. &lt;br&gt;
What are Providers tho...&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final thisIsProvider = Provider((ref) {
  return MyValue();
}); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;final thisIsProvider&lt;/code&gt; is the declaration of the variable. The &lt;code&gt;Provider();&lt;/code&gt; comes from Riverpod Class. &lt;code&gt;MyValue()&lt;/code&gt; refers to object that our Provider is returning. It could be a &lt;code&gt;string&lt;/code&gt;, &lt;code&gt;int&lt;/code&gt;, or any other data type. &lt;/p&gt;

&lt;p&gt;To understand more vividly using real code examples let's learn to import riverpod.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Riverpod
&lt;/h3&gt;

&lt;p&gt;There are 3 types of riverpod&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;riverpod&lt;/code&gt; to be used only with Dart&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;flutter_riverpod&lt;/code&gt; when we use Flutter and riverpod &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;riverpod_hooks&lt;/code&gt; when we use &lt;code&gt;flutter_hooks&lt;/code&gt; in our flutter Project.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For this blog, we will use &lt;code&gt;flutter_riverpod&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In &lt;code&gt;pubspec.yaml&lt;/code&gt; Under dependencies add &lt;code&gt;flutter_riverpod&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dependencies:
  flutter_riverpod:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrap the root of your widget tree (&lt;code&gt;MyApp()&lt;/code&gt; Class) with &lt;code&gt;ProviderScope()&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() {
  runApp(
    //Right Here👇
    ProviderScope(
      child: MyApp(),
    ),
  );
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And don't forget to import riverpod in your .dart files&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter_riverpod/flutter_riverpod.dart';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Let's play with riverpod now
&lt;/h3&gt;

&lt;p&gt;Ok...so after all this, let's actually use the riverpod with a basic &lt;code&gt;Provider()&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Copy the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() {
  runApp(
//Don't forget to wrap MyApp() with ProviderScope()
    const ProviderScope(child: MyApp()),
  );
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: Home());
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Riverpod')),
      body: Center(
        child: 
          return Text('Riverpod says Hello');
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code is self-explanatory to any flutter developer with basic knowledge of flutter with changes that we discussed before while installing &lt;code&gt;riverpod&lt;/code&gt;. Now we will use riverpod's Provider to display the text in the &lt;code&gt;Text()&lt;/code&gt; in the &lt;code&gt;Center()&lt;/code&gt; of the &lt;code&gt;Scaffold()&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change &lt;code&gt;StatelessWidget()&lt;/code&gt; to &lt;code&gt;ConsumerWidget()&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Home extends ConsumerWidget {
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Pass another object named &lt;code&gt;WidgetRef ref&lt;/code&gt; in &lt;code&gt;build()&lt;/code&gt; method of &lt;code&gt;ConsumerWidget()&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Home extends ConsumerWidget {
  @override
 Widget build(BuildContext context, WidgetRef ref) {
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now let's create a &lt;code&gt;Provider()&lt;/code&gt; the most basic of all.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() {
  runApp(
//Don't forget to wrap MyApp() with ProviderScope()
    const ProviderScope(child: MyApp()),
  );
}
//Right Here😉
final helloTextProvider = Provider((ref) {
  return "Hello Riverpod";
}); 
class Home extends ConsumerWidget {
  @override
 Widget build(BuildContext context, WidgetRef ref) {
...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Let's &lt;code&gt;watch()&lt;/code&gt; our &lt;code&gt;helloTextProvider()&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Home extends ConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(title: const Text('Riverpod')),
      body: Center(
        child: 
//Over here Brother and Sisters😊,
          return Text(ref.watch(helloTextProvider()));
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  The Final Code
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

void main() {
  runApp(
//Don't forget to wrap MyApp() with ProviderScope()
    const ProviderScope(child: MyApp()),
  );
}

//Right Here😉
final helloTextProvider = Provider((ref) {
  return "Hello Riverpod";
}); 

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(home: Home());
  }
}

class Home extends ConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return Scaffold(
      appBar: AppBar(title: const Text('Riverpod')),
      body: Center(
        child: 
          //Over here Brother and Sisters😊,
          return Text(ref.watch(helloTextProvider()));
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And Congrats🎉🎉, you made your first Riverpod App(if it runs successfullly🤭😉) . &lt;/p&gt;

&lt;p&gt;In my next blog, we will learn to use &lt;code&gt;StateProvider()&lt;/code&gt; where you will actually get to know the advantages of &lt;code&gt;flutter_riverpod&lt;/code&gt;. &lt;br&gt;
Till that &lt;code&gt;Oh Boy!&lt;/code&gt; you all need to wait! &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://chandramcodes.hashnode.dev/hello-flutter-with-riverpod-100"&gt;Hashnode&lt;/a&gt; on 29th December 2020&lt;/em&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>riverpod</category>
      <category>android</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
