<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rajeswari S on Medium]]></title>
        <description><![CDATA[Stories by Rajeswari S on Medium]]></description>
        <link>https://medium.com/@rajeswari3699?source=rss-d91f619ffaf5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*FzjrJTfJaV_oBajp5gtJfQ.png</url>
            <title>Stories by Rajeswari S on Medium</title>
            <link>https://medium.com/@rajeswari3699?source=rss-d91f619ffaf5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 11:32:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajeswari3699/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[FLUTTER PROJECT STRUCTURE]]></title>
            <link>https://medium.com/@rajeswari3699/flutter-project-structure-82cb31020860?source=rss-d91f619ffaf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/82cb31020860</guid>
            <category><![CDATA[project-management]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[file-structure]]></category>
            <dc:creator><![CDATA[Rajeswari S]]></dc:creator>
            <pubDate>Wed, 27 Jul 2022 06:38:11 GMT</pubDate>
            <atom:updated>2022-07-27T06:38:11.663Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VUNQc_xocpFL2zFSTpRWjw.jpeg" /></figure><h4>Why file structure?</h4><p>The file structure is the organization of the data of an application. The file structure is something that plays a very important role in the effective and easy management of the project be it of any size. As the size of a project grows, it becomes more and more important to have a proper structure and format for the code otherwise it can lead to many undesired problems such as:</p><ul><li>Unable to find the specific file in a repository, making it a time-consuming task.</li><li>Unfit for teamwork.</li><li>Difficult to maintain.</li><li>Or in the worst-case scenario, it can result in low performant app.</li></ul><p>We need to have a good file structure in our flutter app, and that is what we are going to discuss in this article. Although flutter does not give any recommendations in the structuring of the app, still we should do it in the best possible manner.</p><p>But before that one important thing that we always need to keep in mind is the naming of the file and directories must always be in the proper format.</p><h4><strong>Naming for files and directories:</strong></h4><ol><li>Create a new directory, the naming should be in lower case.</li></ol><p>Ex: screens , components</p><p>2. Create a new file, the naming should be in following manner<br> 2a. should be in lower case.</p><p>Ex. login.dart</p><p>2b. lower case for both words separated by underscore</p><p>Ex. login_screen.dart</p><p>2c. Should be avoided camel case, upper case for both words, upper case for both words separated by underscore</p><p>Ex. loginScreen.dart,</p><p>LoginScreen.dart,</p><p>Loginscreen.dart,</p><p>Login_Screen.dart</p><h4><strong>Naming for Variable Declaration:</strong></h4><p>1. Variable naming should be following the camel case</p><p>Ex. var userName;</p><p>2. Should we avoided the following manner of variable declaration</p><p>Ex. var user_Name;<br> var user_name;<br> var UserName;<br> var Username;<br> var User_Name;</p><h4><strong>Naming for Method:</strong></h4><p>1. When we create a new Method and naming it in camelCase and camelCase with underscore</p><p>Ex. loginMethod(){}<br> _loginMethod(){}</p><p>2. should we avoided the following case (both words are uppercase or lower case)</p><p>Ex. _LoginMethod(){} <br> loginmethod(){}</p><h4><strong>Project File Structure:</strong></h4><p>Whenever we create a new project in flutter these are the files and directories that we are provided with project. Now we will add some other folders and files in the project that are listed below.</p><h4>1.<strong> Assets: Static assets for the app.</strong></h4><p>Create assets directory is on the root level will contain all the static assets that are used in the application, for example, fonts, icons, logos, images, videos, etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*aRVgHpufbGUdYjumWyPB6w.png" /><figcaption>assets directory</figcaption></figure><h4>2.<strong> lib Structure</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/787/1*QyTJHAysOTim2jUnk_jM6g.png" /><figcaption>lib Structure</figcaption></figure><p><strong>Actions: </strong>This directory is supposed to hold all the interactions that transact the data from outside the app.</p><p><strong>Components: </strong>This directory is contain all the reusable components of this app. That widget are used multiple times in the application</p><p><strong>Models: </strong>Models are the collection of data that are usually sourced from the servers, users, or external APIs, these are used in combination with widgets to complete the user interface of the app.</p><p><strong>Reducers: </strong>This directory for state management, here using reducer, if you are using providers naming it providers or else.</p><p><strong>Res: </strong>In this resource directory to hold on app requirements like strings, colors, images and fonts…etc.,</p><p><strong>Routes: </strong>In this routes directory have the entire the application routes (navigation) .</p><p><strong>Screens: </strong>This directory will contain the actual layout of the UI for the entire application. It can further be distributed into two-three folders.</p><p><strong>Services: </strong>In this directory fully for API interactions.</p><p><strong>Utilis: </strong>This directory will hold all the app logic or business logic of our entire application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*sEUptdwfSyoJFpAkFDNMrg.png" /><figcaption>A brief view of folder structure</figcaption></figure><h4><strong>Project Deployment:</strong></h4><p>Before we deploy a flutter project we ensure the following things, that are</p><p>1. Ensure the file structure<br> 2. Naming should be perfect as mentioned in above <br> 3. Code documentation<br> 4. To ensure the project coding structure is dart format<br> 5. To remove all unnecessary codes and print statements<br> 6. To remove all unused fileds, unused codes and dead codes</p><p>A last note on delimiters: <strong>never use spaces in your project path and filenames</strong>. Yes, many of us use them in our computer’s general file system because they’re so intuitive. But code and operating systems have a hard time dealing with them, so avoiding them in your project file structures will save you a lot of headache and cumbersome code.</p><blockquote>Project management can be defined as a way of <strong>developing structure in a complex project</strong>, where the independent variables of time, cost, resources and human behavior come together. <em>~ Rory Burke</em></blockquote><h4>Conclusion</h4><p>A successful file structure organizes your data and code with the goal of repeatability, making it easier for you and your collaborators to revisit, revise and develop your project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*i9V4yZG8rVm9NPVOR_mYXw.gif" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82cb31020860" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SonarQube with Flutter]]></title>
            <link>https://techmusings.optisolbusiness.com/sonarqube-with-flutter-e294e48018f2?source=rss-d91f619ffaf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e294e48018f2</guid>
            <category><![CDATA[code-analysis]]></category>
            <category><![CDATA[code-review]]></category>
            <category><![CDATA[sonarqube]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Rajeswari S]]></dc:creator>
            <pubDate>Mon, 23 May 2022 06:15:15 GMT</pubDate>
            <atom:updated>2022-09-21T10:14:02.086Z</atom:updated>
            <content:encoded><![CDATA[<p>SonarQube is a Code Quality Assurance tool that collects and analyzes source code, and provides reports for the code quality of your project.</p><p>For Flutter comes with dart analyzer and coverage.In SonarQube can help you write cleaner and safer code to detect bugs, code smells and security vulnerabilities. In this blog may help you implement sonarqube in your flutter app.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*ZKsysHxLfI5VWdSOITsYVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*31bH1BSx4XL7wWECid9l_A.png" /></figure><p><strong>Setup for Mac:</strong></p><p>Note: The SonarQube server require Java version 11 and the SonarQube scanners require Java version 11 or 17.</p><p><strong>Download and Setting up Sonarqube</strong></p><ol><li>Go to the Link → <a href="https://www.sonarqube.org/downloads/">https://www.sonarqube.org/downloads/</a></li></ol><p>2. Click <strong><em>COMMUNITY </em></strong>to download as a zip file</p><p>3. Extract a zip file and Move into the Applications folder</p><p>4. Change the name of the folder as <em>SonarQube</em></p><p><strong>Download and Setting up SonarScanner</strong></p><ol><li>Go to the Link → <a href="https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/">https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/</a></li><li>Click and download sonarscanner depends on your system OS</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8eB3xffs6DFU9ppdtUlEJQ.png" /></figure><p>3. In my case i am using mac OS , so that i can download SonarScanner Mac OS X 64- bit as a zip file</p><p>4.Extract a zip file and move into applications folder</p><p>5. Rename it as SonarScanner</p><p><strong>For Flutter download Sonar-Flutter Plugin</strong></p><ol><li>Go to the link <a href="https://github.com/insideapp-oss/sonar-flutter/releases/">https://github.com/insideapp-oss/sonar-flutter/releases/</a></li><li>Get latest release on sonar- scanner</li></ol><p>3. download sonar-flutter-plugin under the assets</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KJiWRzzXIt5KszsQA3mDAg.png" /></figure><p>4. move it into inside Applications → SonarQube → extensions → plugins folder.</p><p><strong>Set path in Terminal:<br></strong> open terminal. your Terminal tells you which shell you’re using. Depends on your shell set a path , save and quite a terminal.</p><p>export PATH=$PATH:/Applications/SonarScanner/bin<br>export PATH=$PATH:/Applications/SonarQube/bin</p><p>The setting up sonarqube and sonarscanner over. now we need to start the sonarqube server and Run sonarscanner</p><p><strong>Starting up Sonarqube server:<br></strong><em>run the following command in your terminal for mac:<br></em> sh /Applications/SonarQube/bin/macosx-universal-64/sonar.sh console</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bGHdiIXx3CrFFNqa3ktHw.png" /></figure><p><strong>Logging In and Create Project:</strong><br>1. Go to the browser. Open url —&gt; <a href="http://localhost:9000/about">http://localhost:9000/about</a><br>2.Click on Login use <strong>admin</strong> as username, <strong>admin</strong> as password<br>3.Create a Project as manually.<br>4.Enter the Project name.<br>5.Enter the project key.<br>6.click create and generate token for a project</p><p><strong>Project Configuration:<br></strong>1. Open your flutter project<br>2. Create a new file<strong><em> sonar-project.properties</em></strong> <br>3. add the following code in this file.<br>note: your project key should be match with your sonarqube project key</p><pre># Project identification<br>sonar.projectKey=your project key<br>sonar.projectName=your project name<br>sonar.projectVersion=1.0<br> <br># Source code location.<br># Path is relative to the sonar-project.properties file. Defaults to .<br># Use commas to specify more than one folder.<br>sonar.sources=lib<br>sonar.tests=test</pre><pre># Encoding of the source code. Default is default system encoding.<br>sonar.sourceEncoding=UTF-8</pre><pre># Allows reuse of an existing analyzer report<br># sonar.dart.analysis.reportPath=</pre><pre># Analyzer mode<br># Can be:<br># — flutter (flutter analyze) — default<br># — dart (dart analyze)<br># — legacy (dartanalyzer)<br># sonar.flutter.analyzer.mode=</pre><p><strong>Performing Analysis of your Project:<br></strong>1. open new terminal and run the following commands<br>2. Navigate to your flutter project- cd ~/Projects/Applications/myProject<br>3. flutter pub get<br>4. flutter test (sometimes test are failed)<br>5.flutter test — machine — coverage &gt; tests.output<br>6.sonar-scanner<br>The sonar scanner result is success , we can view the analysis report in webpage.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N9tvdJsUWNatttCGuBpFjg.png" /></figure><p>Successfully implemented sonarqube with flutter project.Hope this helpful for you… Thankyou!! 😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e294e48018f2" width="1" height="1" alt=""><hr><p><a href="https://techmusings.optisolbusiness.com/sonarqube-with-flutter-e294e48018f2">SonarQube with Flutter</a> was originally published in <a href="https://techmusings.optisolbusiness.com/">Tech Musings</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Offline Storage Using HIVE database]]></title>
            <link>https://techmusings.optisolbusiness.com/flutter-offline-storage-using-hive-database-a22cdfaa259e?source=rss-d91f619ffaf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a22cdfaa259e</guid>
            <category><![CDATA[hive-flutter]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[redux]]></category>
            <category><![CDATA[hive]]></category>
            <dc:creator><![CDATA[Rajeswari S]]></dc:creator>
            <pubDate>Mon, 03 Jan 2022 13:26:05 GMT</pubDate>
            <atom:updated>2022-09-21T10:14:33.159Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAnOizuhw51bzbB5MMAmFQ.jpeg" /></figure><p>In this Article we learn about Storing data as offline from REST Api response. we will see, How to Store List of data in Hive Database by using State Management of <strong>Redux </strong>and perform CRUD operations.</p><p><strong>Why choosing Hive?</strong></p><p>Hive is an Easy, Fast, Secure<strong> NoSQL </strong>Database Implementation for Flutter Applications. Hive has more PUB Points and Like 👍 when compare to other database (ObjectBox,Moor, sqflite etc.,). Hive is a lightweight and fast <strong>key-value </strong>database solution and is written in pure Dart. Hive is a dart package used in Flutter applications for storing data locally<strong> </strong>and<strong> </strong>manipulating the data on a targeted device.</p><p>A database typically allows developers to store, access, search, update, query, and otherwise manipulate data in the database via a developer language or API. These types of operations are done within an application, in the background, typically hidden from end users. Many applications need a database as part of their technology stack. The most typical database operations are <strong>CRUD</strong>: <strong>C</strong>reate, <strong>R</strong>ead, <strong>U</strong>pdate, <strong>D</strong>elete.</p><p><strong>what are boxes?</strong></p><p>Hive is pretty fantastic at storing the data securely using a AES-256 (robust encryption) method. So, <strong>where does it store the data? In the hive boxes!</strong></p><p>All data stored in Hive is organized in boxes. For a small app, a single box might be enough. For more advanced problems, boxes are a great way to organize your data. Boxes can also be encrypted to store sensitive data.</p><p>Before you can use a box, you have to open it. For regular boxes, this loads all of its data from the local storage into memory for immediate access.</p><p>Hive uses the concept of “boxes” for storing data on the database. boxes are flexible and can only handle simple relationships between data.It stores data in<strong> boxes having key-value sets</strong>. So, to read this data stored inside the boxes, you will have to <strong>open the boxes</strong> first to either read or compose it.</p><p><strong>Let’s Start our Implementation:</strong></p><p>Before moving on to the CRUD operations of the database, First we get data from API response and Stored in Hive boxes with State management of Redux.</p><p>I have Already publish an Article how to get data from API response and stored data in Redux . here is link👉 <a href="https://medium.com/@rajeswari3699/flutter-redux-state-management-with-redux-in-flutter-7a6a13515f69"><strong>Redux-State management with Redux in Flutter.</strong></a><strong> </strong>Using this Knowledge you can build your code with Redux. Now i can Skip this Step and directly move to how to store data In HIVE database from Redux.</p><p>When user open App as offline display data from database. when user have a network connection get data from server , Update db and display data (user request → server → get response → Redux (Reducer) → Update DB(Hive) → Display data ).</p><p><strong>Add Dependencies:</strong></p><p>Add the h<a href="https://pub.dev/packages/hive">ive</a> ,<a href="https://pub.dev/packages/hive_flutter">hive_flutter</a> and <a href="https://pub.dev/packages/path_provider">path_provider</a> packages to your pubspec.yaml file. we also need to add <a href="https://pub.dev/packages/hive_generator">hive_generator</a> and <a href="https://pub.dev/packages/build_runner">build_runner</a> to the dev dependencies .</p><pre>dependencies:<br>  hive: ^2.0.4<br>  hive_flutter: ^1.1.0<br>  path_provider: ^2.0.8<br>  flutter_redux: ^0.8.2<br>  redux: ^5.0.0<br>  redux_thunk: ^0.4.0</pre><pre>dev_dependencies:<br>  hive_generator: ^1.1.1<br>  build_runner: ^2.1.7</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DhJZK86CBJpx2TnA1C8hew.png" /></figure><p>First we initialize Hive in Main Function before we perform any operations related hive database.</p><pre>  <strong>await </strong>Hive.initFlutter();</pre><p>initialize hive with the path of the directory .it’s Optional. We can find the location on HDFS(Hadoop Distributed File System) where the directories for the database are made by checking hive.</p><pre>   Directory directory = <strong>await </strong>getApplicationDocumentsDirectory();<br>   Hive.init(directory.<strong>path</strong>);</pre><p>Hive supports all primitive types, List, Map, DateTime and Uint8List. If you want to store other objects, you have to register a TypeAdapter which converts the object from and to binary form. When you want Hive to use a TypeAdapter, you have to register it.</p><pre>Hive.registerAdapter(ServiceAdapter());</pre><p><strong>main.dart</strong></p><pre><strong>void </strong>main() <strong>async </strong>{<br>  WidgetsFlutterBinding.<em>ensureInitialized</em>();<br>  <strong>await </strong>Hive.initFlutter();<br>   Directory directory = <strong>await </strong>getApplicationDocumentsDirectory();<br>   Hive.init(directory.<strong>path</strong>);<br>   Hive.registerAdapter(ServiceAdapter());<br>  runApp(MyApp());<br>}<br><br><strong>final </strong>navigatorKey = GlobalKey&lt;NavigatorState&gt;();<br><br><strong>class </strong>MyApp <strong>extends </strong>StatefulWidget{<br>  <strong>const </strong>MyApp({Key? key}) : <strong>super</strong>(key: key);<br>  _MyAppState createState()=&gt;_MyAppState();<br>}<br><br><strong>class </strong>_MyAppState <strong>extends </strong>State&lt;MyApp&gt; {<br>  <strong>final store </strong>= Store&lt;AppState&gt;(<br>    appReducer,<br>    initialState: AppState.initial(),<br>    middleware: [thunkMiddleware, apiMiddleware, ],<br>  );<br><br>  @override<br>  <strong>void </strong>initState() {<br>    <strong>super</strong>.initState();<br>  }<br><br>  @override<br>  Widget build(BuildContext context) {<br>    SystemChrome.<em>setPreferredOrientations</em>([<br>      DeviceOrientation.<strong>portraitUp</strong>,<br>      DeviceOrientation.<strong>portraitDown</strong>,<br>    ]);<br><br>    <strong>return </strong>StoreProvider(<br>        store: <strong>this</strong>.<strong>store</strong>,<br>        child: MaterialApp(<br>          builder: (context, child) {<br>            <strong>return </strong>MediaQuery(data: MediaQuery.<em>of</em>(context).copyWith(textScaleFactor: 1.0), child:child!);<br>          },<br>          navigatorKey: navigatorKey,<br>          initialRoute: <strong>&#39;/feed&#39;</strong>,<br>          onGenerateRoute: RouteGenerator.<em>generateRoute</em>,<br>          debugShowCheckedModeBanner: <strong>false</strong>,<em><br>        </em>)<br>    );<br>  }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/307/1*l0JRvZ0qyM6GPzQRgmplWw.png" /><figcaption>Get List of data from Hive</figcaption></figure><p><strong>hivemodel.dart:</strong></p><p>Create model class for hive. Two things are needed for that: An instance of the adapter and a typeId. Every type has a unique typeId which is used to find the correct adapter when a value is brought back from disk. All typeIds between 0 and 223 are allowed.Make sure to use typeIds consistently. Your changes have to be compatible to previous versions of the box.It’s recommended to register all TypeAdapters before opening any boxes.</p><pre><strong>import &#39;package:hive/hive.dart&#39;</strong>;<br><strong>part &#39;hivemodel.g.dart&#39;</strong>;<br><br>@HiveType(typeId: 1,adapterName: <strong>&quot;ServiceAdapter&quot;</strong>)<br><strong>class </strong>GetService{<br>  @HiveField(0)<br>  String <strong>name</strong>;<br><br>  @HiveField(1)<br>  String <strong>lastname</strong>;<br><br>  @HiveField(2)<br>  String <strong>status</strong>;<br><br>  GetService({<strong>required this</strong>.<strong>name</strong>,<strong>required this</strong>.<strong>status</strong>,<strong>required this</strong>.<strong>lastname</strong>});<br>}</pre><p><strong>hivemodel.g.dart</strong></p><p>The <a href="https://pub.dev/packages/hive_generator">hive_generator</a> package can automatically generate TypeAdapters for almost any class.</p><ol><li>To generate a TypeAdapter for a class, annotate it with @HiveType and provide a typeId (between 0 and 223)</li><li>Annotate all fields which should be stored with @HiveField</li><li>You can Specify <strong>part ‘hivemodel.g.dart’ </strong>in<strong> hivemodel.dart</strong> .</li><li>Open terminal and Run flutter packages pub run build_runner build then automatically create <strong>hivemodel.g.dart </strong>.</li></ol><pre><em>// GENERATED CODE - DO NOT MODIFY BY HAND<br><br></em><strong>part of &#39;hivemodel.dart&#39;</strong>;<br><br><em>// **************************************************************************<br>// TypeAdapterGenerator<br>// **************************************************************************<br><br></em><strong>class </strong>ServiceAdapter <strong>extends </strong>TypeAdapter&lt;GetService&gt; {<br>  @override<br>  <strong>final </strong>int <strong>typeId </strong>= 1;<br><br>  @override<br>  GetService read(BinaryReader reader) {<br>    <strong>final </strong>numOfFields = reader.readByte();<br>    <strong>final </strong>fields = &lt;int, <strong>dynamic</strong>&gt;{<br>      <strong>for </strong>(int i = 0; i &lt; numOfFields; i++) reader.readByte(): reader.read(),<br>    };<br>    <strong>return </strong>GetService(<br>      name: fields[0] <strong>as </strong>String,<br>      status: fields[2] <strong>as </strong>String,<br>      lastname: fields[1] <strong>as </strong>String,<br>    );<br>  }<br><br>  @override<br>  <strong>void </strong>write(BinaryWriter writer, GetService obj) {<br>    writer<br>      ..writeByte(3)<br>      ..writeByte(0)<br>      ..write(obj.<strong>name</strong>)<br>      ..writeByte(1)<br>      ..write(obj.<strong>lastname</strong>)<br>      ..writeByte(2)<br>      ..write(obj.<strong>status</strong>);<br>  }<br><br>  @override<br>  int <strong>get hashCode </strong>=&gt; <strong>typeId</strong>.<strong>hashCode</strong>;<br><br>  @override<br>  bool <strong>operator </strong>==(Object other) =&gt;<br>      identical(<strong>this</strong>, other) ||<br>      other <strong>is </strong>ServiceAdapter &amp;&amp;<br>          <strong>runtimeType </strong>== other.<strong>runtimeType </strong>&amp;&amp;<br>          <strong>typeId </strong>== other.<strong>typeId</strong>;<br>}</pre><p><strong>feedscreen.dart:</strong></p><pre><strong>await </strong>Hive.openBox&lt;GetService&gt;(<strong>&#39;service&#39;</strong>);</pre><p>when we start to store data in hive. we need to open Hive Box. here ‘service’ is name of box.It is case-insensitive.</p><pre><strong>class </strong>_FeedScreenState <strong>extends </strong>State&lt;FeedScreen&gt; {<br>  int <strong>listLenght </strong>= 0;<br><br>  @override<br>  <strong>void </strong>initState(){<br>    hiveopen();<br>  }<br><br>  hiveopen() <strong>async </strong>{<br>     box = <strong>await </strong>Hive.openBox&lt;GetService&gt;(<strong>&#39;service&#39;</strong>);<br><br>    setState(() {<br>      ListServiceItems = box.values.toList();<br>    });<em><br>  </em>}<br><br>  putalldata(RequestProps props) <strong>async </strong>{<br>     box = <strong>await </strong>Hive.openBox&lt;GetService&gt;(<strong>&#39;service&#39;</strong>); <em>//open box</em><br>    box.clear();  //<em>clear all values in Hive</em><br>    <strong>for</strong>(int i=0; i&lt;<strong>listLenght</strong>; i++) {<br>  GetService adddata = <strong>new </strong>GetService(<br>      name: props.<strong>feedsuccess</strong>!.<strong>success</strong>![i].<strong>waiterId</strong>!.<strong>firstName</strong>.toString(),<br>      status: props.<strong>feedsuccess</strong>!.<strong>success</strong>![i].<strong>status</strong>.toString(),<br>      lastname: props.<strong>feedsuccess</strong>!.<strong>success</strong>![i].<strong>waiterId</strong>!.<strong>lastName</strong>.toString());<br>      box.add(adddata); // <em>add data from hive</em><br>}<br>    setState(() {<br>      ListServiceItems = box.values.toList(); //<em>get values from Hive</em><br>    });<em><br>  </em>}<br><br>  <strong>var data </strong>= {<br>    <strong>&quot;userId&quot;</strong>:userid.toString()<br>  };<br><br>   <strong>void </strong>handleInitialBuild(RequestProps props) {<br>    <em>props.feedsuccessapi(&quot;&quot;);<br>   </em>}<br><br>  @override<br>  Widget build(BuildContext context) {<br>    <strong>return </strong>StoreConnector&lt;AppState, RequestProps&gt;(<br>    converter: (store) =&gt; mapStateToProps(store),<br>    onInitialBuild: (props) =&gt; <strong>this</strong>.handleInitialBuild(props),<br>    builder: (context, props) {<br>      Widget ? body;<br><br>    <strong>if </strong>(props.<strong>loading </strong>== <strong>true</strong>) {<br>        body = Center(<br>        child: CircularProgressIndicator(),<br>        );<br>    }<br><br>    <strong>else if</strong>(props.<strong>feedsuccess </strong>!= <strong>null</strong>) {<em><br>       </em><strong>listLenght </strong>=  props.<strong>feedsuccess</strong>!.<strong>success</strong>!.<strong>length</strong>;<br>       Timer(Duration(milliseconds: 100), () {<br>         putalldata(props);<br>       });<em><br>    </em>}<br><br>    <strong>else if</strong>(props.<strong>error </strong>!= <strong>null</strong>){<br>       print(<strong>&quot;error&quot;</strong>);<br>    }<br><br>    <strong>return </strong>Scaffold(<br>        appBar: AppBar(<br>        title: Text(<strong>&#39;Home page&#39;</strong>),<em><br>    </em>),<br><br>      body:<br>    ListView.builder(<br>    itemCount: ListServiceItems.<strong>length</strong>,<br>    itemBuilder: (context, position) {<br>      GetService getdeatils = ListServiceItems[position];<br>      <strong>var </strong>name = getdeatils.<strong>name</strong>;<br>      <strong>var </strong>status = getdeatils.<strong>status</strong>;<br>      <strong>var </strong>lastname = getdeatils.<strong>lastname</strong>;<br>      <strong>return </strong>Card(<br>          child: Container(<br>          padding: EdgeInsets.all(7),<br>        child: Column(<br>          crossAxisAlignment: CrossAxisAlignment.<strong>center</strong>,<br>          children: [<br>            Text( <strong>&quot;USER NAME : &quot;</strong>+name + <strong>&quot; &quot;</strong>+ lastname, style: TextStyle(fontSize: 18, fontWeight: FontWeight.<em>bold</em>),),<br>            SizedBox(height: 10,),<br>            Text(<strong>&quot;STATUS MESSAGE : &quot;</strong>+ status),<em><br>          </em>],<br>        )<br>          )<br>      );<br>    })<em><br><br>    </em>);<br>    });<br>  }<br>}</pre><h3>Crud Operations:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*z-ZXMaMx0xvkJa4ICw3tMQ.gif" /><figcaption>Create Read Update Delete</figcaption></figure><p>Add the Icon button in<em> </em><strong><em>feedscreen.dart . </em></strong>When user click Add button and edit button open AddandUpdate screen and pass the required parameter values.</p><pre>IconButton(<br>  icon: Icon(Icons.<em>add</em>),<br>  onPressed: () {<br>    Navigator.<em>push</em>(context, MaterialPageRoute(builder: (_) =&gt; UpdateData( getServicemodel: <strong>null</strong>, position: -1, isEdit:<strong>false</strong>,)));<br>  },<br>)</pre><pre>IconButton(<br>    icon: Icon(Icons.<em>edit</em>,color: Colors.<em>blue</em>,),<br>    onPressed: () {<br>      Navigator.<em>push</em>(<br>          context,<br>          MaterialPageRoute(<br>              builder: (_) =&gt; UpdateData(<br>                    isEdit: <strong>true</strong>,position: position, getServicemodel:getdeatils,)));<br>    }),</pre><p>ADD/Update Screen:</p><p>Here, we open the box and then use the add() method to append the data to our box. you can also use the put() method, the difference is with put() you have to specify the key for each value - box.put(&#39;key&#39;, item), but add() just gives each value an index and auto increments it.</p><p>Read data from Hive:</p><ul><li>box.get(&#39;key) - get the value from a key.</li><li>box.getAt(index) - get the value from an index created with box.add().</li><li>box.values - this returns an iterable containing all the items in the box.</li></ul><p><strong>Updatedate.dart:</strong></p><pre><strong>class </strong>UpdateData <strong>extends </strong>StatefulWidget {<br>  bool <strong>isEdit</strong>;<br>  int <strong>position </strong>= -1;<br>  GetService? <strong>getServicemodel </strong>= <strong>null</strong>;<br>  UpdateData( {Key? key, <strong>required this</strong>.<strong>isEdit</strong>,<strong>required this</strong>.<strong>position</strong>, <strong>required this</strong>.<strong>getServicemodel</strong>}) : <strong>super</strong>(key: key);<br><br>  @override<br>  _UpdateDataState createState() =&gt; _UpdateDataState();<br>}<br><br><strong>class </strong>_UpdateDataState <strong>extends </strong>State&lt;UpdateData&gt; {<br>  <strong>var firstNameController </strong>=  TextEditingController();<br>  <strong>var lastNameController </strong>=  TextEditingController();<br>  <strong>var statusController </strong>=  TextEditingController();<br><br>  @override<br>  Widget build(BuildContext context) {<br>    <strong>if </strong>(<strong>widget</strong>.<strong>isEdit</strong>) {<br>      <strong>firstNameController</strong>.<strong>text </strong>= <strong>widget</strong>.<strong>getServicemodel</strong>!.<strong>name</strong>;<br>      <strong>lastNameController</strong>.<strong>text </strong>= <strong>widget</strong>.<strong>getServicemodel</strong>!.<strong>lastname</strong>;<br>      <strong>statusController</strong>.<strong>text </strong>= <strong>widget</strong>.<strong>getServicemodel</strong>!.<strong>status</strong>;<br>    }<br><br>    <strong>return </strong>Scaffold(<br>        appBar: AppBar(<br>        title: Text(<strong>&#39;ADD and Update&#39;</strong>)),<br>      body: SafeArea(<br>        child: Padding(<br>          padding: <strong>const </strong>EdgeInsets.all(8.0),<br>          child: Column(<br>            children: [<br>              SizedBox(height: 30),<br>              Row(<br>                children: [<br>                  Text(<strong>&quot;FIRSTNAME :&quot;</strong>, style: TextStyle(fontSize: 18, color:  Colors.<em>black</em>)),<br>                  SizedBox(width: 20),<br>                  Expanded(<br>                    child:<br>                  TextField(controller: <strong>firstNameController</strong>,<br>                    textInputAction: TextInputAction.<strong>next</strong>,<br>                  )),<br>                ],<br>              ),<br>              Row(<br>                children: [<br>                  Text(<strong>&quot;LASTNAME :&quot;</strong>, style: TextStyle(fontSize: 18,color:  Colors.<em>black</em>)),<br>                  SizedBox(width: 20),<br>                  Expanded(<br>                    child:<br>                  TextField(controller: <strong>lastNameController</strong>,<br>                    textInputAction: TextInputAction.<strong>next</strong>,<br>                  )),<br>                ],<br>              ),<br>              Row(<br>                children: [<br>                  Text(<strong>&quot;STATUS    :&quot;</strong>,style: TextStyle(fontSize: 18,color:  Colors.<em>black</em>)),<br>                  SizedBox(width: 40),<br>                  Expanded(<br>                    child:<br>                  TextField(controller: <strong>statusController</strong>,<br>                    textInputAction: TextInputAction.<strong>next</strong>,<br>                  )),<br>                ],<br>              ),<br>                 SizedBox(height: 20,),<br>              MaterialButton(<br>                color: Colors.<em>blue</em>,<br>                child: Text(<strong>&quot;SAVE&quot;</strong>,<br>                    style: TextStyle(color: Colors.<em>white</em>, fontSize: 18, )),<br>                onPressed: () <strong>async </strong>{<br>                  <strong>var </strong>firstName = <strong>firstNameController</strong>.<strong>text</strong>;<br>                  <strong>var </strong>lastName = <strong>lastNameController</strong>.<strong>text</strong>;<br>                  <strong>var </strong>status = <strong>statusController</strong>.<strong>text</strong>;<br>                  <strong>if </strong>(firstName.<strong>isNotEmpty </strong>&amp;<br>                  lastName.<strong>isNotEmpty </strong>&amp;<br>                  status.<strong>isNotEmpty</strong>) {<br>                    GetService updatedata = <strong>new </strong>GetService(<br>                        name: firstName,<br>                        lastname: lastName,<br>                        status: status);<br><br>                     <strong>if </strong>(<strong>widget</strong>.<strong>isEdit</strong>) {<br>                     <strong>var </strong>box = <strong>await </strong>Hive.openBox&lt;GetService&gt;(<strong>&#39;service&#39;</strong>);<br>                       box.putAt(<strong>widget</strong>.<strong>position</strong>, updatedata);<br>                    } <strong>else </strong>{<br>                      <strong>var </strong>box = <strong>await </strong>Hive.openBox&lt;GetService&gt;(<strong>&#39;service&#39;</strong>);<br>                      box.add(updatedata);<br>                    }<br>                    Navigator.<em>pushAndRemoveUntil</em>(<br>                        context,<br>                        MaterialPageRoute(<br>                            builder: (_) =&gt; FeedScreen()),<br>                            (r) =&gt; <strong>false</strong>);<br>                 }<br>                },<br>              )<br>            ],<br>          ),<br>        ),<br>      ),<br>    );<br>  }<br>}</pre><p>Delete:</p><ul><li>box.delete(&#39;key) - get the value from a key.</li><li>box.deleteAt(index) - get the value from an index created with box.add().</li><li>box.deleteAll(keys) - accepts an iterable of keys, and deletes all the keys given.</li></ul><pre>IconButton(<br>    icon: Icon(Icons.<em>delete</em>,color: Colors.<em>red</em>,),<br>    onPressed: (){<br>      <strong>final </strong>box = Hive.box&lt;GetService&gt;(<strong>&#39;service&#39;</strong>);<br>      box.deleteAt(position);<br>      setState(() =&gt; {<br>        ListServiceItems.removeAt(position)<br>      });<br>    })</pre><p><strong>Demo video for online and offline mode:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/352/1*xEimmkfYBNzylRqjCTRMxA.gif" /><figcaption>Offline Mode and Online Mode</figcaption></figure><p>Hope this blog may helpful to you. Thankyou!! 🤗</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a22cdfaa259e" width="1" height="1" alt=""><hr><p><a href="https://techmusings.optisolbusiness.com/flutter-offline-storage-using-hive-database-a22cdfaa259e">Flutter Offline Storage Using HIVE database</a> was originally published in <a href="https://techmusings.optisolbusiness.com/">Tech Musings</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter Redux-State management with Redux in Flutter]]></title>
            <link>https://medium.com/@rajeswari3699/flutter-redux-state-management-with-redux-in-flutter-7a6a13515f69?source=rss-d91f619ffaf5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a6a13515f69</guid>
            <category><![CDATA[flutter-redux]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[flutter-state-management]]></category>
            <dc:creator><![CDATA[Rajeswari S]]></dc:creator>
            <pubDate>Mon, 23 Aug 2021 13:45:25 GMT</pubDate>
            <atom:updated>2021-08-23T13:45:25.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZE4SOs0U2JpL5Rpu6D0EpQ.jpeg" /></figure><p>In the following article, we’ll be focusing on Flutter app and use Redux to manage the state of our app. Redux is a unidirectional data flow architecture that makes it easy to develop, maintain and test applications.</p><h3>Redux Setup:</h3><h4>Install Packages:</h4><p>Now we’ll add the Redux dependencies to our app with the latest version of package and add them to the<em> </em><strong><em>pubspec.yaml</em></strong> file.</p><pre><strong>redux</strong>: ^5.0.0</pre><pre><strong>flutter_redux</strong>: ^0.8.2</pre><pre><strong>redux_thunk</strong>: ^0.4.0</pre><h4>Redux Elements:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*1lsy6U2vjEhZH7oxy365Nw.png" /><figcaption>The Redux components</figcaption></figure><p>we can See the brief explanation of each component in following with example code. Now we move to create modal class.We are taking example of login module with our flutter app. First we need to create login_model.dart</p><h4>Model:</h4><p>Here is our login model: login_model.dart</p><pre><strong>class </strong>Loginmodel {<br>  String <strong>token</strong>;<br><br>  Loginmodel({<strong>this</strong>.<strong>token</strong>});<br><br>  Loginmodel.fromJson(Map&lt;String, <strong>dynamic</strong>&gt; json) {<br>    <strong>token </strong>= json[<strong>&#39;token&#39;</strong>];<br>  }<br><br>  Map&lt;String, <strong>dynamic</strong>&gt; toJson() {<br>    <strong>final </strong>Map&lt;String, <strong>dynamic</strong>&gt; data = <strong>new </strong>Map&lt;String, <strong>dynamic</strong>&gt;();<br>    data[<strong>&#39;token&#39;</strong>] = <strong>this</strong>.<strong>token</strong>;<br>    <strong>return </strong>data;<br>  }<br>}</pre><h4>State:</h4><p>We would like to store the user data after a successful login and also we would like to present a loading indicator if an API call is in progress. Also, we’d like to display error message if an error happened. We have to compose the stored objects to match those requirements.</p><p>login_state.dart</p><pre><strong>class </strong>LoginState {<br>  bool <strong>loading</strong>;<br>  <strong>dynamic error</strong>;<br>  Loginmodel <strong>success</strong>;<br><br>  LoginState({<br>    <strong>this</strong>.<strong>loading</strong>,<br>    <strong>this</strong>.<strong>error</strong>,<br>    <strong>this</strong>.<strong>success</strong>,<br><br>});<br>  <strong>factory </strong>LoginState.initial() =&gt; LoginState(<br>         loading: <strong>false</strong>,<br>         error: <strong>null</strong>,<br>         success: <strong>null</strong>,<br><br>  );<br>}</pre><p>we’ll create AppState this is our main state object, the one that holds entire applications state.</p><pre><strong>class </strong>AppState {</pre><pre><strong>final </strong>LoginState <strong>login</strong>;</pre><pre>AppState({<strong>this</strong>.<strong>login</strong>,});</pre><pre><strong>factory </strong>AppState.initial() =&gt; AppState(login: LoginState.initial());</pre><pre>AppState copyWith({LoginState login,}) {</pre><pre><strong>return </strong>AppState(<br>login:login ?? <strong>this</strong>.<strong>login</strong>, );<br>}<br>}</pre><h4>Reducer:</h4><p>Reducers are responsible for generating the next global state of the application by transforming the information received from the actions and setting the related values in the store.A function that receives previous State and an action containing the next State, this is where we use our copyWith method what it does is that it’s a method that receives all State fields and returns a newState.</p><p>login_reducer.dart</p><pre>LoginState loginReducer(LoginState state, <strong>dynamic </strong>action) {<br>  LoginState newState = state;<br><br>  <strong>switch </strong>(action.type) {<br><br>    <strong>case </strong>LOGIN_REQUEST:<br>      newState.<strong>error </strong>= <strong>null</strong>;<br>      newState.<strong>loading </strong>= <strong>true</strong>;<br>      newState.<strong>success </strong>= <strong>null</strong>;<br>      <strong>return </strong>newState;<br><br>    <strong>case </strong>LOGIN_SUCCESS:<br>      newState.<strong>error </strong>= <strong>null</strong>;<br>      newState.<strong>loading </strong>= <strong>false</strong>;<br>      newState.<strong>success </strong>= Loginmodel.fromJson(action.payload);<br>      <strong>return </strong>newState;<br><br>    <strong>case </strong>LOGIN_FAILURE:<br>      newState.<strong>error </strong>= action.error;<br>      newState.<strong>loading </strong>= <strong>false</strong>;<br>      newState.<strong>success </strong>= <strong>null</strong>;<br>      <strong>return </strong>newState;<br>  }<br>}</pre><pre><strong>const </strong>LOGIN_REQUEST = <strong>&#39;LOGIN_REQUEST&#39;</strong>;<br><strong>const </strong>LOGIN_SUCCESS = <strong>&#39;LOGIN_SUCCESS&#39;</strong>;<br><strong>const </strong>LOGIN_FAILURE = <strong>&#39;LOGIN_FAILURE&#39;</strong>;</pre><p>The root reducer combines all the reducers that build different pieces of state. It’s also called app reducer.</p><pre>AppState appReducer(AppState state, action) {<br>  <strong>return </strong>AppState(<br>    login: loginReducer(state.<strong>login</strong>, action),<br>);<br>}</pre><h4>Action:</h4><p>Now, that we have successfully configured the store, we can start integrating the actions to initiate changes in the global state.</p><p>Actions are generated by application events and carry the information which will be consumed by the reducers. For example, if the user presses the login button we should fire an action to start the login API call and present the loading indicator.</p><p>login_action.dart</p><pre>ThunkAction&lt;AppState&gt; login(data) =&gt; (Store&lt;AppState&gt; store) =&gt;<br>    postApi(<br>        loginApiurl,<br>        data,<br>        [<br>          LOGIN_REQUEST,<br>          LOGIN_SUCCESS,<br>          LOGIN_FAILURE,<br>        ],<br>        store<br>    );</pre><p>Redux Thunk is a redux middleware that helps you to dispatch functions as actions, under the hood it does one job, check that if passed action is a function then call it and pass the store.</p><pre>postApi(url, params, List&lt;String&gt; type, store) <strong>async </strong>{<br>  <strong>var </strong>urlValue = BASE_URL + url;<br>  Response response;<br>      response = <strong>await </strong>dio.post(<br>          urlValue,<br>          data: params,<br>          options: Options(<br>              headers: {<br>                headerAuth: headerAuthToken,<br>              },<br>              validateStatus: (status) { <strong>return </strong>status &lt; 500; }<br>          )<br>      );<br>      <strong>if </strong>(response.<strong>statusCode </strong>== 200) {<br>        store.dispatch(ResponseModal.responseResult(response, type[1]));<br>      }<br>      <strong>else </strong>{<br>        store.dispatch(ResponseModal.responseResult(response, type[2]));<br>      }<br>}</pre><pre><strong>class </strong>ResponseModal {<br>  <strong>final </strong>String <strong>type</strong>;<br>  <strong>dynamic payload</strong>;<br>  <strong>dynamic statuscode</strong>;<br>  <strong>dynamic error</strong>;<br><br>  ResponseModal({<br>    <strong>this</strong>.<strong>type</strong>,<br>    <strong>this</strong>.<strong>payload</strong>,<br>    <strong>this</strong>.<strong>statuscode</strong>,<br>    <strong>this</strong>.<strong>error<br>  </strong>});<br><br>  ResponseModal.responseResult(result, <strong>this</strong>.<strong>type</strong>) {<br>    <strong>if </strong>(result != <strong>null</strong>) {<br>      <strong>if </strong>(result <strong>is </strong>String) {<br>        <strong>payload </strong>= result;<br>        <strong>statuscode </strong>= <strong>null</strong>;<br>        <strong>error </strong>=result;<em><br>      </em>} <strong>else if </strong>(result <strong>is </strong>Response) {<br>        <strong>if </strong>(result.<strong>statusCode </strong>== 200) {<br>          <strong>payload </strong>= result.<strong>data</strong>;<br>          <strong>statuscode </strong>= result.<strong>statusCode</strong>;<br>          <strong>error </strong>= <strong>false</strong>;<br>        } <strong>else </strong>{<br>          <strong>payload </strong>= result.<strong>data</strong>[<strong>&#39;error_msg&#39;</strong>].toString();<br>          <strong>statuscode </strong>= result.<strong>statusCode</strong>;<br>          <strong>error </strong>= result.<strong>statusMessage</strong>;<br>        }<br>      }<br>    } <strong>else </strong>{<br>      <strong>payload </strong>= <strong>null</strong>;<br>      <strong>statuscode </strong>= <strong>null</strong>;<br>      <strong>error </strong>= <strong>null</strong>;<br>    }<br>  }<br>}</pre><h4>Middleware:</h4><p>If we’d like to create separate layers for data handling we should use middleware. This way we are able to intercept actions and transform the information from their payload before it reaches the reducers.</p><pre><strong>void </strong>apiMiddleware(Store&lt;AppState&gt; store, <strong>dynamic </strong>action, NextDispatcher next) {<br>  Timer _timer;<br>  CancelToken _token;<br>  _timer?.cancel();<br>  _token?.cancel(<strong>&quot;cancelled&quot;</strong>);<br>  _timer = <strong>new </strong>Timer(<strong>new </strong>Duration(milliseconds: 250), () {<br>    _token = <strong>new </strong>CancelToken();<br>  });<br>  next(action);<br>}</pre><h4>Components:</h4><p>This is the last part where we initialize our store and consume data to render our result.Components form all the visible elements on the UI and users are able to interact with them. They can be connected to our Redux store and present their current values in the UI. Flutter Redux provides a convenient way to do so by using the <strong><em>StoreConnector </em></strong>class.</p><p><strong><em>converter</em></strong>: specifying the converter method, we will be able to observe parts of the whole Redux store and filter the component related variables. It’s important to implement this method if we would like to avoid updating our component every time something changes in the store which can lead to performance issues.</p><p><strong><em>builder</em></strong>: the collected properties from the converter method are passed to the builder which composes the Widget component based on those values.</p><p>login.dart</p><pre>StoreConnector&lt;AppState, LoginScreenProps&gt;(<br>    converter: (store) =&gt; mapStateToProps(store),<br>    builder: (context, props) {<br>          //...... type your code<br>          props.loginapi(data); // call api by passing data</pre><pre>}<br>);<br></pre><pre><strong><br>class </strong>LoginScreenProps {<br>  <strong>final </strong>bool <strong>loading</strong>;<br>  <strong>final dynamic error</strong>;<br>  <strong>final </strong>Loginmodel <strong>success</strong>;<br>  <strong>final </strong>Function <strong>loginapi</strong>;<br><br>  LoginScreenProps({<br>    <strong>this</strong>.<strong>loading</strong>,<br>    <strong>this</strong>.<strong>error</strong>,<br>    <strong>this</strong>.<strong>success</strong>,<br>    <strong>this</strong>.<strong>loginapi</strong>,<br>  });<br>}<br>  LoginScreenProps mapStateToProps(Store&lt;AppState&gt; store) {<br>    <strong>return </strong>LoginScreenProps(<br>      loading: store.<strong>state</strong>.<strong>login</strong>.<strong>loading</strong>,<br>      error: store.<strong>state</strong>.<strong>login</strong>.<strong>error</strong>,<br>      success: store.<strong>state</strong>.<strong>login</strong>.<strong>success</strong>,<br>      loginapi: (data) =&gt; store.dispatch(login(data)),<br>    );<br>  }</pre><p>Thanks for reading this article…All the best</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a6a13515f69" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>