<?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: Denyse</title>
    <description>The latest articles on DEV Community by Denyse (@dmutoni).</description>
    <link>https://dev.to/dmutoni</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%2F576269%2F40b2d464-4f8a-4652-bb78-890fcbba409d.jpg</url>
      <title>DEV Community: Denyse</title>
      <link>https://dev.to/dmutoni</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dmutoni"/>
    <language>en</language>
    <item>
      <title>Exploring Python Objects: A Dive into Identity, Types, and Mutability</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Fri, 15 Mar 2024 20:45:16 +0000</pubDate>
      <link>https://dev.to/dmutoni/exploring-python-objects-a-dive-into-identity-types-and-mutability-14he</link>
      <guid>https://dev.to/dmutoni/exploring-python-objects-a-dive-into-identity-types-and-mutability-14he</guid>
      <description>&lt;p&gt;Sup reader!!,&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Python, a dynamic and robust programming language, it opens the door to the captivating realm of objects. In this article, we are going to explore the fundamental concepts of identity, types, and mutability within Python's object-oriented paradigm. Mastery of these principles is essential for crafting optimized and error-free code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqugy7srisk44bgz1o6b8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqugy7srisk44bgz1o6b8.png" alt="Let's get started" width="480" height="270"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What's id in Python?
&lt;/h2&gt;

&lt;p&gt;In Python, the built-in function id() is a function that retrieves the unique integer representing an object's memory location. Every object in Python has a distinct identity, even if they share the same value.&lt;/p&gt;

&lt;h2&gt;
  
  
  What's type in Python?
&lt;/h2&gt;

&lt;p&gt;In Python, the type() function is a function that reveals an object's class or type, aiding informed decisions on manipulation or interaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mutable vs. Immutable Objects
&lt;/h2&gt;

&lt;p&gt;In Python, mutable objects are those whose state or content can be changed after they are created whereas immutable objects are those objects that are essentially read-only any attempt to modify their content results in the creation of a &lt;br&gt;
new object.&lt;/p&gt;

&lt;p&gt;Here are the examples of mutable and immutable objects:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mutable Objects:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Byte array&lt;/li&gt;
&lt;li&gt;Dictionary&lt;/li&gt;
&lt;li&gt;Set&lt;/li&gt;
&lt;li&gt;List&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Immutable Objects:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numbers (int, float, complex)&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;li&gt;Tuple&lt;/li&gt;
&lt;li&gt;Bytes&lt;/li&gt;
&lt;li&gt;Frozen Set&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Understanding mutability is vital, as it impacts how objects behave during assignments and referencing.&lt;/p&gt;
&lt;h2&gt;
  
  
  Variable Assignment vs. Referencing in Python:
&lt;/h2&gt;

&lt;p&gt;Assigning a value to a variable establishes a reference to the object. In Python, variables are names bound to objects, making it vital to distinguish between assignment and referencing to prevent unforeseen outcomes in your code.&lt;/p&gt;
&lt;h2&gt;
  
  
  Memory Storage of Immutable Objects:
&lt;/h2&gt;

&lt;p&gt;Immutable objects, once initialized, remain unchangeable. A new object with the updated value is created if modifications are attempted. This approach preserves the integrity of the original object's value.&lt;/p&gt;
&lt;h2&gt;
  
  
  Examples with Memory Schema
&lt;/h2&gt;

&lt;p&gt;Let's explore examples to understand the concepts we discussed earlier clearly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 1: Immutable Object&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name = "Alice"

name[0] = "B"  # Throws an error as strings are immutable.

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

&lt;/div&gt;



&lt;p&gt;In this example, trying to modify the first character of the string name results in an error, highlighting the immutability of strings.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example 2: Mutable Object
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;colors = ["red", "green", "blue"]

colors[0] = "yellow"

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

&lt;/div&gt;



&lt;p&gt;Here, the first element of the list colors is successfully changed to "yellow", highlighting the mutability of lists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Variable Value Management in Function Calls
&lt;/h2&gt;

&lt;p&gt;When passing a variable to a function in Python, the mechanism used is known as &lt;strong&gt;"pass by assignment."&lt;/strong&gt; This implies that the function receives a reference to the object, rather than a copy. It's essential to learn this mechanism for anticipating your function's behavior.&lt;/p&gt;

&lt;p&gt;If you've read this far, &lt;/p&gt;

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

</description>
    </item>
    <item>
      <title>Streams in dart</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Sat, 02 Jul 2022 13:09:27 +0000</pubDate>
      <link>https://dev.to/dmutoni/streams-in-dart-5gd0</link>
      <guid>https://dev.to/dmutoni/streams-in-dart-5gd0</guid>
      <description>&lt;p&gt;Sup folks, hope you are doing great 🤗, we are going to pass through many in one flutter concept 😂 concept called a stream. &lt;/p&gt;

&lt;p&gt;Let's start with a simple case study.&lt;br&gt;
Imagine yourself sitting by a creek, having a wonderful time. While watching the water flow, you see a piece of wood or a leaf floating down the stream and you decide to take it out of the water 😂 Funny right? You could even have someone upstream purposely float things down the creek for you to grab.&lt;/p&gt;

&lt;p&gt;So we can imagine Dart in a similar way: as data flowing down a creek, waiting for someone to grab it. A stream can be like a pipe, you put a value on the one end and if there’s a listener on the other end that listener will receive that value. A Stream can have multiple listeners and all of those listeners will receive the same value when it’s put in the pipeline. The way you put values on a stream is by using a StreamController.&lt;/p&gt;
&lt;h2&gt;
  
  
  What are streams in dart?
&lt;/h2&gt;

&lt;p&gt;A stream is a source of asynchronous data events. They provide a way to receive a sequence of events.&lt;/p&gt;
&lt;h2&gt;
  
  
  What can you do with a stream ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;With Dart streams, you can send one data event at a time while other parts of your app listen for those events. Such events can be collections, maps or any other type of data you’ve created.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Streams can send errors in addition to data thus you can also stop the stream, if you need to.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Important concepts of Streams in flutter
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Stream Controller :&lt;/strong&gt; A StreamController simplifies stream management, automatically creating a &lt;code&gt;stream&lt;/code&gt; and &lt;code&gt;sink&lt;/code&gt;, and providing methods for controlling a stream’s behavior. A StreamController object in Dart does exactly what the name suggests, it controls Dart Streams. The object is used to create streams and send data, errors, and done events on them. Controllers also help check a stream’s properties, such as how many subscribers it has or if it’s paused.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Stream Builders :&lt;/strong&gt; StreamBuilder is a widget that uses stream operations and basically, it rebuilds its UI when it gets the new values that are passed via Stream it listens to.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;StreamBuilder requires 2 parameters:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;stream&lt;/strong&gt;: A method that returns a stream object&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;builder&lt;/strong&gt;: widgets that will be returned during different states of a streambuilder.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Sink&lt;/strong&gt;: In Flutter Streams, a Sink is a point from where we can add data into the stream pipe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Source&lt;/strong&gt;: In Flutter Stream, a Source is a point from where we can keep listening to stream data or get the data that is been added into the stream.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to create streams in flutter?
&lt;/h2&gt;

&lt;p&gt;Let's first have a look at generators.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generators&lt;/strong&gt; can create sequence of values synchronously (by this we can create Iterable) and asynchronously (by this we can create Stream).&lt;br&gt;
So, you can produce a stream by calling an &lt;code&gt;async*&lt;/code&gt; function, which then returns a stream. Consuming that stream will lead the function to emit events until it ends, and the stream closes. You consume a stream either using an &lt;code&gt;await&lt;/code&gt; &lt;code&gt;for loop&lt;/code&gt;, which is available inside an &lt;code&gt;async&lt;/code&gt; or &lt;code&gt;async*&lt;/code&gt; function, or by forwarding its events directly using &lt;code&gt;yield*&lt;/code&gt; inside an &lt;code&gt;async*&lt;/code&gt; function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Future&amp;lt;double&amp;gt; getRandomValue() async {
  var random = Random(2);
  await Future.delayed(Duration(seconds: 1));
  return random.nextDouble();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code can be used and you’ll get a random value back once off and the function will be finished executing. This means if you want another random value you’ll have to call and await the function again. Like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var value1 = await getRandomValue();
var value2 = await getRandomValue();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And this is so tiresome right?&lt;/p&gt;

&lt;p&gt;So if you want to call the function once and continuously get random values from that function without stopping it’s execution? That’s where &lt;code&gt;async*&lt;/code&gt; and &lt;code&gt;yield&lt;/code&gt; comes in. Hmm, interesting then lets make a function that returns a stream and every second will emit a new random value.&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;double&amp;gt; getRandomValues() async* {
    var random = Random(2);
    while (true) {
      await Future.delayed(Duration(seconds: 1));
      yield random.nextDouble();
    }
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Well if you are confused about the difference between the previous function and this one don't worry, let's clearly look at the differences: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The first thing to notice is that we now return a &lt;code&gt;Stream&lt;/code&gt;and not a &lt;code&gt;Future&lt;/code&gt;. That means instead of awaiting on the value we’ll have to subscribe to the stream.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The second difference is that &lt;code&gt;async*&lt;/code&gt; instead of &lt;code&gt;async&lt;/code&gt;. This tells the runtime that this code should be run asynchronously but execution will continue even after "returning" a value.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The last difference is the replacement of return with yield. This is basically a return function but it doesn't exit the function. Instead it continues executing the rest of the code after yield.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Welp, that was one way of creating streams 🤗 Tadaaa !!!!&lt;/p&gt;

&lt;p&gt;Usually when you are creating streams, you use &lt;code&gt;StreamController&lt;/code&gt; which holds both &lt;code&gt;stream&lt;/code&gt; and &lt;code&gt;StreamSink&lt;/code&gt; like below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final streamController = StreamController&amp;lt;DateTime&amp;gt;();
    Timer.periodic(Duration(seconds: 2), (timer) {
      streamController.add(DateTime.now());
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before we continue notice that we emitted a new value over a stream using &lt;code&gt;add&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How to use streams?
&lt;/h2&gt;

&lt;p&gt;The next thing to do is to be able to get the values from a stream. This is commonly referred to as subscribing or listening to a stream. When you subscribe to a stream you will only get the values that are emitted (put onto the stream) after the subscription. You subscribe to the stream by calling the listen function and supplying it with a Function to call back to when there's a new value available, commonly referred to as a callback function, or just a callback.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;streamController.stream.listen((event) {
      print(event);
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.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%2Fyl3xnmbw3md05ob54ilz.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fyl3xnmbw3md05ob54ilz.PNG" alt="Date"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Managing a stream
&lt;/h2&gt;

&lt;p&gt;The listen call returns a &lt;code&gt;StreamSubscription&lt;/code&gt; of the type of your stream. We can use this to manage stream subscription. Notice that we have our subscription to the stream and it’s emitting over time. That’s great. But we’ve got a small bug with this implementation: we never disposed or cleaned up our subscription to the stream. And this means that even if the user goes to another part of our app or does something else, our app will still listen to this stream and process the results.&lt;br&gt;
Basically we need to make sure there are no memory leaks. A subscription to a stream will stay active until its memory allocation is destroyed, usually the entire lifecycle of your app. This is perfectly fine in some cases and not fine in others. Let's look together how to cancel to a stream subscription.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  final streamController = StreamController&amp;lt;DateTime&amp;gt;();
    final unsubscribeAt = DateTime.now().add(Duration(seconds: 10));
    StreamSubscription&amp;lt;DateTime&amp;gt;? subscription;

    Timer.periodic(Duration(seconds: 2), (timer) {
      streamController.add(DateTime.now());
    });

    subscription = streamController.stream.listen((event) async {
      print(event);
      if (event.isAfter(unsubscribeAt)) {
        print("It's after ${unsubscribeAt}, cleaning up the stream");
        await subscription?.cancel();
      }
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Handling stream errors.
&lt;/h2&gt;

&lt;p&gt;As we know 😂 when we are programming we often meet errors. So we are going to see how we can manage errors in our streams.&lt;/p&gt;

&lt;p&gt;The reasons for these can be vast, but if your stream is connected for real-time updates from a server and the mobile device disconnects from the internet, then the stream disconnects as well and yields an error.&lt;/p&gt;

&lt;p&gt;When this happens and we don’t handle the error, Flutter will throw an exception and the app can potentially be left in an unusable state.&lt;/p&gt;

&lt;p&gt;Fortunately, it’s fairly easy to handle errors. Let’s make our stream yield an error if our seconds are divisible by three, and, for the sake of completeness, let’s also handle the event when the stream completes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;final streamController = StreamController&amp;lt;DateTime&amp;gt;();
    final unsubscribeAt = DateTime.now().add(Duration(seconds: 10));
    late StreamSubscription&amp;lt;DateTime&amp;gt; subscription;

    final timer = Timer.periodic(Duration(seconds: 2), (timer) {
      streamController.add(DateTime.now());
      if (DateTime.now().second % 3 == 0) {
        streamController.addError(() =&amp;gt; Exception('Seconds are divisible by three.'));
      }
    });

    subscription = streamController.stream.listen((event) async {
      print(event);
      if (event.isAfter(unsubscribeAt)) {
        print("It's after ${unsubscribeAt}, cleaning up the stream");
        timer.cancel();
        await streamController.close();
        await subscription.cancel();
      }
    }, onError: (err, stack) {
      print('the stream had an error :(');
    }, onDone: () {
      print('the stream is done :)');
    });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output will be &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fuw44uzqq7d5zqjk1w6iu.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fuw44uzqq7d5zqjk1w6iu.PNG" alt="Stream error"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus 🎉
&lt;/h2&gt;

&lt;h2&gt;
  
  
  What are the types of streams in dart?
&lt;/h2&gt;

&lt;p&gt;There are two kinds of streams: "Single-subscription" streams and "broadcast" streams.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F9t6uvp84uwmaec7pvux7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F9t6uvp84uwmaec7pvux7.png" alt="Types of streams"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A single-subscription&lt;/strong&gt; stream allows only a single listener during the whole lifetime of the stream. It doesn't start generating events until it has a listener, and it stops sending events when the listener is unsubscribed, even if the source of events could still provide more. The stream created by an async* function is a single-subscription stream, but each call to the function creates a new such stream.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Listening twice on a single-subscription stream is not allowed, even after the first subscription has been canceled.&lt;/p&gt;

&lt;p&gt;Single-subscription streams are generally used for streaming chunks of larger contiguous data, like file I/O&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;A broadcast stream&lt;/strong&gt; allows any number of listeners, and it fires its events when they are ready, whether there are listeners or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Broadcast streams are used for independent events/observers.&lt;/p&gt;

&lt;p&gt;If several listeners want to listen to a single-subscription stream, use &lt;strong&gt;asBroadcastStream&lt;/strong&gt; to create a broadcast stream on top of the non-broadcast stream.&lt;/p&gt;

&lt;p&gt;Hoorraaay 😝 congrants you've read to this far. This was a lot. But hope you understand what a stream is, let's have a short recap about what we have covered. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How a basic stream works and what purpose they serve&lt;/li&gt;
&lt;li&gt;How to clean up a subscription after we’ve used it&lt;/li&gt;
&lt;li&gt;How to handle basic errors that come from the stream and capture them when a stream completes&lt;/li&gt;
&lt;li&gt;Types of streams&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So your task now is examine yourself and see how you can implement this in a flutter app 🔥 just give it a try.&lt;br&gt;
Goodluck 🎉🎉&lt;/p&gt;

</description>
      <category>dart</category>
      <category>flutter</category>
      <category>programming</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Flutter state management 🔥</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Fri, 24 Jun 2022 08:03:09 +0000</pubDate>
      <link>https://dev.to/dmutoni/flutter-state-management-32n7</link>
      <guid>https://dev.to/dmutoni/flutter-state-management-32n7</guid>
      <description>&lt;p&gt;Sup reader!! How have you been? we going to go through different state management approaches in flutter, for sure they are a lot of state managements in flutter. We are just going through some of them. 😚 .... Tadaaaa !!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fdeoxqbvn1hza54qwca5m.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fdeoxqbvn1hza54qwca5m.gif" alt="Get started"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is state management?
&lt;/h2&gt;

&lt;p&gt;State management refers to the management of the state of one or more user interface controls such as text fields, OK buttons, animations, etc. in a graphical user interface. In this user interface programming technique, the state of one UI control depends on the state of other UI controls.&lt;/p&gt;

&lt;p&gt;State management is a complex topic. If you feel that some of your questions haven’t been answered, or that the approach described in this blog is not viable for your use cases, you are probably right 😂.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why do you need state management?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think of an app that has two separate screens: a catalog, and a cart (represented by the MyCatalog, and MyCart widgets, respectively). It could be a shopping app, but you can imagine the same structure in a simple social networking app (replace catalog for “wall” and cart for “favorites”). You need to keep track of items that a user added to cart or favorites, the total price in cart and many other things ... So to keep track of all these events you got to manage your state using one of the state management approach.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fpgktokc185nav1kcrufn.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fpgktokc185nav1kcrufn.gif" alt="River pod"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you’re coming to Flutter from an imperative framework (such as Android SDK or iOS UIKit), you need to start thinking about app development from a new perspective.&lt;/p&gt;

&lt;p&gt;Many assumptions that you might have don’t apply to Flutter. For example, in Flutter it’s okay to rebuild parts of your UI from scratch instead of modifying it. Flutter is fast enough to do that, even on every frame if needed.&lt;/p&gt;

&lt;p&gt;Flutter is declarative. This means that Flutter builds its user interface to reflect the current state of your app:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fccs5ju1tdu5vzyc2pecw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fccs5ju1tdu5vzyc2pecw.png" alt="UI state"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the state of your app changes (for example, the user flips a switch in the settings screen), you change the state, and that triggers a redraw of the user interface. There is no imperative changing of the UI itself (like widget.setText)—you change the state, and the UI rebuilds from scratch.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what are different state management approaches in Flutter ?
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Bloc&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A predictable state management library that helps implement the BLoC (Business Logic Component) design pattern.&lt;br&gt;
This design pattern helps to separate presentation from business logic. Following the BLoC pattern facilitates testability and reusability. This package abstracts reactive aspects of the pattern allowing developers to focus on writing the business logic. Bloc makes it easy to separate presentation from business logic, making your code fast, easy to test, and reusable.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Bloc was designed with three core values in mind:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Simple&lt;/strong&gt;: Easy to understand &amp;amp; can be used by developers with varying skill levels.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Powerful&lt;/strong&gt;: Help make amazing, complex applications by composing them of smaller components.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Testable&lt;/strong&gt;: Easily test every aspect of an application so that we can iterate with confidence.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can use Bloc in flutter via &lt;a href="https://pub.dev/packages/flutter_bloc" rel="noopener noreferrer"&gt;flutter_bloc&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Getx&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A simplified reactive state management solution. It combines high-performance state management, intelligent dependency injection, and route management quickly and practically.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Three basic principles on which it is built:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Performance&lt;/strong&gt;: focused on minimum consumption of memory and resources&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Productivity&lt;/strong&gt;: intuitive and efficient tool combined with simplicity and straightforward syntax that ultimately saves development time&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Organization&lt;/strong&gt;: decoupling business logic from view and presentation logic cannot get better than this. You do not need context to navigate between routes, nor do you need stateful widgets&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can use Getx in flutter via &lt;a href="https://pub.dev/packages/get" rel="noopener noreferrer"&gt;Getx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Redux&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Redux is a unidirectional data flow architecture that helps a developer to develop and maintain an App easily. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Here are 4 components that redux generally contains:&lt;/em&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Action: When an event is generated then it is represented as an action and is dispatched to the Reducer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Reducer&lt;/strong&gt;: When Reducer gets any update, it updates the store with a new state what it receives.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Store&lt;/strong&gt;: When Store receives any update it notifies to the view.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;View&lt;/strong&gt;: It is recreated to show the changes which have been made.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;How to use Redux in flutter?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Before using Redux, you should know that flutter SDK does not have support for Redux but by using the &lt;a href="https://pub.dev/packages/flutter_redux" rel="noopener noreferrer"&gt;flutter_redux&lt;/a&gt; plugin, it can be implemented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Provider&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Provider was created by Remi Rousselet, aims to handle the state as cleanly as possible. In Provider, widgets listen to changes in the state and update as soon as they are notified.&lt;/p&gt;

&lt;p&gt;You can use Provider via &lt;a href="https://pub.dev/packages/provider" rel="noopener noreferrer"&gt;provider&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Riverpod&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A Reactive Caching and Data-binding Framework. Riverpod is a popular Flutter state management library that shares many of the advantages of Provider and brings many additional benefits. According to the official documentation: Riverpod is a complete rewrite of the Provider package to make improvements that would be otherwise impossible.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Riverpod also has 3 basic principles:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;easily create, access, and combine providers with minimal boilerplate code&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;write testable code and keep your logic outside the widget tree&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;catch programming errors at compile-time rather than at runtime&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can use riverpod via &lt;a href="https://pub.dev/packages/riverpod" rel="noopener noreferrer"&gt;riverpod&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. MobX&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;MobX is a battle tested library that makes state management simple and scalable by transparently applying functional reactive programming (TFRP). &lt;/p&gt;

&lt;p&gt;&lt;em&gt;The philosophy behind MobX is simple:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Straightforward&lt;/strong&gt;: Write minimalistic, boilerplate free code that captures your intent. Trying to update a record field? Use the good old JavaScript assignment. Updating data in an asynchronous process? No special tools are required, the reactivity system will detect all your changes and propagate them out to where they are being used.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Effortless optimal rendering&lt;/strong&gt;: All changes to and uses of your data are tracked at runtime, building a dependency tree that captures all relations between state and output. This guarantees that computations depending on your state, like React components, run only when strictly needed. There is no need to manually optimize components with error-prone and sub-optimal techniques like memoization and selectors.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Architectural freedom&lt;/strong&gt;: MobX is unopinionated and allows you to manage your application state outside of any UI framework. This makes your code decoupled, portable, and above all, easily testable&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What's my preferred state management and why? 🤔
&lt;/h2&gt;

&lt;p&gt;My preferred state management is &lt;strong&gt;bloc&lt;/strong&gt;🔥 why ?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fw34pra9pjfepsvgt0lai.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fw34pra9pjfepsvgt0lai.png" alt="Bloc"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Bloc is great for modularity and has an amazing documentation. Also Bloc has a bunch of extensions like bloc_concurrency, hydrated_bloc etc. That make things like caching, denouncing, throttling easy, in addition to that, error handling in bloc is amazing, you can use BlocObserver to capture changes, events or errors you can then plug Crashlytics or Sentry only in your observer and you’re good to go with logging.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;I have been also using bloc in a team of many people but it was interesting how all of us seamlessly worked within a single code base following the same patterns and conventions. 🤗&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Overall, Bloc attempts to make state changes predictable by regulating when a state change can occur and enforcing a single way to change state throughout an entire application.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are some but you can find more on the &lt;a href="https://docs.flutter.dev/development/data-and-backend/state-mgmt/options" rel="noopener noreferrer"&gt;Flutter&lt;/a&gt;. There are many state management solutions and deciding which one to use can be a daunting task. There is no one perfect state management solution! What's important is that you pick the one that works best for your team and your project.&lt;/p&gt;

&lt;p&gt;Tadaaa!!!!&lt;/p&gt;

</description>
      <category>mobile</category>
      <category>flutter</category>
      <category>dart</category>
    </item>
    <item>
      <title>Dive deep in flutter widgets 💥</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Fri, 10 Jun 2022 07:55:19 +0000</pubDate>
      <link>https://dev.to/dmutoni/dive-deep-in-flutter-widgets-1b4</link>
      <guid>https://dev.to/dmutoni/dive-deep-in-flutter-widgets-1b4</guid>
      <description>&lt;p&gt;Sup reader!, this is the second chapter in the series of flutter assuming that you have already setup your flutter editor now let's go...&lt;/p&gt;

&lt;p&gt;If you haven't read the previous blog about introduction to flutter I strongly recommend to read it before reading this one. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fib9gislopifuwu570ae4.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fib9gislopifuwu570ae4.gif" alt="GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Flutter is Google’s UI toolkit for crafting beautiful, natively compiled iOS and Android apps from a single code base. To build any application we start with widgets – The building block of flutter applications. Widgets describe what their view should look like given their current configuration and state. It includes a text widget, row widget, column widget, container widget, and many more. &lt;/p&gt;

&lt;h2&gt;
  
  
  What's a widget in flutter 🤔?
&lt;/h2&gt;

&lt;p&gt;Widgets are the central class hierarchy in the Flutter framework. A widget is an immutable description of part of a user interface. Widgets can be inflated into elements, which manage the underlying render tree. Widgets themselves have no mutable state (all their fields must be final).&lt;/p&gt;

&lt;h2&gt;
  
  
  hunnnn, What are the types of widgets in flutter?
&lt;/h2&gt;

&lt;p&gt;There are broadly two types of widgets in the flutter: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Stateless widgets is a widget that describes part of the user interface by building a constellation of other widgets that describe the user interface more concretely.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Stateful widgets are sensitive to what happens within its boundaries and gets rebuilt when a state change is detected. Conversely, Stateless widgets are not state sensitive and remain static throughout its life cycle.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;okay, now you know you what a widget is, so what's next?&lt;/p&gt;

&lt;h2&gt;
  
  
  How do we write widgets in flutter ?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Write a stateless widget&lt;/strong&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 School extends StatelessWidget {
  const School({ Key key }) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
          color: const Color(0xFF2DBD3A), 
          child: Text("My school is Rwanda Coding Academy")
    );
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will render a simple screen with a text &lt;code&gt;My school is Rwanda Coding Academy&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Well that was short and simple right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Write a stateful widget&lt;/strong&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 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; {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Test'),
      ),
      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,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), 
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let's see magic happening 😂&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fcxe5zjhs2ohekxwv6z65.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fcxe5zjhs2ohekxwv6z65.gif" alt="Flutter counter app"&gt;&lt;/a&gt;&lt;br&gt;
As you can see from the above image, whenever we click the button at bottom the number of times that we have clicked increases by one.&lt;/p&gt;

&lt;p&gt;wooh, in a stateful widget you got to write a bit more lines than in stateless widgets. In a stateful widget you've got to add some more components. Well, a stateful widget is a bit complicated compared to stateless widget.&lt;/p&gt;

&lt;p&gt;Let's talk more about a statefull widget.&lt;/p&gt;

&lt;p&gt;First of all being a stateful widget that means that it has a mutable state. The state is information that can be read synchronously when the widget is built and might change during a widget’s lifetime. It is the responsibility of the widget implementer to ensure that the State is promptly notified when such state changes, using the &lt;code&gt;State.setState&lt;/code&gt; method.&lt;/p&gt;

&lt;p&gt;Here are some few concepts that you'll need to know about a stateful widget. &lt;/p&gt;

&lt;h2&gt;
  
  
  The concept of a state
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;The data used by the widget might change&lt;/li&gt;
&lt;li&gt;The data can't be read synchronously when the widget is built. (All state must be established by the time the build method is called).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Take a close look on our stateful widget, probably you have recognized that &lt;code&gt;MyHomePage&lt;/code&gt;class is separate from &lt;code&gt;_MyHomePageState&lt;/code&gt;😕 Why is that so? &lt;/p&gt;

&lt;p&gt;The simple answer is that it's because of perfomance 🤗. How ? &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Widgets are immutable. Since StatefulWidget extends Widget it therefore must be immutable too. Splitting the declaration into two classes allows both StatefulWidget to be immutable and State to be mutable.&lt;/li&gt;
&lt;li&gt;Widgets are instantiated using the syntax &lt;code&gt;new MyWidget()&lt;/code&gt;. If we merged both classes into one, &lt;code&gt;new MyWidget()&lt;/code&gt; would reset all the properties of the state every time its parent update.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As for the further explanation of &lt;code&gt;class _MyStatefulState extends State&amp;lt;MyStateful&amp;gt;&lt;/code&gt;&lt;br&gt;
That is because the State class can access to it's Stateful part using the this.widget field. The generic is here to make that field of type MyStateful instead of just StatefulWidget. As you may want to access MyStateful properties.&lt;br&gt;
Woww, clear now 🤗.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lifecycle of a stateful widget
&lt;/h2&gt;

&lt;p&gt;Hey, take a note on this !!!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. createState()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When Flutter is instructed to build a StatefulWidget, it immediately calls createState(). This method must exist. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. mounted is true&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When createState creates your state class, a buildContext is assigned to that state. &lt;code&gt;buildContext&lt;/code&gt;is, overly simplified, the place in the widget tree in which this widget is placed. All widgets have a bool &lt;code&gt;this.mounted&lt;/code&gt; property. It is turned true when the buildContext is assigned. It is an error to call setState when a widget is unmounted.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. initState()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is the first method called when the widget is created (after the class constructor, of course.) initState is called once and only once. It must call &lt;code&gt;super.initState()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. didChangeDependencies()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method is called immediately after &lt;code&gt;initState&lt;/code&gt; on the first time the widget is built.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. build()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method is called often. It is required, and it must return a Widget 🤗.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. didUpdateWidget(Widget oldWidget)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the parent widget changes and has to rebuild this widget (because it needs to give it different data), but it's being rebuilt with the same &lt;code&gt;runtimeType&lt;/code&gt;, then this method is called. This is because Flutter is re-using the state, which is long lived. In this case, you may want to initialize some data again, as you would in &lt;code&gt;initState&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. setState()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This method is called often from the framework itself and from the developer. Its used to notify the framework that data has changed&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. deactivate()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Deactivate is called when State is removed from the tree, but it might be reinserted before the current frame change is finished. This method exists basically because State objects can be moved from one point in a tree to another.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;9. dispose()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;dispose() is called when the State object is removed, which is permanent. This method is where you should unsubscribe and cancel all animations, streams, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. mounted is false()&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The state object can never remount, and error will be thrown if setState is called.&lt;/p&gt;

&lt;p&gt;Woww, wowww thanks for reading to this far 🔥 from now you can go ahead and start playing with flutter changes 😂 try writing as many as you can. &lt;br&gt;
for more widgets please head to &lt;a href="//flutter.dev"&gt;Flutter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Get started with flutter 🔥</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Sat, 28 May 2022 08:30:13 +0000</pubDate>
      <link>https://dev.to/dmutoni/get-started-with-flutter-3k4</link>
      <guid>https://dev.to/dmutoni/get-started-with-flutter-3k4</guid>
      <description>&lt;p&gt;Sup !!!!, It's been a couple of days when making a dart tour, I strongly recommend to watch the previous serie before starting with this one. We are going to tackle on the key points in flutter thus give a short overview. I am now exciting to start getting our hands dirty with flutter 😊 Let's make this tour together.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fqx6n7pat236ijdl7gxm1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fqx6n7pat236ijdl7gxm1.gif" alt="GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is flutter 🤔?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Flutter is an open source framework by Google and released around May 2017 it is for building beautiful, natively compiled, multi-platform applications from a single codebase.&lt;br&gt;
This means that you can use one programming language and one codebase to create two different apps (mobile, web, desktop, and embedded devices).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So regarding to previous series, flutter is a framework of Dart and since Dart is exciting that means that flutter is interesting and easy to learn too 😝 woww this sounds interesting right?&lt;/p&gt;

&lt;h2&gt;
  
  
  What are the two main parts of flutter ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;An SDK (Software Development Kit)&lt;/strong&gt;: A collection of tools that are going to help you develop your applications. This includes tools to compile your code into native machine code (code for iOS and Android)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;A Framework (UI Library based on widgets)&lt;/strong&gt;: A collection of reusable UI elements (buttons, text inputs, sliders, and so on) that you can personalize for your own needs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;moving forward ...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F6fkfc7s2wue7gq3fmdvs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F6fkfc7s2wue7gq3fmdvs.png" alt="core concepts"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why should you learn and use flutter?
&lt;/h2&gt;

&lt;p&gt;I am going to select this from my own experience 😉&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter is simple and easy to use:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Flutter is a modern framework, and you can feel it since I've first used React native and Java it was kinda tiresome but then when I shifted to flutter booommmm 💥 things were different I didn't feel the sweetness of mobile development before using flutter 😂 . One thing that I liked is that you can build native apps without a bunch of codes.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter is fast:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Being fast I mean compared to other cross-platform development applications like React Native that require bridges between their code and native elements, Flutter eliminates additional processing steps that decrease performance making it noticeably faster. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter is productive:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But how does Flutter support productivity 🤔? Mainly by build-in features that go with Flutter: Widgets, Animations and Hot reload. Hot reload allows developers to see in real-time all changes they have made to an application. In that way, all concerns that arise can be efficiently managed. Significant modifications force you to reload the app. But if you do work like design, for example, and change the size of an element, it’s in real-time!! My best part 😂&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter is flexible:&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Flexible is a built-in widget in flutter which controls how a child of base flex widgets that are Row, Column, and Flex will fill the space available to it. The Expanded widget in flutter is shorthand of Flexible with the default fit of FlexFit.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Flutter has got good documentation: &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To be honest, I learnt flutter through their documentation, everything is very detailed with easy examples for basic use cases. Each time I’ve had a problem with one of my widgets in my code, I have been able to check the documentation and the answer was there&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter is ideal for startup MVPs:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to develop your app quickly please use flutter since it is cheaper thus you don't need to develop different apps for different devices hence with flutter you will build one beatiful app for all 😊.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Flutter has got a growing community 😎 and furthermore it is supported by Vs Code 😂 our very own best Code editor.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What are the flutter principles ?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Everything is a widget&lt;/strong&gt;!!! so because of this principle when you hear flutter, all you hear is that every one is talking about widget, so what is a widget ?&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;Widgets are the central class hierarchy in the Flutter framework. A widget is an &lt;strong&gt;immutable description&lt;/strong&gt; of part of a user interface. Widgets can be inflated into elements, which manage the underlying render tree. Widgets themselves have no mutable state (all their fields must be final).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Composition inheritance&lt;/strong&gt; Inheritance is the capacity of a class to inherit properties and strategies from a superclass and the's superclass, etc. It is exemplified in Dart by the &lt;a class="mentioned-user" href="https://dev.to/override"&gt;@override&lt;/a&gt; metatag. With it, a subclass's execution of inherited conduct can be particular to be proper to its more explicit subtype.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Widget tree&lt;/strong&gt; The widget tree is how you create your UI; you position widgets within each other to build simple and complex layouts. Since just about everything in the Flutter framework is a widget, and as you start nesting them, the code can become harder to follow.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Flutter architecture
&lt;/h2&gt;

&lt;p&gt;Aside from the core concepts that we have previously discussed, Flutter delivers the basic architecture that you can apply to your application and manage its state easily. The architecture that is used in Flutter is called the Business Logic Component (BLOC). Basically, it is an event-state based approach that allows you to trigger events and handle state changes based on them. The BLOC is a good approach that separates your business logic from the user interface and oversees business logic key points by testing. The core ideas that were used for BLOC architecture are simplicity, scalability, and testability, and all these goals were definitely achieved within the BLOC architecture. But this is a very huge separate topic that we will discuss at a later date.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F1xm8lssyh4rnhk9a4mhs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F1xm8lssyh4rnhk9a4mhs.png" alt="Bloc architecture"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For more information on how to install and setup flutter editor please head to: &lt;a href="https://docs.flutter.dev/get-started/install" rel="noopener noreferrer"&gt;Install and setup flutter editor&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you 🔥 for reading this far .. it was interesting right? &lt;br&gt;
Wanna dive deep into widgets 😝 stay tuned for more articles ...&lt;br&gt;
for more information about flutter please head to flutter.dev&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
    </item>
    <item>
      <title>7 Hot 🔥 features that will get you started with dart ⏭️</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Wed, 25 May 2022 05:35:42 +0000</pubDate>
      <link>https://dev.to/dmutoni/7-hot-features-that-will-get-you-started-with-dart-847</link>
      <guid>https://dev.to/dmutoni/7-hot-features-that-will-get-you-started-with-dart-847</guid>
      <description>&lt;p&gt;Hello folks, In this series, this is the 3rd chapter of what to know about dart before getting started to flutter have a look :&lt;br&gt;
Before that I strongly recommend the previous chapters to help you get a clear vision of what dart is...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2F8a9lmaax7b6tecf7093j.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F8a9lmaax7b6tecf7093j.gif" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Difference between const, final and var 🤔&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Final means single-assignment: a final variable or field must have an initializer. Once assigned a value, a final variable's value cannot be changed. final modifies variables. Final value can only be determined at run time. Thus like when using &lt;code&gt;DateTime.now()&lt;/code&gt; since the current date and time can only be&lt;br&gt;
determined at runtime, not at compile time.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Const has a meaning that's a bit more complex 😯 and subtle in Dart. const modifies values. You can use it when creating collections, like const [1, 2, 3], and when constructing objects (instead of new) like const Point(2, 3). Here, const means that the object's entire deep state can be determined entirely at compile time and that the object will be frozen and completely immutable.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then for var is completely mutable as its value can be reassigned at any point. final variables can only be assigned once, but by using objects, you can change the value of its fields. const variables are compile-time constants and are fully immutable; nothing about these variables can be changed once&lt;br&gt;
they've been assigned.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2.Why should we use immutable data types ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are two primary benefits of using immutable data types which are: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;It's faster&lt;/strong&gt;. When you declare a const value, the compiler has less work to do. It only has to allocate memory for that variable once and doesn't need to worry
about reallocating if the variable is reassigned. This may seem like an infinitesimal gain, but as your programs grow, your performance gain grows as well.&lt;/li&gt;
&lt;li&gt;Immutable data does not have side effects. One of the most common sources of bugs in programming is where value is changed in one place, and it causes an unexpected cascade of changes. If the data cannot change, then there will be no cascade. And in practice, most variables tend to only be assigned once anyway,
so why not take advantage of immutability?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. String buffer in dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The first interesting thing about strings in dart is that it's okay if you use single quotes or double quotes they both work 😝&lt;br&gt;
It's probably worth mentioning another way to perform concatenation tasks, which is using the &lt;code&gt;StringBuffer&lt;/code&gt;object. Consider 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;List fruits = ['Strawberry', 'Coconut', 'Orange', 'Mango', 'Apple'];
StringBuffer buffer = StringBuffer();
for (String fruit in fruits) {
 buffer.write(fruit);
 buffer.write(' ');
}
print (buffer.toString()); // prints: Strawberry Coconut Orange Mango Apple
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can use a StringBuffer to incrementally build a string. This is better than using&lt;br&gt;
string concatenation as it performs better. You add content to a StringBuffer by calling&lt;br&gt;
its write method. Then, once it's been created, you can transform it into a String with the&lt;br&gt;
toString method.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Types of parameters in dart&lt;/strong&gt;&lt;br&gt;
Dart has two types of parameters which are &amp;gt; named and positional parameters.&lt;/p&gt;

&lt;p&gt;**Positional optional parameters **are those parameters that are used if you wrap your function's parameter list in square brackets &lt;code&gt;[ ]&lt;/code&gt;, then those parameters can be omitted without the compiler throwing errors. The question mark after a parameter, such as in String? name, tells the Dart compiler that the parameter itself can be null. Remember we covered this in the previous chapter 😝 so here by they are used like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void unnamed([String? name, int? age]) {
 final actualName = name ?? 'Unknown';
 final actualAge = age ?? 0;
 print('$actualName is $actualAge years old.');
}

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

&lt;/div&gt;



&lt;p&gt;One more thing to add also supports &lt;strong&gt;named optional&lt;/strong&gt; parameters with curly braces. Then When calling a function with named parameters, you need to specify the&lt;br&gt;
parameter name. You can call the parameters in any order; for&lt;br&gt;
example, &lt;code&gt;named(greeting: 'hello!')&lt;/code&gt;;. And Dart also supports default values for parameters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Closures&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Closures, also known as first-class functions, are an interesting language feature that emerged from lambda calculus in the 1930s. The basic idea is that a function is also a value that can be passed around to other functions as a parameter. These types of functions are called closures, but there is really no difference between a function and a closure. Closures can be saved to variables and used as parameters for other functions. They are&lt;br&gt;
even written inline when consuming a function that expects a closure as a property.&lt;br&gt;
We can optimise the use of closures using typedef keyword have a look:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;typedef NumberGetter = int Function();
int powerOfTwo(NumberGetter getter) {
 return getter() * getter();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;6. Relationships between classes in dart&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://media.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%2Fgl10wgt8m4k3gub4orfq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fgl10wgt8m4k3gub4orfq.png" alt="Classes"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Grouping data and manipulating data in dart&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now as you are familiar with other languages you know that each language has a way to organize data, you can use one of these collections: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Lists are linear collections where the order of the elements is maintained.&lt;/li&gt;
&lt;li&gt;Maps are a non-linear collection of values that can be accessed by a unique key.&lt;/li&gt;
&lt;li&gt;Sets are a non-linear collection of unique values where the order is not maintained
If Dart is not your first programming language, then
this matrix should help you correlate collections to equivalent concepts in other languages:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fr4jdpv6hbhs1prvwhyjg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fr4jdpv6hbhs1prvwhyjg.png" alt="Collections"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One thing that these collections have in common is a subscript syntax.  Subscripts are a way to quickly access elements in a collection, and they tend to work identically from language to&lt;br&gt;
language.&lt;br&gt;
like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;numbers[1] = 15;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Horrayyy!!!! ✈️ Thanks fo reading to this far now you're good to go with dart this marks the end of our series about the introduction to dart. Thank you 😉, stay tuned for more articles 🎉&lt;br&gt;
And for further explanation please head to dart.dev.&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>mobile</category>
    </item>
    <item>
      <title>Null safety and asynchronous programming in dart 😊</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Mon, 23 May 2022 09:12:53 +0000</pubDate>
      <link>https://dev.to/dmutoni/null-safety-and-asynchronous-programming-in-dart-174e</link>
      <guid>https://dev.to/dmutoni/null-safety-and-asynchronous-programming-in-dart-174e</guid>
      <description>&lt;p&gt;Hey folks, in this series is second chapter, here we are going to go through major dart features with the assumption that you already know how to program in another language😉&lt;/p&gt;

&lt;p&gt;As you learn Dart you have to keep these concepts in mind: &lt;/p&gt;

&lt;h2&gt;
  
  
  Null safety in Dart
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Dart offers sound null safety, that is to say types in your code are non-nullable by default, meaning that variables can’t contain null unless you say they can. With sound null safety, Dart can protect you from null exceptions at runtime through static code analysis. Unlike many other null-safe languages, when Dart determines that a variable is non-nullable, that variable is always non-nullable. If you inspect your running code in the debugger, you’ll see that non-nullability is retained at runtime (hence sound null safety).
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// In null-safe Dart, none of these can ever be null.
var i = 50; // Inferred to be an int.
String name = getFileName();
final b = Foo();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To indicate that a variable may be null you can use &lt;code&gt;?&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;int? aNullableInt = null;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generally speaking, variables that have no value are null, and this may lead to errors in your code. If you have been programming for any length of time, you are probably already&lt;br&gt;
familiar with null exceptions in your code. The goal of null safety is to help you prevent execution errors raised by the improper use of null. With null safety, by default, your variables cannot be assigned a null value.&lt;/p&gt;

&lt;p&gt;So how can one use dart null safety ? 🤔&lt;br&gt;
It's simple dart null safety is avaiable in Dart ^2.12 or Flutter 2 as well as Flutter 3.&lt;br&gt;
But also if you want to migrate your app to null safety you can &lt;br&gt;
use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ dart create -t console my_cli
$ cd my_cli
$ dart migrate --apply-changes
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;⚠️ But wait.. Before migrating your app to null safety check this first:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Wait&lt;/strong&gt; for the packages that you depend on to migrate
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//Get the migration state of your package’s dependencies, using the following command:
$ dart pub outdated --mode=null-safety
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Migrate&lt;/strong&gt; your package's code, preferably using the interactive migration tool. You can also migrate using
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;dart migrate&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;or migrate your code by hand.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Statically&lt;/strong&gt; analyze your package’s code.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ dart pub get
$ dart analyze
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Test&lt;/strong&gt; to make sure your changes work.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dart test
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Publish&lt;/strong&gt; ✨&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If the package is already on pub.dev, publish the null-safe version as a prerelease version. 🎉 If you have reached this step kudos to you 😉&lt;/p&gt;

&lt;h2&gt;
  
  
  Asynchronous programming in dart
&lt;/h2&gt;

&lt;p&gt;Asynchronous operations let your program complete work while waiting for another operation to finish. There are some common asynchronous operations which are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Fetching data over a network.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Writing to a database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reading data from a file.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It works in situations when you are searching for straightforwardness over productivity. To deal with basic and autonomous information, asynchronous programming is an extraordinary decision.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fva23ilz7wa043968zsy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fva23ilz7wa043968zsy5.png" alt="Asynchronous programming"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why should we use asynchronous programming 🤔&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Improvement in performance and responsiveness of your application, especially when you have long-running activities that don’t need to block the execution. For this situation, you can perform other work while waiting for the outcome from the long-running undertaking.&lt;/li&gt;
&lt;li&gt;Assemble your code in a flawless and comprehensible manner fundamentally better than the standard code of the conventional thread creation and taking care of it with &lt;code&gt;async / await&lt;/code&gt; , you compose less code and your code will be more viable than utilizing the past asynchronous programming strategies like utilizing plain assignment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Such asynchronous computations usually provide their result as a Future or, if the result has multiple parts, as a Stream. These computations introduce asynchrony into a program. To accommodate that initial asynchrony, other plain Dart functions also need to become asynchronous.&lt;/p&gt;

&lt;p&gt;To interact with these asynchronous results, you can use the async and await keywords. Most asynchronous functions are just async Dart functions that depend, possibly deep down, on an inherently asynchronous computation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;hummm, Then what's a future in dart?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A future represents the result of an asynchronous operation, and can have two states: uncompleted or completed&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So how can you work with futures ?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The async and await keywords provide a declarative way to define asynchronous functions and use their results. Remember these two basic guidelines when using async and await:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To define an async function, add async before the function body:&lt;br&gt;
Here is an example &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The await keyword works only in async functions.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;void main() async {
await flutter();
print('flutter Devs done');
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;KUDOSS ✈️, you are now capable of some of the major concepts in dart&lt;/p&gt;

&lt;p&gt;For more details about the null safety and asynchronous programming please head to &lt;code&gt;dart.dev&lt;/code&gt;&lt;br&gt;
Thank you 🎉&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>programming</category>
      <category>mobile</category>
    </item>
    <item>
      <title>A brief introduction to Dart</title>
      <dc:creator>Denyse</dc:creator>
      <pubDate>Sat, 21 May 2022 06:37:12 +0000</pubDate>
      <link>https://dev.to/dmutoni/a-briefly-introduction-to-dart-1p7m</link>
      <guid>https://dev.to/dmutoni/a-briefly-introduction-to-dart-1p7m</guid>
      <description>&lt;p&gt;Hey folks 👋  I am Denyse, this series is first chapter I want to write about flutter in the future i'll write more and more cool things about Dart and Flutter we'll spend a little time to take a look into Dart programming languages.&lt;br&gt;
I wanted to jump straight to flutter ... but wait 🤔 I couldn't talk about flutter without talking about dart first  &lt;/p&gt;

&lt;h2&gt;
  
  
  So what is Dart?
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Dart is a programming language designed for client development, such as for web and mobile apps. It is designed by a huge and powerful company ✨ company called &lt;strong&gt;Google&lt;/strong&gt; and also can be used to build server and desktop applications. It is a class-based, garbage-collected language with C-style syntax.&lt;br&gt;
Dart is a client-optimized language for developing fast apps on any platform. Dart was created by Google and first time it appeared was October 10, 2011.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Fun fact about it 😂, first stable version of Dart wasn't 1.0.0, it was 0.8.10-rev.3.29803.&lt;/p&gt;

&lt;p&gt;In Dart SDK Tools contain these tools that necessary for development applications:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;DartVM - Dart Virtual Machine.&lt;/li&gt;
&lt;li&gt;dart2js- Dart to javascript (web use only) for deployable Javascript.&lt;/li&gt;
&lt;li&gt;dartdevc - Dart to javascript(web use only) for testing purpose.&lt;/li&gt;
&lt;li&gt;dartfmt - Tools formatter dart code&lt;/li&gt;
&lt;li&gt;dartanalyzer - Tools help analyze warning and error code that are specified in dart language. DartPad and IDEs such as Android Studio or VS Code are use the same analysis engine that dartanalyzer provide&lt;/li&gt;
&lt;li&gt;DartDoc - The API documentation generator (using for write package mostly)&lt;/li&gt;
&lt;li&gt;pub - Dart package manager (it's like npm or yarn or pnpm). We can use pub tools for manage Dart packages.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What do we mean by Dart fast &lt;strong&gt;apps&lt;/strong&gt; , here we mean Dart's speed to mean Dart can compile at both &lt;strong&gt;Run time(JIT)&lt;/strong&gt; and &lt;strong&gt;Ahead of Time (AOT)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.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%2Fb0iy19xz3sj77cuol6z3.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2Fb0iy19xz3sj77cuol6z3.gif" alt="GIF"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is AOT or JIT ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.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%2F9xy50hx6e9gk0bw90uus.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.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%2F9xy50hx6e9gk0bw90uus.png" alt="JIT and AOT description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;em&gt;&lt;strong&gt;JIT&lt;/strong&gt;&lt;/em&gt; means or &lt;strong&gt;development mode&lt;/strong&gt; Flutter provide cools features which are &lt;strong&gt;hot-reload&lt;/strong&gt; and &lt;strong&gt;hot-restart&lt;/strong&gt; 😊 that help you see UI changes when you change on code. With that is lots of tools that help you debug.&lt;/li&gt;
&lt;li&gt;The &lt;em&gt;&lt;strong&gt;AOT&lt;/strong&gt;&lt;/em&gt;  or &lt;strong&gt;release mode&lt;/strong&gt; your code is compiled to native code for better &lt;strong&gt;performance&lt;/strong&gt;, minimum app size and remove other stuff that useful in dev mode.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Wanna know more about dart? head to &lt;a href="https://dart.dev/" rel="noopener noreferrer"&gt;Dart documentation&lt;/a&gt; and stay tuned to get more updates about flutter and dart ... &lt;/p&gt;

</description>
      <category>flutter</category>
      <category>dart</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
