<?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: AbhishekDoshi26</title>
    <description>The latest articles on DEV Community by AbhishekDoshi26 (@abhishekdoshi26).</description>
    <link>https://dev.to/abhishekdoshi26</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%2F265721%2Fc1783e0b-cb16-42af-a8ee-70b9ec75b1ec.png</url>
      <title>DEV Community: AbhishekDoshi26</title>
      <link>https://dev.to/abhishekdoshi26</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhishekdoshi26"/>
    <language>en</language>
    <item>
      <title>Bloc Pattern in Flutter | Part 1💙</title>
      <dc:creator>AbhishekDoshi26</dc:creator>
      <pubDate>Mon, 21 Dec 2020 16:50:50 +0000</pubDate>
      <link>https://dev.to/abhishekdoshi26/bloc-pattern-in-flutter-part-1-33kh</link>
      <guid>https://dev.to/abhishekdoshi26/bloc-pattern-in-flutter-part-1-33kh</guid>
      <description>&lt;h2&gt;
  
  
  Bloc Pattern in Flutter | Part 1💙
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Do you feel Bloc is tough? Me too!
&lt;/h3&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;Let’s make it easy then!😍&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;In this article, we will check out how to use Bloc in Flutter using flutter_bloc package with an example.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Package Link: &lt;a href="https://pub.dev/packages/flutter_bloc" rel="noopener noreferrer"&gt;flutter_bloc | Flutter Package (pub.dev)&lt;/a&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F2200%2F0%2A-6V0mn8A-nG3INtT.jpg" 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%2Fcdn-images-1.medium.com%2Fmax%2F2200%2F0%2A-6V0mn8A-nG3INtT.jpg"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;So Bloc basically uses the concept of Inherited Widget. We can implement Bloc using Stream and Sink but, we already have a package **flutter_bloc **which is a wrapper of Stream and Sink.&lt;/p&gt;

&lt;p&gt;Before we start bloc, there are two concepts that needs to be clear:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Events&lt;/strong&gt;: Events are basically the functionalities of the app. Let’s say for our basic Counter app, &lt;strong&gt;&lt;em&gt;Increment&lt;/em&gt;&lt;/strong&gt; is a functionality and hence, one of our event is &lt;strong&gt;&lt;em&gt;Increment&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;States: *&lt;em&gt;State is the information that can be read synchronously when the widget is built and might change during the lifetime of the widget. Or, in simple words, we can say that the State is something that our app is, before and after the event. *&lt;/em&gt;*Hence, in our Counter example, the app before increment and after increment is State. Also, we can say that we have a state while it’s incrementing.&lt;/strong&gt;*&lt;/p&gt;&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%2Fcdn-images-1.medium.com%2Fmax%2F2700%2F1%2AzX8briMwYZ7dymAakD0u0Q.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%2Fcdn-images-1.medium.com%2Fmax%2F2700%2F1%2AzX8briMwYZ7dymAakD0u0Q.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In BLOC, we give &lt;strong&gt;Event **as **input **to BLOC. Then we do the **processing&lt;/strong&gt;/&lt;strong&gt;business logic in the Bloc&lt;/strong&gt; and provide &lt;strong&gt;State **as **output&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In a Bloc, there will be 3 main files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;bloc file:&lt;/strong&gt; This file contains the main Business Logic&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;events file:&lt;/strong&gt; This file states all the events that are present in your app.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;state file:&lt;/strong&gt; This file contains all the states that your app undergoes.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Let’s start with the coding!
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;We will re-write the basic Counter App using BLOC!&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step 1: Import &lt;a href="https://pub.dev/packages/flutter_bloc" rel="noopener noreferrer"&gt;flutter_bloc&lt;/a&gt; in pubspec.yaml&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;flutter_bloc: ^6.1.1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Create a folder named bloc and create 2 files in it. Here, we will name them as counter_bloc andcounter_event . As we don’t have multiple states, we won’t create counter_state .&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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUUxqsfm1qnEsqfx7cf_Vxw.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%2Fcdn-images-1.medium.com%2Fmax%2F2000%2F1%2AUUxqsfm1qnEsqfx7cf_Vxw.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is how the project structure will look like. You can name your files according to your comfort.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: **Let’s first create the basic UI and functionality of our app by scratch without Bloc. Here’s the main.dart and home.dart files:&lt;br&gt;
**main.dart:&lt;/strong&gt;&lt;/p&gt;

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

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  [@override](http://twitter.com/override)
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;home.dart&lt;/strong&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';

class MyHomePage extends StatefulWidget {
  [@override](http://twitter.com/override)
  _MyHomePageState createState() =&amp;gt; _MyHomePageState();
}

class _MyHomePageState extends State&amp;lt;MyHomePage&amp;gt; {
  int counter = 0;

[@override](http://twitter.com/override)
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () =&amp;gt; setState(() {
          counter++;
        }),
      ),
      appBar: AppBar(
        title: Text('Bloc Counter Example'),
      ),
      body: Center(
        child: Text(
          '$counter',
          style: TextStyle(fontSize: 50.0),
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So this is the basic application (Counter Application) that we created from scratch. Now, let’s work on our &lt;strong&gt;BLOC.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;**Step 4: **Let’s create our events. As this is a simple example, we just have 1 event i.e. **Increment **and we don’t even need to pass any parameters. So we will use enum in this case. So, our counter_event.dart will look like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;enum CounterEvent { increment }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Now, let’s work on our bloc file i.e. counter_bloc.dart . &lt;br&gt;
In this file, we need to specify our business logic. We have to create a class that extends Bloc class. Let me show you how it will look:&lt;/p&gt;

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

class CounterBloc extends Bloc&amp;lt;CounterEvent, int&amp;gt; {
  CounterBloc() : super(0);

[@override](http://twitter.com/override)
  Stream&amp;lt;int&amp;gt; mapEventToState(CounterEvent event) async* {
    switch (event) {
      case CounterEvent.increment:
        yield state + 1;
        break;
      default:
        break;
    }
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So, the above code is our counter_bloc.dart . This is the main core of our application that will increment the counter. Let’s break this code and understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;class CounterBloc extends Bloc&lt;/strong&gt;&lt;br&gt;
Here, **CounterEvent **is our event i.e. enum that we created in counter_event.dart and **int **is the state because we are simply incrementing an integer variable. If your application is complex, instead of int, you can specify your State class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;**CounterBloc() : super(0);&lt;br&gt;
**So, this is basically the constructor of CounterBloc() class where we pass an initial value i.e. 0 in our case to the parent class i.e. Bloc class because our CounterBloc extends Bloc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then we need to implement one method named mapEventToState . This method basically maps our input events with the corresponding output states.&lt;br&gt;
*&lt;em&gt;Stream mapEventToState(CounterEvent event) async&lt;/em&gt;&lt;br&gt;
*&lt;em&gt;This method takes Event as input and returns a Stream of state and hence we need to make it async&lt;/em&gt;. Now, if you have custom state file, you have to replace **int **with your state class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Now, we check for the events. If it’s CounterEvent.increment, we need to increment the value. yield adds a value to the output stream of the surrounding async* function. It's like return, but doesn't terminate the function.&lt;/p&gt;

&lt;p&gt;switch (event) {&lt;br&gt;
      case CounterEvent.increment:&lt;br&gt;
        yield state + 1;&lt;br&gt;
        break;&lt;br&gt;
      default:&lt;br&gt;
        break;&lt;br&gt;
    }&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Here, we complete our counter_bloc.dart file implementation!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So, our BLOC is ready! Now we just need to integrate it with our UI i.e. main.dart and home.dart files&lt;/p&gt;

&lt;p&gt;I hope it was pretty clear till here! Don’t bang your laptop, we are just a few lines of code away 😉&lt;/p&gt;



&lt;p&gt;**Step 6: **Open main.dart file and wrap the child of MaterialApp with BlocProvider. Your file will look like this:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:bloc_counter_example/bloc/counter_bloc.dart';
import 'package:bloc_counter_example/home.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  [@override](http://twitter.com/override)
  Widget build(BuildContext context) {
    return MaterialApp(
      home: BlocProvider&amp;lt;CounterBloc&amp;gt;(
        create: (context) =&amp;gt; CounterBloc(),
        child: MyHomePage(),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;So, basically BlocProvider will provide the access to Bloc throughout the Widget Tree.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;BlocProvider&amp;lt;CounterBloc&amp;gt;(
        create: (context) =&amp;gt; CounterBloc(),
        child: MyHomePage(),
      ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, CounterBloc is our bloc class that we created in previous step. We need to provide which bloc is to be created (here CounterBloc()) and the child where the bloc should be accessible. Yep! That’s it for main.dart file. Let’s now move to home.dart 😍&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: **Open home.dart file and create an instance of **CounterBloc()&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CounterBloc _counterBloc;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Now, inside our build method, let’s instantiate our _counterBloc variable.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;_counterBloc = BlocProvider.of&amp;lt;CounterBloc&amp;gt;(context);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;What does the above statement does??? It actually gives you access to the CounterBloc that we created. Now, using _counterBloc we can access our event and state.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: **Now, wrap the Text() widget (where we display the count) with **BlocBuilder&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body: Center(
        child: BlocBuilder&amp;lt;CounterBloc, int&amp;gt;(
          builder: (context, state) {
            return Text(
              '$state',
              style: TextStyle(fontSize: 50.0),
            );
          },
        ),
      ),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here, the state variable that we can see, has access to the states. In this case, state is just an integer value which will get incremented. So we can directly display the state. Now, let’s change our Floating Action Button onPressed() method!&lt;/p&gt;

&lt;p&gt;**Step 9: **In onPressed for Floating Action Button, we need to add the event to the bloc. Syntax:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;onPressed: () =&amp;gt; _counterBloc.add(CounterEvent.increment),
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;This is how your home.dart file will look now:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:bloc_counter_example/bloc/counter_bloc.dart';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'bloc/counter_event.dart';

class MyHomePage extends StatefulWidget {
  [@override](http://twitter.com/override)
  _MyHomePageState createState() =&amp;gt; _MyHomePageState();
}

class _MyHomePageState extends State&amp;lt;MyHomePage&amp;gt; {
  CounterBloc _counterBloc;

[@override](http://twitter.com/override)
  void dispose() {
    _counterBloc.close();
    super.dispose();
  }

[@override](http://twitter.com/override)
  Widget build(BuildContext context) {
    _counterBloc = BlocProvider.of&amp;lt;CounterBloc&amp;gt;(context);
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () =&amp;gt; _counterBloc.add(CounterEvent.increment),
      ),
      appBar: AppBar(
        title: Text('Bloc Counter Example'),
      ),
      body: Center(
        child: BlocBuilder&amp;lt;CounterBloc, int&amp;gt;(
          builder: (context, state) {
            return Text(
              '$state',
              style: TextStyle(fontSize: 50.0),
            );
          },
        ),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;And done!!!!!!!!!!!!!&lt;/strong&gt;&lt;/p&gt;



&lt;p&gt;We just implemented Bloc in our basic Counter Application💙&lt;/p&gt;

&lt;p&gt;In the next article, we will take a complex application with multiple states and implement it using Bloc.&lt;/p&gt;

&lt;p&gt;Hope you enjoyed this article!&lt;/p&gt;

&lt;p&gt;GitHub Repository: &lt;a href="https://github.com/AbhishekDoshi26/bloc_counter_example" rel="noopener noreferrer"&gt;AbhishekDoshi26/bloc_counter_example (github.com)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you loved it, you can &lt;a href="https://www.buymeacoffee.com/abhishekdoshi26" rel="noopener noreferrer"&gt;**Buy Me A Coffee&lt;/a&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%2Fcdn-images-1.medium.com%2Fmax%2F16676%2F1%2AVqLYs481X9kw_CTosgqlcg.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%2Fcdn-images-1.medium.com%2Fmax%2F16676%2F1%2AVqLYs481X9kw_CTosgqlcg.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Don’t forget to connect with me on:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.instagram.com/abhishekdoshi26/" rel="noopener noreferrer"&gt;**Instagram&lt;/a&gt;**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://twitter.com/AbhishekDoshi26" rel="noopener noreferrer"&gt;**Twitter&lt;/a&gt;**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.linkedin.com/in/AbhishekDoshi26" rel="noopener noreferrer"&gt;**LinkedIn&lt;/a&gt;**&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href="https://github.com/AbhishekDoshi26" rel="noopener noreferrer"&gt;**GitHub&lt;/a&gt;**&lt;/p&gt;

&lt;blockquote&gt;
&lt;h1&gt;
  
  
  Don’t stop, until you are breathing!💙
&lt;/h1&gt;
&lt;h1&gt;
  
  
  - Abhishek Doshi
&lt;/h1&gt;
&lt;/blockquote&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>tutorial</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>Flutter Valsad</title>
      <dc:creator>AbhishekDoshi26</dc:creator>
      <pubDate>Fri, 06 Nov 2020 07:00:11 +0000</pubDate>
      <link>https://dev.to/abhishekdoshi26/flutter-valsad-4n3g</link>
      <guid>https://dev.to/abhishekdoshi26/flutter-valsad-4n3g</guid>
      <description>&lt;p&gt;Flutter Valsad is here 🥁🥁&lt;/p&gt;

&lt;p&gt;For more updates follow us on :&lt;br&gt;
Instagram: &lt;a href="https://www.instagram.com/flutter_valsad"&gt;https://www.instagram.com/flutter_valsad&lt;/a&gt;&lt;br&gt;
Twitter: &lt;a href="https://twitter.com/flutter_valsad"&gt;https://twitter.com/flutter_valsad&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💙💙&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>community</category>
    </item>
    <item>
      <title>How to publish your first Flutter Package!</title>
      <dc:creator>AbhishekDoshi26</dc:creator>
      <pubDate>Thu, 15 Oct 2020 16:33:25 +0000</pubDate>
      <link>https://dev.to/abhishekdoshi26/how-to-publish-your-first-flutter-package-5467</link>
      <guid>https://dev.to/abhishekdoshi26/how-to-publish-your-first-flutter-package-5467</guid>
      <description>&lt;p&gt;Using Flutter Packages since long?&lt;br&gt;
Do you wish to contribute back?&lt;br&gt;
Do you wish to publish your own package and help the community? &lt;br&gt;
But don't know how? &lt;br&gt;
&lt;strong&gt;No worries. I have your back.&lt;/strong&gt;&lt;br&gt;
In this blog, I will get you through each and every step of how to publish your own Flutter Package on the official Flutter Website &lt;a href="//pub.dev"&gt;&lt;strong&gt;pub.dev&lt;/strong&gt;&lt;/a&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%2Fcdn-images-1.medium.com%2Fmax%2F1000%2F1%2A3AxRgomPxY8gZPNNYfe9vQ.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%2Fcdn-images-1.medium.com%2Fmax%2F1000%2F1%2A3AxRgomPxY8gZPNNYfe9vQ.png" alt="pub.dev"&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Pre-Requisites :&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Passion For Helping&lt;/li&gt;
&lt;li&gt;Understanding of Flutter&lt;/li&gt;
&lt;li&gt;Git&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  So let's get our hands dirty!! 👏👏
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A flutter package always has a class which returns a widget.&lt;/strong&gt;&lt;br&gt;
Also, the class must not have any hard-coded values.&lt;br&gt;
All the functionalities which you want to provide to the user, create it as a property (variable) and create a constructor to get the value.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For example:&lt;/strong&gt;&lt;br&gt;
If you want the user to set the height of the container, create a property named &lt;code&gt;double height&lt;/code&gt;. Add in the constructor &amp;amp; then pass it to the height property of the Container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class &amp;lt;class_name&amp;gt;{
     double height;
     class_name({this.height});
     .
     .
     .
     .
     Container(
        height:height,
        .
        .
        .
     ),
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the code is created, use it in an application to test it and get a better understanding.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;So, let's start through the steps of how to publish the package!! 🎉💙&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Start by creating new flutter package!!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Android Studio&lt;/li&gt;
&lt;li&gt;Click on Create new Flutter Project&lt;/li&gt;
&lt;li&gt;Click on New Flutter Package&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; Give the name of the project as the one you want your package to be named. Thus, the name of your project will be your package name.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; Put the project on Github. Keep the repo public.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; This is the most Important Step!!&lt;br&gt;
Edit the Pubspec.YAML file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Add Description&lt;/strong&gt; for the package (Minimum 20 words). This costs you points on pub.dev after publishing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remove author&lt;/strong&gt; as it is not used now.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add homepage&lt;/strong&gt;. HomePage can be your own website or you can also give the Github Profile Page link.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Add repository.&lt;/strong&gt; Don't do mistake in this!! If the link get's wrong, &lt;code&gt;issues&lt;/code&gt; link on the pub.dev will not be generated. Here's an example:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Correct Link: https://github.com/AbhishekDoshi26/contactus
Wrong Link: https://github.com/AbhishekDoshi26/contactus.git
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Add Version Number.&lt;/strong&gt; Whenever you update your package code, version number has to be changed.&lt;/li&gt;
&lt;/ul&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Write the code in the dart file.&lt;/strong&gt; Here's an example of the code of a package named &lt;a href="https://github.com/AbhishekDoshi26/contactus/blob/master/lib/contactus.dart" rel="noopener noreferrer"&gt;&lt;code&gt;contactus&lt;/code&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;&lt;strong&gt;Step 6: Create Documentation.&lt;/strong&gt; For Documentation, you need to use /// to provide the documentation for a particular property/method/class,etc. &lt;strong&gt;&lt;em&gt;/// will create documentaion and // will be comment.&lt;/em&gt;&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 ContactUs extends StatelessWidget {
  ///Logo of the Company/individual
  final ImageProvider logo;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also, after creating manual documentations to your classes, let's created the predefined documentation. Open Command Prompt in the package location and run &lt;code&gt;dartdoc&lt;/code&gt; command in terminal on your package location.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 7:&lt;/strong&gt; Open the &lt;strong&gt;&lt;code&gt;CHANGELOG.md&lt;/code&gt;&lt;/strong&gt; file and write the version number, publishing date and description in the file. Here's an example for the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;## [1.0.0] - 16/04/2020.
Added Icons for all the social networks
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 8:&lt;/strong&gt; Create a file LICENSE.txt &amp;amp; add any license such as MIT License. You can get template of any license from the internet. You can refer the MIT License of &lt;a href="https://github.com/AbhishekDoshi26/contactus/blob/master/LICENSE" rel="noopener noreferrer"&gt;&lt;strong&gt;contactus package&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 8: Create an Example.&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inside the package folder itself, create a &lt;strong&gt;new flutter project, named as example.&lt;/strong&gt; (Don't change the name. Name has to be compulsory example as it will be used in pub.dev)&lt;/li&gt;
&lt;li&gt;To use the package in the example, without publishing, add in the &lt;strong&gt;pubspec.yaml&lt;/strong&gt; the following line:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package_name:
    path: Complete path of the package on your computer.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Here's the code snippet of how you can use contactus package or your own package in the example:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import 'package:contactus/contactus.dart';
import 'package:flutter/material.dart';
void main() =&amp;gt; runApp(MyApp());
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        bottomNavigationBar: ContactUsBottomAppBar(
          companyName: 'Abhishek Doshi',
          textColor: Colors.white,
          backgroundColor: Colors.teal.shade300,
          email: 'adoshi26.ad@gmail.com',
        ),
        backgroundColor: Colors.teal,
        body: Container(),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;&lt;strong&gt;Step 9: Push all to the Github Repository&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 10:&lt;/strong&gt; Open Command Prompt on the repo location. Now run the following command:&lt;br&gt;
&lt;strong&gt;&lt;code&gt;flutter pub publish --dry-run&lt;/code&gt;&lt;/strong&gt;&lt;br&gt;
If any suggestions or warnings are encountered, do the required changes.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Step 11:&lt;/strong&gt; If everything is perfect, run the following command to publish the package.&lt;br&gt;
&lt;strong&gt;&lt;code&gt;flutter pub publish&lt;/code&gt;&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;&lt;em&gt;Tadaaaaaaaaaaaaaa!!!!!!!!🌟🎉👏 Your package has been published!!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, whenever you change anything in the code/any file of the package/example, you need to update the following files:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pubspec.yaml (Version Number)&lt;/li&gt;
&lt;li&gt;CHANGELOG.md (Add new version, date &amp;amp; description)&lt;/li&gt;
&lt;/ul&gt;




&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&lt;em&gt;Don't stop until you are breathing!!!&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
 &lt;a href="https://abhishekdoshi.netlify.app/" rel="noopener noreferrer"&gt;&lt;strong&gt;-Abhishek Doshi&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
    </item>
    <item>
      <title>Contribute to your 1st Hacktober Fest</title>
      <dc:creator>AbhishekDoshi26</dc:creator>
      <pubDate>Thu, 15 Oct 2020 16:06:28 +0000</pubDate>
      <link>https://dev.to/abhishekdoshi26/contribute-to-your-1st-hacktober-fest-4cl6</link>
      <guid>https://dev.to/abhishekdoshi26/contribute-to-your-1st-hacktober-fest-4cl6</guid>
      <description>&lt;p&gt;Is this your 1st Hacktoberfest? Don't worry! I have your back.&lt;br&gt;
Here are the steps for generating your 1st legit pull request!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You need to register yourself at &lt;a href="http://hacktoberfest.digitalocean.com/"&gt;Hacktober Fest Website&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;After you register yourself, go to &lt;a href="//github.com"&gt;Github&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Now, in the search box, you can search for &lt;strong&gt;Hacktober Fest&lt;/strong&gt; label. There will come a list of Repositories/Issues in the result.&lt;/li&gt;
&lt;li&gt;If you don't find that interesting, you can simply go in &lt;strong&gt;Explore&lt;/strong&gt; and checkout various repositories.&lt;/li&gt;
&lt;li&gt;If that repository has a &lt;strong&gt;Hacktober Fest&lt;/strong&gt; topic, congrats, you got a repo for contribution.&lt;/li&gt;
&lt;li&gt;Now, as you have repository, let's start contribution!&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Fork this repo to your account.
- Clone the repo to your pc.
- Now, make changes or do your contributions to the cloned repo.
- After you have done your contributions, commit the changes and push the commit to your repo.
- Now, go to your repo on github website and generate a **Pull Request**
- Go to [Hacktober Fest Profile Page] (http://hacktoberfest.digitalocean.com/profile) and you will see the PR generated there.
- Now, you need to wait for the Review period to end. 
- If your PR gets merged, congrats, you have got 1 PR counted for Hacktober Fest!!
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Happy Open Sourcing!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>hacktoberfest</category>
      <category>flutter</category>
      <category>github</category>
      <category>git</category>
    </item>
  </channel>
</rss>
