<?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 Rajesh muthyala on Medium]]></title>
        <description><![CDATA[Stories by Rajesh muthyala on Medium]]></description>
        <link>https://medium.com/@rajesh.muthyala?source=rss-44721f9dd99d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SH2fSm1rFKHrrRwd.jpg</url>
            <title>Stories by Rajesh muthyala on Medium</title>
            <link>https://medium.com/@rajesh.muthyala?source=rss-44721f9dd99d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 18:06:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rajesh.muthyala/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 with Google Maps and Google Place]]></title>
            <link>https://medium.com/@rajesh.muthyala/flutter-with-google-maps-and-google-place-85ccee3f0371?source=rss-44721f9dd99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/85ccee3f0371</guid>
            <category><![CDATA[nearby-api]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[google-places-api]]></category>
            <category><![CDATA[google-maps-api]]></category>
            <dc:creator><![CDATA[Rajesh muthyala]]></dc:creator>
            <pubDate>Mon, 24 Jun 2019 11:18:29 GMT</pubDate>
            <atom:updated>2019-06-24T11:18:29.147Z</atom:updated>
            <content:encoded><![CDATA[<h3>Get an API Key to use Google features</h3><p>To use the Maps SDK for Android you must have an API key. The API key is a unique identifier that is used to authenticate requests associated with your project for usage and billing purposes.</p><h3>Get the API key</h3><p>You must have at least one API key associated with your project.</p><p>To get an API key:</p><ol><li>Go to the <a href="https://cloud.google.com/console/google/maps-apis/overview">Google Cloud Platform Console</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hRLhW0IcBqflza8Q8gw5Mw.png" /><figcaption>fig1.1 API screen for google</figcaption></figure><ol><li>From the Project drop-down menu, select or create the project for which you want to add an API key.</li><li>From the</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*Argqme2i-R7yZvVk.png" /><figcaption>Navigation menu, select <strong>APIs &amp; Services &gt; Credentials</strong>.</figcaption></figure><p>4. On the <strong>Credentials</strong> page, click <strong>Create credentials &gt; API key</strong>. <br>The <strong>API key created</strong> dialog displays your newly created API key (an encrypted string).</p><p><strong>4. Close.</strong> <br>The new API key is listed on the <strong>Credentials</strong> page under <strong>API keys</strong>. <br>(Remember to <a href="https://developers.google.com/maps/documentation/android-sdk/get-api-key#restrict_key">restrict the API key</a> before using it in production.</p><p>On the <strong>Restrict and rename API key</strong> page, set the restrictions:</p><ul><li>Application restrictions</li><li>Select <strong>Android apps</strong> and follow the instructions.</li><li>Click <strong>+ Add package name and fingerprint</strong>.</li><li>Enter your package name and SHA-1 certificate fingerprint. For example:</li><li>com.example.android.mapexample</li><li>BB:0D:AC:74:D3:21:E1:43:67:71:9B:62:91:AF:A1:66:6E:44:5D:75</li></ul><p>For more information, see <a href="https://developers.google.com/maps/documentation/android-sdk/get-api-key#fingerprint">Where to get your app’s SHA-1 fingerprint</a>).</p><ul><li>API restrictions</li><li>Select <strong>Restrict key</strong>.</li><li>Click <strong>Select APIs</strong> and select <strong>Maps SDK for Android</strong>. <br>(If there are other enabled APIs you want to use with this key, select them as well.)</li><li>Click <strong>SAVE</strong>.</li></ul><p>please refer the link given below for complete google API documentation</p><p><a href="https://developers.google.com/maps/documentation/android-sdk/get-api-key#restrict_key">Get an API Key | Maps SDK for Android | Google Developers</a></p><h3>Adding the API key to Flutter App</h3><p>The first step is to add the Google Maps Flutter plugin as a dependency in the <strong>pubspec.yaml</strong> file. The package is available as <a href="https://pub.dartlang.org/packages/google_maps_flutter">google_maps_flutter</a> on <a href="https://pub.dartlang.org/">pub.dartlang.org</a>.</p><p>dependencies:</p><p>google_maps_flutter: ^0.4.0</p><p>Once you do that, you need to run <strong>flutter packages get</strong>.</p><p>The next step is getting an API key for both Android and iOS. For Android, follow the instructions at <a href="https://developers.google.com/maps/documentation/android-sdk/signup">Maps SDK for Android — Get API Key</a>. Once you have your API key, add it to your Flutter app in the application manifest (<a href="https://gist.github.com/kenzieschmoll/21ee5723ce83fb0675dcde202fbd6dca">android/app/src/main/AndroidManifest.xml</a>), as follows:</p><p>&lt;manifest … &lt;application … &lt;meta-data android:name=”com.google.android.geo.API_KEY” android:value=” YOUR ANDROID API KEY HERE”/&gt;</p><h4>For iOS, follow the instructions at <a href="https://developers.google.com/maps/documentation/ios-sdk/get-api-key">Maps SDK for iOS — Get API Key</a>. Once you have this key, add it to your Flutter app in the application delegate (<a href="https://gist.github.com/kenzieschmoll/15aee1e8e3fbab3ba25a6a3c9425bbfb">ios/Runner/AppDelegate.m</a>):</h4><p>#include “AppDelegate.h”<br>#include “GeneratedPluginRegistrant.h”<br>// Add the GoogleMaps import.<br>#import “GoogleMaps/GoogleMaps.h”</p><p><a href="http://twitter.com/implementation">@implementation</a> AppDelegate</p><ul><li>(BOOL)application:(UIApplication *)application<br> didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {<br> // Add the following line with your API key.<br> [GMSServices provideAPIKey:@”YOUR IOS API KEY HERE”];<br> [GeneratedPluginRegistrant registerWithRegistry:self];<br> return [super application:application didFinishLaunchingWithOptions:launchOptions];<br>}<br><a href="http://twitter.com/end">@end</a></li><li>On iOS, you also need to add a setting to the app’s Info.plist file (ios/Runner/Info.plist). <br>These entry forces Flutter on iOS into a single threaded mode,<br> which is required for the platform view embedding to work. <br>This technical restriction is being worked on and will be lifted before Google Maps moves out of Developer Preview.</li><li>Add a boolean property with the key io.flutter.embedded_views_preview and the value true:</li><li>&lt;key&gt;io.flutter.embedded_views_preview&lt;/key&gt;&lt;true/&gt;</li></ul><p>Top Google API’s for Location:-</p><h3>1. google_maps_flutter 0.5.19</h3><h3>2. geolocator 5.0.1</h3><h3>3. flutter_google_places 0.2.3</h3><p>Google_maps_flutter 0.5.19</p><h3>Setup</h3><p>The first step is to add the Google Maps Flutter plugin as a dependency in the <strong>pubspec.yaml</strong> file. The package is available as <a href="https://pub.dartlang.org/packages/google_maps_flutter">google_maps_flutter</a> on <a href="https://pub.dartlang.org/">pub.dartlang.org</a>.</p><h4>Use this package as a library</h4><h4>1. Depend on it</h4><p>Add this to your package’s pubspec.yaml file:</p><p>dependencies:</p><p><strong>google_maps_flutter: ^0.5.19</strong></p><ul><li>README.md</li><li>CHANGELOG.md</li><li>Example</li><li>Installing</li><li>Versions</li><li>99</li></ul><h3>Use this package as a library</h3><h3>1. Depend on it</h3><p>Add this to your package’s pubspec.yaml file:</p><pre>dependencies:<br>  <strong>google_maps_flutter: ^0.5.19</strong></pre><h3>2. Install it</h3><p>You can install packages from the command line:</p><p>with Flutter:</p><p><strong>flutter pub get</strong></p><p>Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.</p><h3>3. Import it</h3><p>Now in your Dart code, you can use:</p><p><strong>import</strong> ‘package:google_maps_flutter/google_maps_flutter.dart’;</p><h3>Adding a Google map widget</h3><p>Now you are ready to add a google map widget! Run <strong>flutter clean</strong> to make sure the API key changes are picked up on the next build. Then, add a google map widget that covers the entire screen:</p><p>import ‘dart:async’;</p><p>import ‘package:flutter/material.dart’;<br>import ‘package:google_maps_flutter/google_maps_flutter.dart’;</p><p>void main() =&gt; runApp(MyApp());</p><p>class MyApp extends StatefulWidget {<br> <a href="http://twitter.com/override">@override</a><br> _MyAppState createState() =&gt; _MyAppState();<br>}</p><p>class _MyAppState extends State&lt;MyApp&gt; {<br> Completer&lt;GoogleMapController&gt; _controller = Completer();</p><p>static const LatLng _center = const LatLng(45.521563, -122.677433);</p><p>void _onMapCreated(GoogleMapController controller) {<br> _controller.complete(controller);<br> }</p><p><a href="http://twitter.com/override">@override</a><br> Widget build(BuildContext context) {<br> return MaterialApp(<br> home: Scaffold(<br> appBar: AppBar(<br> title: Text(‘Maps Sample App’),<br> backgroundColor: Colors.green[700],<br> ),<br> body: GoogleMap(<br> onMapCreated: _onMapCreated,<br> initialCameraPosition: CameraPosition(<br> target: _center,<br> zoom: 11.0,<br> ),<br> ),<br> ),<br> );<br> }<br>}</p><p>Important bits:</p><ul><li><strong>onMapCreated</strong>: method that is called on map creation and takes a MapController as a parameter.</li><li><strong>initialCameraPosition</strong>: required parameter that sets the starting camera position. Camera position describes which part of the world you want the map to point at.</li><li><strong>mapController</strong>: manages camera function (position, animation, zoom). This pattern is similar to other controllers available in Flutter, for example <a href="https://docs.flutter.io/flutter/widgets/TextEditingController-class.html">TextEditingController</a>.</li></ul><p>If you run your app at this point, it should look like this:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*HqQgh-AMZ4_xzutBC8oAYw.png" /><figcaption>Fig1.1 integrated map inside flutter</figcaption></figure><h3>What can you do with a Google Map?</h3><p>So now you have Google Maps in your app, but you probably want to do something more interesting. What about putting Flutter widgets on top of the map, changing the map’s appearance, or adding place markers to the map? You can do it all!</p><h4>Add a widget on top of the map</h4><p>It’s important to remember that the GoogleMap widget is just a Flutter widget, meaning you can treat it like any other widget. This includes placing another widget on top of it. By placing the GoogleMap widget inside of a Stack widget, you can layer other Flutter widgets on top of the map widget:</p><p>body: Stack(<br> children: &lt;Widget&gt;[<br> GoogleMap(<br> onMapCreated: _onMapCreated,<br> initialCameraPosition: CameraPosition(<br> target: _center,<br> zoom: 11.0,<br> ),<br> ),<br> Padding(<br> padding: const EdgeInsets.all(16.0),<br> child: Align(<br> alignment: Alignment.topRight,<br> child: FloatingActionButton(<br> onPressed: () =&gt; print(‘button pressed’),<br> materialTapTargetSize: MaterialTapTargetSize.padded,<br> backgroundColor: Colors.green,<br> child: const Icon(Icons.map, size: 36.0),<br> ),<br> ),<br> ),<br> ],<br>),</p><p>Now, add a method that will modify the value of _currentMapType inside of a setState() call. This will update the appearance of the map to match the new value of _currentMapType.</p><p>void _onMapTypeButtonPressed() {<br> setState(() {<br> _currentMapType = _currentMapType == MapType.normal<br> ? MapType.satellite<br> : MapType.normal;<br> });<br>}</p><h4>Add a marker</h4><p>How about creating another button that, when pressed, adds place markers to the map. Following the same pattern as before, add a button to the stack. Place another FloatingActionButton inside the Align widget from the build method. You’ll need to wrap both FloatingActionButtons in a Column widget:</p><p>FloatingActionButton(<br> onPressed: <strong>_onAddMarkerButtonPressed,</strong><br> materialTapTargetSize: MaterialTapTargetSize.padded,<br> backgroundColor: Colors.green,<br> child: const Icon(Icons.add_location, size: 36.0),<br> ),</p><p>To implement the _onAddMarkerButtonPressed method, we need to do a couple things. First, create a variable called _markers to store the map’s markers. Set this as the markers property of the GoogleMap widget.</p><p>final Set&lt;Marker&gt; _markers = {};</p><p>@override</p><p>Widget build(BuildContext context) {</p><p>return MaterialApp(</p><p>… GoogleMap(</p><p>… <strong>markers: _markers,</strong></p><p>)</p><p>);</p><p>}</p><p>To add a marker in the center of the map, we need to track the map’s current camera position. Add the following code to do that:</p><p>LatLng _lastMapPosition = _center;</p><p>void _onCameraMove(CameraPosition position) {<br> _lastMapPosition = position.target;<br>}</p><p><a href="http://twitter.com/override">@override</a><br>Widget build(BuildContext context) {<br> return MaterialApp(<br> …<br> GoogleMap(<br> …<br> onCameraMove: _onCameraMove,<br> ),<br> );<br>}</p><p>Now, we can add a marker to the map by modifying the content of _markersinside of a setState() call.</p><p>void _onAddMarkerButtonPressed() {<br> setState(() {<br> _markers.add(Marker(<br> // This marker id can be anything that uniquely identifies each marker.<br> markerId: MarkerId(_lastMapPosition.toString()),<br> position: _lastMapPosition,<br> infoWindow: InfoWindow(<br> title: ‘Really cool place’,<br> snippet: ‘5 Star Rating’,<br> ),<br> icon: BitmapDescriptor.defaultMarker,<br> ));<br> });<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/293/1*teqvmEdnSld2NLeOwdPlrw.png" /><figcaption>fig 1.2 with markers</figcaption></figure><h3>2. geolocator 5.0.1</h3><h3>Features <a href="https://pub.dev/packages/geolocator#features">#</a></h3><ul><li>Get the current location of the device;</li><li>Get the last known location;</li><li>Get continuous location updates;</li><li>Check if location services are enabled on the device;</li><li>Translate an address to geocoordinates and vice verse (a.k.a. Geocoding);</li><li>Calculate the distance (in meters) between two geocoordinates;</li><li>Check the availability of Google Play services (on Android only).</li></ul><h3>Usage <a href="https://pub.dev/packages/geolocator#usage">#</a></h3><p>To use this plugin, add geolocator as a <a href="https://flutter.io/platform-plugins/">dependency in your pubspec.yaml file</a>. For example:</p><pre>dependencies:<br>  geolocator: &#39;^5.0.0&#39;</pre><h3>API <a href="https://pub.dev/packages/geolocator#api">#</a></h3><h3>Geolocation <a href="https://pub.dev/packages/geolocator#geolocation">#</a></h3><p>To query the current location of the device simply make a call to the getCurrentPositionmethod:</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>Position position = <strong>await</strong> Geolocator().getCurrentPosition(desiredAccuracy: LocationAccuracy.high);</pre><p>To query the last known location retrieved stored on the device you can use them getLastKnownPosition method (note that this can result in a null value when no location details are available):</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>Position position = <strong>await</strong> Geolocator().getLastKnownPosition(desiredAccuracy: LocationAccuracy.high);</pre><p>To listen for location changes you can subscribe to the onPositionChanged stream. Supply an instance of the LocationOptions class to configure the desired accuracy and the minimum distance change (in meters) before updates are sent to the application.</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre><strong>var</strong> geolocator = Geolocator();<br><strong>var</strong> locationOptions = LocationOptions(accuracy: LocationAccuracy.high, distanceFilter: 10);</pre><pre>StreamSubscription&lt;Position&gt; positionStream = geolocator.getPositionStream(locationOptions).listen(<br>    (Position position) {<br>        print(position == <strong>null</strong> ? &#39;Unknown&#39; : position.latitude.toString() + &#39;, &#39; + position.longitude.toString());<br>    });</pre><p>To check if location services are enabled you can call the checkGeolocationPermissionStatusmethod. This method returns a value of the GeolocationStatus enum indicating the availability of the location services on the device. Optionally you can specify if you want to test for GeolocationPermission.locationAlways or GeolocationPermission.locationWhenInUse (by default GeolocationPermission.location is used, which checks for either one of the previously mentioned permissions). Example usage:</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>GeolocationStatus geolocationStatus  = <strong>await</strong> Geolocator().checkGeolocationPermissionStatus();</pre><p>By default Geolocator will use FusedLocationProviderClient on Android when Google Play Services are available. It will fall back to LocationManager when it is not available. You can override the behavior by setting forceAndroidLocationManager.</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>Geolocator geolocator = Geolocator()..forceAndroidLocationManager = <strong>true</strong>;<br>GeolocationStatus geolocationStatus  = <strong>await</strong> geolocator.checkGeolocationPermissionStatus();</pre><h3>Geocoding <a href="https://pub.dev/packages/geolocator#geocoding">#</a></h3><p>To translate an address into latitude and longitude coordinates you can use them placemarkFromAddress method:</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>List&lt;Placemark&gt; placemark = <strong>await</strong> Geolocator().placemarkFromAddress(&quot;Gronausestraat 710, Enschede&quot;);</pre><p>If you want to translate latitude and longitude coordinates into an address you can use them placemarkFromCoordinates method:</p><pre><strong>import</strong> &#39;package:geolocator/geolocator.dart&#39;;</pre><pre>List&lt;Placemark&gt; placemark = <strong>await</strong> Geolocator().placemarkFromCoordinates(52.2165157, 6.9437819);</pre><p>Both the placemarkFromAddress and placemarkFromCoordinates accept an optional localeIdentifier parameter. This parameter can be used to enforce the resulting placemark to be formatted (and translated) according to the specified locale. The localeIdentifiershould be formatted using the syntax: [languageCode]_[countryCode]. Use the <a href="http://www.loc.gov/standards/iso639-2/php/English_list.php">ISO 639-1 or ISO 639-2</a> standard for the language code and the 2 letter <a href="https://en.wikipedia.org/wiki/ISO_3166-1">ISO 3166-1</a> standard for the country code. Some examples are:</p><h3>Calculate distance <a href="https://pub.dev/packages/geolocator#calculate-distance">#</a></h3><p>To calculate the distance (in meters) between two geocoordinates you can use them distanceBetween method. The distanceBetween the method takes four parameters:</p><p>Parameter Type Description:-<br>startLatitude double Latitude of the start position<br>startLongitude double Longitude of the start position<br>endLatitude double Latitude of the destination position<br>endLongitude double Longitude of the destination position</p><p>import ‘package:geolocator/geolocator.dart’;</p><p>double distanceInMeters = await geolocator().distance between(52.2165157, 6.9437819, 52.3546274, 4.8285838);</p><h4>Setup</h4><p>The setup for this plugin is more or less the same as the location. If you plan to use coarse location as well, add</p><pre>&lt;<strong>uses-permission android:name=&quot;android.permission.ACCESS_COARSE_LOCATION&quot; </strong>/&gt;</pre><p>to AndroidManifest.xml .</p><p>First, we will do the same two tasks with this plugin, which is more or less the same:</p><h4>Get location once</h4><p>Use the Geolocator object instead of Location and instead of a Map&lt;String,double&gt; , we get back a Position object.</p><pre>Geolocator <strong>geolocator </strong>= Geolocator();</pre><pre>Position <strong>userLocation</strong>;</pre><p>And we do this to take location:</p><pre>currentLocation = <strong>await geolocator</strong>.getCurrentPosition(<br>    desiredAccuracy: LocationAccuracy.<strong>best</strong>);</pre><p>You can get all the details about the place as:</p><pre>print(placemark[0].<strong>country</strong>);<br>print(placemark[0].<strong>position</strong>);<br>print(placemark[0].<strong>locality</strong>);<br>print(placemark[0].<strong>administrativeArea</strong>);<br>print(placemark[0].<strong>postalCode</strong>);<br>print(placemark[0].<strong>name</strong>);<br>print(placemark[0].<strong>subAdministratieArea</strong>);<br>print(placemark[0].<strong>isoCountryCode</strong>);<br>print(placemark[0].<strong>subLocality</strong>);<br>print(placemark[0].<strong>subThoroughfare</strong>);<br>print(placemark[0].<strong>thoroughfare</strong>);</pre><p>We can also get the details of a place from the coordinates:</p><pre>List&lt;Placemark&gt; placemark = <strong>await </strong>Geolocator().placemarkFromCoordinates(52.2165157, 6.9437819);</pre><h4>Getting the distance between coordinates</h4><p>This plugin also allows us to <strong>calculate the distance between two coordinates </strong>as:</p><pre>double distanceInMeters = <strong>await </strong>Geolocator().distanceBetween(52.2165157, 6.9437819, 52.3546274, 4.8285838);</pre><h3>flutter_google_places 0.2.3</h3><p>Getting Started <a href="https://pub.dev/packages/flutter_google_places#getting-started">#</a></p><pre><em># pubspec.yaml</em></pre><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  flutter_google_places: &lt;last-version&gt;</pre><p>Flutter has just achieved its latest milestone with the release of stable 1.0 version. It has many amazing features that provide a foundation for an amazing future ahead as it matures. Here are several of the great features:</p><ul><li>PlatformView. Widget to render native platform views such as iOS UIView and Android View</li><li>MapView plugin. Widget to display Google Map View built on top of PlatformView API</li><li>Add to App: Tools to convert existing iOS and Android apps to Flutter in stages.</li><li>Flutter Desktop Embedding &amp; Hummingbird: An initiative to bring Flutter to Web &amp; Desktop.</li></ul><p>To celebrate the release of Flutter 1.0, we are going to build an app to display and search nearby places inside Map View using Google Map and Google Places API.</p><h3>Project Setup &amp; Import Dependencies</h3><p>First make sure you have upgraded your Flutter SDK to 1.0.0 using flutter upgrade command from your shell.</p><p>Create a new project using flutter create create command, open the project using Visual Studio Code or Android Studio.</p><p>Next, we will add dependencies inside the pubspec.yaml file. There are 3 dependencies we will use:</p><ul><li>google_maps_flutter: Official Google Map View plugin from the Flutter team that uses PlatformView under the hood. It is still in Developer Preview status, so breaking changes and bugs can be expected. <a href="https://github.com/flutter/plugins/tree/master/packages/google_maps_flutter">Link</a></li><li>flutter_google_places: Plugin from Hadrien Lejard that provides an interface to us to communicate with the Google Places Autocomplete API. <a href="https://pub.dartlang.org/packages/flutter_google_places">Link</a></li><li>location: Plugin from Guillaume Bernos that uses Platform Channel API to access GPS on Android &amp; iOS devices used to get user current location. <a href="https://pub.dartlang.org/packages/location">Link</a></li><li>name: Google Places App<br>description: Display &amp; Search your nearby places</li><li>version: 1.0.0+1</li><li>environment:<br> SDK: “&gt;=2.0.0-dev.68.0 ❤.0.0”</li><li>dependencies:<br> flutter:<br> SDK: flutter</li><li>google_maps_flutter: ^0.0.3<br> flutter_google_places: ^0.1.4<br> location: ^1.4.1</li><li>dev_dependencies:<br> flutter_test:<br> SDK: flutter</li><li>flutter:<br> uses-material-design: true</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*XXPwKVh1VJNCr-9lGDY2-w.png" /><figcaption>fig 1.3 after implementing Google places</figcaption></figure><p>In our main screen, we will ask user to grant GPS access and access their location, then we will ask the Google Places API to get nearby places to visit around. Make sure to paste your Google API key in the YOUR_API_KEYplaceholder.</p><ol><li>This widget consists of Scaffold with AppBar containing 2 actions item, refresh and search . The body uses Column with MapView as the first item, the second item wraps the ListView in an Expanded widget so it can flex all the remaining vertical space of the screen.</li><li>When the MapView has been created, a method is invoked to assign the MapControlller as the widget property, then it calls the refresh method that will asks user their current location using location plugin, then using the location it will invoke getNearbyPlaces to retrieve the nearby places using flutter_google_places plugin, then assigned the places as the state of the widget.</li><li>The places will be displayed in a Card inside ListView, each row shows the place name, address, and type. The inline MapView on the top displays all the pin marker of the places. When user taps on the row, the app will navigate to the place detail screen passing the placeId .</li></ol><p>import ‘dart:async’;<br>import ‘package:google_maps_webservice/places.dart’;<br>import ‘package:flutter_google_places/flutter_google_places.dart’;<br>import ‘package:flutter/material.dart’;<br>import ‘package:google_maps_flutter/google_maps_flutter.dart’;<br>import ‘package:location/location.dart’ as LocationManager;<br>import ‘place_detail.dart’;</p><p>const kGoogleApiKey = “TOUR_API_KEY”;<br>GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey);</p><p>void main() {<br> runApp(MaterialApp(<br> title: “PlaceZ”,<br> home: Home(),<br> debugShowCheckedModeBanner: false,<br> ));<br>}</p><p>class Home extends StatefulWidget {<br> <a href="http://twitter.com/override">@override</a><br> State&lt;StatefulWidget&gt; createState() {<br> return HomeState();<br> }<br>}</p><p>class HomeState extends State&lt;Home&gt; {<br> final homeScaffoldKey = GlobalKey&lt;ScaffoldState&gt;();<br> GoogleMapController mapController;<br> List&lt;PlacesSearchResult&gt; places = [];<br> bool isLoading = false;<br> String errorMessage;</p><p><a href="http://twitter.com/override">@override</a><br> Widget build(BuildContext context) {<br> Widget expandedChild;<br> if (isLoading) {<br> expandedChild = Center(child: CircularProgressIndicator(value: null));<br> } else if (errorMessage != null) {<br> expandedChild = Center(<br> child: Text(errorMessage),<br> );<br> } else {<br> expandedChild = buildPlacesList();<br> }</p><p>return Scaffold(<br> key: homeScaffoldKey,<br> appBar: AppBar(<br> title: const Text(“PlaceZ”),<br> actions: &lt;Widget&gt;[<br> isLoading<br> ? IconButton(<br> icon: Icon(Icons.timer),<br> onPressed: () {},<br> )<br> : IconButton(<br> icon: Icon(Icons.refresh),<br> onPressed: () {<br> refresh();<br> },<br> ),<br> IconButton(<br> icon: Icon(Icons.search),<br> onPressed: () {<br> _handlePressButton();<br> },<br> ),<br> ],<br> ),<br> body: Column(<br> children: &lt;Widget&gt;[<br> Container(<br> child: SizedBox(<br> height: 200.0,<br> child: GoogleMap(<br> onMapCreated: _onMapCreated,<br> options: GoogleMapOptions(<br> myLocationEnabled: true,<br> cameraPosition:<br> const CameraPosition(target: LatLng(0.0, 0.0))))),<br> ),<br> Expanded(child: expandedChild)<br> ],<br> ));<br> }</p><p>void refresh() async {<br> final center = await getUserLocation();</p><p>mapController.animateCamera(CameraUpdate.newCameraPosition(CameraPosition(<br> target: center == null ? LatLng(0, 0) : center, zoom: 15.0)));<br> getNearbyPlaces(center);<br> }</p><p>void _onMapCreated(GoogleMapController controller) async {<br> mapController = controller;<br> refresh();<br> }</p><p>Future&lt;LatLng&gt; getUserLocation() async {<br> var currentLocation = &lt;String, double&gt;{};<br> final location = LocationManager.Location();<br> try {<br> currentLocation = await location.getLocation();<br> final lat = currentLocation[“latitude”];<br> final lng = currentLocation[“longitude”];<br> final center = LatLng(lat, lng);<br> return center;<br> } on Exception {<br> currentLocation = null;<br> return null;<br> }<br> }</p><p>void getNearbyPlaces(LatLng center) async {<br> setState(() {<br> this.isLoading = true;<br> this.errorMessage = null;<br> });</p><p>final location = Location(center.latitude, center.longitude);<br> final result = await _places.searchNearbyWithRadius(location, 2500);<br> setState(() {<br> this.isLoading = false;<br> if (result.status == “OK”) {<br> this.places = result.results;<br> result.results.forEach((f) {<br> final markerOptions = MarkerOptions(<br> position:<br> LatLng(f.geometry.location.lat, f.geometry.location.lng),<br> infoWindowText: InfoWindowText(“${f.name}”, “${f.types?.first}”));<br> mapController.addMarker(markerOptions);<br> });<br> } else {<br> this.errorMessage = result.errorMessage;<br> }<br> });<br> }</p><p>void onError(PlacesAutocompleteResponse response) {<br> homeScaffoldKey.currentState.showSnackBar(<br> SnackBar(content: Text(response.errorMessage)),<br> );<br> }</p><p>Future&lt;void&gt; _handlePressButton() async {<br> try {<br> final center = await getUserLocation();<br> Prediction p = await PlacesAutocomplete.show(<br> context: context,<br> strictbounds: center == null ? false : true,<br> apiKey: kGoogleApiKey,<br> onError: onError,<br> mode: Mode.fullscreen,<br> language: “en”,<br> location: center == null<br> ? null<br> : Location(center.latitude, center.longitude),<br> radius: center == null ? null : 10000);</p><p>showDetailPlace(p.placeId);<br> } catch (e) {<br> return;<br> }<br> }</p><p>Future&lt;Null&gt; showDetailPlace(String placeId) async {<br> if (placeId != null) {<br> Navigator.push(<br> context,<br> MaterialPageRoute(builder: (context) =&gt; PlaceDetailWidget(placeId)),<br> );<br> }<br> }</p><p>ListView buildPlacesList() {<br> final placesWidget = places.map((f) {<br> List&lt;Widget&gt; list = [<br> Padding(<br> padding: EdgeInsets.only(bottom: 4.0),<br> child: Text(<br> f.name,<br> style: Theme.of(context).textTheme.subtitle,<br> ),<br> )<br> ];<br> if (f.formattedAddress != null) {<br> list.add(Padding(<br> padding: EdgeInsets.only(bottom: 2.0),<br> child: Text(<br> f.formattedAddress,<br> style: Theme.of(context).textTheme.subtitle,<br> ),<br> ));<br> }</p><p>if (f.vicinity != null) {<br> list.add(Padding(<br> padding: EdgeInsets.only(bottom: 2.0),<br> child: Text(<br> f.vicinity,<br> style: Theme.of(context).textTheme.body1,<br> ),<br> ));<br> }</p><p>if (f.types?.first != null) {<br> list.add(Padding(<br> padding: EdgeInsets.only(bottom: 2.0),<br> child: Text(<br> f.types.first,<br> style: Theme.of(context).textTheme.caption,<br> ),<br> ));<br> }</p><p>return Padding(<br> padding: EdgeInsets.only(top: 4.0, bottom: 4.0, left: 8.0, right: 8.0),<br> child: Card(<br> child: InkWell(<br> onTap: () {<br> showDetailPlace(f.placeId);<br> },<br> highlightColor: Colors.lightBlueAccent,<br> splashColor: Colors.red,<br> child: Padding(<br> padding: EdgeInsets.all(8.0),<br> child: Column(<br> mainAxisAlignment: MainAxisAlignment.start,<br> crossAxisAlignment: CrossAxisAlignment.start,<br> children: list,<br> ),<br> ),<br> ),<br> ),<br> );<br> }).toList();</p><p>return ListView(shrinkWrap: true, children: placesWidget);<br> }<br>}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*pnMXBPgPys6mWwMY7mB8PQ.png" /><figcaption>fig1.5 place details screen</figcaption></figure><p>This screen displays the detail of the Places when user taps on the row of the main list screen with a MapView and the pin marker. Make sure to paste your Google API key in the YOUR_API_KEY placeholder</p><ol><li>The widget consists of Scaffold , with AppBar that displays the name of the place inside the Title . The main body used the approach from the main widget that uses Column to stack widget vertically, MapView and ListView .</li><li>ListView displays the places information such as the name, address, phone number for each of its item . It also displays the photos of the place in a horizontal ListView that acts like a carousel in the first item.</li><li>When the widget initializes, the fetchPlaceDetail method is invoked to retrieve the detail of the place using the placeId from the Google Places API. It will then assigned the details as the state of the widget.</li></ol><p>import ‘package:google_maps_webservice/places.dart’;<br>import ‘package:flutter/material.dart’;<br>import ‘package:google_maps_flutter/google_maps_flutter.dart’;</p><p>const kGoogleApiKey = “YOUR_API_KEY”;<br>GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey);</p><p>class PlaceDetailWidget extends StatefulWidget {<br> String placeId;</p><p>PlaceDetailWidget(String placeId) {<br> this.placeId = placeId;<br> }</p><p><a href="http://twitter.com/override">@override</a><br> State&lt;StatefulWidget&gt; createState() {<br> return PlaceDetailState();<br> }<br>}</p><p>class PlaceDetailState extends State&lt;PlaceDetailWidget&gt; {<br> GoogleMapController mapController;<br> PlacesDetailsResponse place;<br> bool isLoading = false;<br> String errorLoading;</p><p><a href="http://twitter.com/override">@override</a><br> void initState() {<br> fetchPlaceDetail();<br> super.initState();<br> }</p><p><a href="http://twitter.com/override">@override</a><br> Widget build(BuildContext context) {<br> Widget bodyChild;<br> String title;<br> if (isLoading) {<br> title = “Loading”;<br> bodyChild = Center(<br> child: CircularProgressIndicator(<br> value: null,<br> ),<br> );<br> } else if (errorLoading != null) {<br> title = “”;<br> bodyChild = Center(<br> child: Text(errorLoading),<br> );<br> } else {<br> final placeDetail = place.result;<br> final location = place.result.geometry.location;<br> final lat = location.lat;<br> final lng = location.lng;<br> final center = LatLng(lat, lng);</p><p>title = placeDetail.name;<br> bodyChild = Column(<br> mainAxisAlignment: MainAxisAlignment.start,<br> crossAxisAlignment: CrossAxisAlignment.stretch,<br> children: &lt;Widget&gt;[<br> Container(<br> child: SizedBox(<br> height: 200.0,<br> child: GoogleMap(<br> onMapCreated: _onMapCreated,<br> options: GoogleMapOptions(<br> myLocationEnabled: true,<br> cameraPosition: CameraPosition(target: center, zoom: 15.0)),<br> ),<br> )),<br> Expanded(<br> child: buildPlaceDetailList(placeDetail),<br> )<br> ],<br> );<br> }</p><p>return Scaffold(<br> appBar: AppBar(<br> title: Text(title),<br> ),<br> body: bodyChild);<br> }</p><p>void fetchPlaceDetail() async {<br> setState(() {<br> this.isLoading = true;<br> this.errorLoading = null;<br> });</p><p>PlacesDetailsResponse place =<br> await _places.getDetailsByPlaceId(widget.placeId);</p><p>if (mounted) {<br> setState(() {<br> this.isLoading = false;<br> if (place.status == “OK”) {<br> this.place = place;<br> } else {<br> this.errorLoading = place.errorMessage;<br> }<br> });<br> }<br> }</p><p>void _onMapCreated(GoogleMapController controller) {<br> mapController = controller;<br> final placeDetail = place.result;<br> final location = place.result.geometry.location;<br> final lat = location.lat;<br> final lng = location.lng;<br> final center = LatLng(lat, lng);<br> var markerOptions = MarkerOptions(<br> position: center,<br> infoWindowText: InfoWindowText(<br> “${placeDetail.name}”, “${placeDetail.formattedAddress}”));<br> mapController.addMarker(markerOptions);<br> mapController.animateCamera(CameraUpdate.newCameraPosition(<br> CameraPosition(target: center, zoom: 15.0)));<br> }</p><p>String buildPhotoURL(String photoReference) {<br> return “<a href="https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&amp;photoreference=${photoReference}&amp;key=${kGoogleApiKey">https://maps.googleapis.com/maps/api/place/photo?maxwidth=400&amp;photoreference=${photoReference}&amp;key=${kGoogleApiKey</a>}&quot;;<br> }</p><p>ListView buildPlaceDetailList(PlaceDetails placeDetail) {<br> List&lt;Widget&gt; list = [];<br> if (placeDetail.photos != null) {<br> final photos = placeDetail.photos;<br> list.add(SizedBox(<br> height: 100.0,<br> child: ListView.builder(<br> scrollDirection: Axis.horizontal,<br> itemCount: photos.length,<br> itemBuilder: (context, index) {<br> return Padding(<br> padding: EdgeInsets.only(right: 1.0),<br> child: SizedBox(<br> height: 100,<br> child: Image.network(<br> buildPhotoURL(photos[index].photoReference)),<br> ));<br> })));<br> }</p><p>list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 4.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> placeDetail.name,<br> style: Theme.of(context).textTheme.subtitle,<br> )),<br> );</p><p>if (placeDetail.formattedAddress != null) {<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 4.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> placeDetail.formattedAddress,<br> style: Theme.of(context).textTheme.body1,<br> )),<br> );<br> }</p><p>if (placeDetail.types?.first != null) {<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 4.0, left: 8.0, right: 8.0, bottom: 0.0),<br> child: Text(<br> placeDetail.types.first.toUpperCase(),<br> style: Theme.of(context).textTheme.caption,<br> )),<br> );<br> }</p><p>if (placeDetail.formattedPhoneNumber != null) {<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 4.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> placeDetail.formattedPhoneNumber,<br> style: Theme.of(context).textTheme.button,<br> )),<br> );<br> }</p><p>if (placeDetail.openingHours != null) {<br> final openingHour = placeDetail.openingHours;<br> var text = ‘’;<br> if (openingHour.openNow) {<br> text = ‘Opening Now’;<br> } else {<br> text = ‘Closed’;<br> }<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 0.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> text,<br> style: Theme.of(context).textTheme.caption,<br> )),<br> );<br> }</p><p>if (placeDetail.website != null) {<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 0.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> placeDetail.website,<br> style: Theme.of(context).textTheme.caption,<br> )),<br> );<br> }</p><p>if (placeDetail.rating != null) {<br> list.add(<br> Padding(<br> padding:<br> EdgeInsets.only(top: 0.0, left: 8.0, right: 8.0, bottom: 4.0),<br> child: Text(<br> “Rating: ${placeDetail.rating}”,<br> style: Theme.of(context).textTheme.caption,<br> )),<br> );<br> }</p><p>return ListView(<br> shrinkWrap: true,<br> children: list,<br> );<br> }<br>}</p><p>above code for search places implementation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*Weqa0zNl7XA93HksW-nkOQ.jpeg" /><figcaption>fig1.5 implementation for search place implementation</figcaption></figure><p>When user taps on the search ActionBar un the main list AppBar. We will display a search bar where user can enter the name of the place they want to search. Then it will provide Autocomplete suggestions using Google Places autocomplete API for user to choose using a dropdown.</p><p>When they tap on the place, we just navigate to the place detail widget passing the placeId just like the nearby places item in the main widgetListView.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=85ccee3f0371" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter For Mobile Applications]]></title>
            <link>https://medium.com/@rajesh.muthyala/flutter-for-mobile-applications-b1905dbb66e2?source=rss-44721f9dd99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1905dbb66e2</guid>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Rajesh muthyala]]></dc:creator>
            <pubDate>Wed, 15 May 2019 10:50:14 GMT</pubDate>
            <atom:updated>2019-05-15T10:50:14.543Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Flutter?</h3><p>Flutter is a mobile app SDK for building high-performance, high-fidelity, apps for iOS and Android, from a single codebase.</p><p>The goal is to enable developers to deliver high-performance apps that feel natural on different platforms. We embrace differences in scrolling behaviors, typography, icons, and more.</p><h3>Why use Flutter?</h3><p>What are some advantages of Flutter? It helps you:</p><ul><li>Be highly productive</li><li>Develop for iOS and Android from a single codebase</li><li>Do more with less code, even on a single OS, with a modern, expressive language and a declarative approach</li><li>Prototype and iterate easily</li><li>Experiment by changing code and reloading as your app runs (with hot reload)</li><li>Fix crashes and continue debugging from where the app left off</li><li>Create beautiful, highly-customized user experiences</li><li>Benefit from a rich set of Material Design and Cupertino (iOS-flavor) widgets built using Flutter’s own framework</li><li>Realize custom, beautiful, brand-driven designs, without the limitations of OEM widget sets</li></ul><h3>Things you might wanna consider before moving to flutter development</h3><h3>1. It is not a LANGUAGE, it’s an SDK:</h3><p>Flutter is not a language, rather an SDK just like Android SDK. For Android development <strong>Java/Kotlin</strong> are the programming languages, for cross-platform development using flutter, <strong>DART</strong> is the official programming language.</p><p>According to the official website of a flutter: “Flutter is Google’s mobile app SDK for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.”</p><p>An SDK (Software Development Kit) is really a toolkit. It contains all the libraries, tools, documentation, etc. required to build software. It is an accessory and not a programming language. If you want to learn flutter development, you have to consider learning the DART language, which is pretty easy if you’re already familiar with any OOP language.</p><h3>2. It does not have a very large support community</h3><p>You might have to wait a little longer to get your questions answered on <strong>Stack Overflow</strong> XD. Flutter is still relatively new and does not have a community as large as other cross-platform solutions such as React Native or pure native apps.</p><p>The community is growing day by day and I believe after it’s <a href="https://developers.google.com/events/flutter-live/">stable launch on 4th December 2018</a> it would really explode.</p><p>But if you are someone who is afraid of documentation (although I believe Flutter has one of the best documentations present online. I personally didn’t need to refer to any other source than the official docs) then this might be a setback to you.</p><h3>3. Everything is a Widget</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/0*MhLzYoDUgY73xOuT.png" /></figure><p>Now this one might take some time getting used to. Everything in Flutter is a widget. Even the app itself is a complete widget.</p><p>It is not intuitive for anyone getting started, to think <strong>widgets</strong> (yes, I just made that up :P). The layouts are widgets, the typography is a widget, color is a widget, a button is a widget.</p><p>It doesn’t sound <strong>intuitive</strong>. When we think of widgets the first thing that comes into our mind is that it might be a part of an application. It might be a module. But to think that it is a complete app itself is something that’s going to take some time to wrap your heads around.</p><p>It might take you <strong>a few days to a month</strong> to get comfortable with flutter. Adding margins, paddings and other attributes are not intuitive at first. Also, you’ll need to spend some time understanding <strong>Box constraints</strong>.</p><p>But once you get a hang of it, you’ll get to know that it was totally worth the pain.</p><h3>4. DART is the official programming language</h3><p>Say what <strong>DART</strong>!!</p><p>That’s the <strong>reaction</strong> of most of the people when they first hear about DART. DART is a general-purpose programming language developed by Google in 2011. It is a client optimized language used to build beautiful mobile and web <strong>applications</strong>.</p><p>Developers at <strong>Google</strong> and elsewhere use Dart to create high-quality, mission-critical apps for iOS, Android, and the web. With features aimed at client-side development, Dart is a <strong>great fit </strong>for both mobile and web apps.</p><p>The apps built using <strong>DART</strong> are real native apps whose code compiles down to JAVA byte code, so at the machine level, it is indistinguishable from real native apps.</p><p>Having said all that, it is still not a very <strong>popular</strong> programming language and you might have to spend some time understanding all the syntactical sugar.</p><h3>5. A bigger APK size</h3><p>Don’t be surprised if you see your newly created, fresh out of the oven flutter app bigger in size than it’s native counterpart by <strong>50–60%</strong>.</p><p>Flutter apps (even React Native apps) have a considerably larger size than their native counterparts. <strong>I have even seen some trivial flutter apps 6–7 MB in size</strong>.</p><p>So, this is something you might wanna consider if your app is already large in size. You don’t want to scare off your users with a huge bloated <strong>APK</strong>.</p><h3>6. Not all features are supported</h3><p>If your app communicates with any hardware via <strong>Bluetooth </strong>then you’d have to develop these features <strong>separately</strong> for iOS and Android and integrate them into a flutter. In this case, one of the major selling points of cross-platform development i.e. time, will <strong>not be much beneficial</strong> as you’d end up spending time to create these features natively for both the apps.</p><h3>7. Still not comparable to a pure Native App</h3><p>This is a point that’s applicable to not only flutter but all the cross-platform solutions such as react native etc. Their performance is not even near to that of a native app.</p><p><a href="https://ayusch.com/native-vs-hybrid/"><em>I have done a full comparison here.</em></a></p><p>In comparison to native apps, they use approximately 30% more memory and are also less CPU efficient.</p><h4>Flutter Architecture — The Technical Overview</h4><p>Flutter is developed using C, C++, Dart, and Skia (a 2D rendering engine). The architecture diagram below presents a better picture of the three key layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/0*65AMye5YbVnV0b8x" /></figure><p>above image specifies the structure of flutter framework:-</p><h3>App size in Flutter</h3><p>The apk size in debug mode for flutter is too big because</p><p>In August 2018, we measured the size of a minimal Flutter app (no Material Components, just a single Center widget, built with flutter build apk), bundled and compressed as a release APK, to be approximately 4.7MB.</p><p>For this simple app, the core engine is approximately 3.2MB (compressed), the framework + app code is approximately 840KB (compressed), the LICENSE file is 55KB (compressed), necessary Java code (classes.dex) is 57KB (compressed), and there is approximately 533KB of (compressed) ICU data.</p><p>Of course, YMMV, and we recommend that you measure your own app, by running flutter build apk and looking at build/app/outputs/apk/release/app-release.apk.</p><p>Please refer below link for the:</p><p>For different framework and different sizes</p><p><a href="https://android.jlelse.eu/comparing-apk-sizes-a0eb37bb36f.">https://android.jlelse.eu/comparing-apk-sizes-a0eb37bb36f.</a></p><h3>Hardware integration in a flutter</h3><p>pub.dartlang.org was the service provider for the native access of hardware for a flutter.</p><p><a href="https://pub.dartlang.org/flutter">https://pub.dartlang.org/flutter</a></p><p>To Use Plugin:</p><p>declare a dependency on the pubspec.yaml of the project<br> 1. dependencies:<br> speech_recognition: &quot;^0.2.0+1&quot;</p><p>2. get the package and build the app<br>flutter packages get</p><p>flutter packages get</p><p>3. Import packages in your dart file</p><p>ex: import &#39;package:speech_recognition/speech_recognition.dart&#39;;</p><p>Sometimes Flutter needs to check special permission for IOS we need P.list for IOS.</p><p>for Android Manifest.xml<br> <br> 1. Permission handler 3.0.0 <br> <br> A permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.</p><p>Check if permission is granted.<br> • Request permission for a specific feature.<br> • Open app settings so the user can enable permission.<br> • Show a rationale for requesting permission (Android).</p><p>Add the dependency in pubspec.yaml <br>dependencies:<br> permission_handler: ‘².2.0’</p><p>Add the dependency in pubspec.yaml <br>dependencies:<br> permission_handler: ‘².2.0’</p><p>Import permission handler .dart;<br>import ‘package:permission_handler/permission_handler.dart’;</p><p>Map&lt;PermissionGroup, PermissionStatus&gt; permissions = await PermissionHandler().requestPermissions([PermissionGroup.contacts]);</p><p>List of permissions to need permission</p><p>Calander, Camera, contacts, location, microphone, photos, remainder.</p><p>4. MVP design Flutter Architecture: Implement MVP Pattern</p><p>Model is an interface defining the data to be displayed or otherwise acted user interface</p><p>The view is a passive interface that displays data routes and user commands to the act upon the data.</p><p>The presenter acts upon the model and the view. It retrieves data from repositories(model). And formats it for display in the view.</p><p>Please refer below example image for architecture:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*p2JvbgEir0BusDiiVHMvIA.png" /><figcaption>firgure1.1 MVP pattern</figcaption></figure><p>So in the MVP pattern, the presenter is the middle mediator handling the model and updating the view. In MVP View and Presenter are completely decoupled and communicate with each other by the interfaces. Because of the decoupling of MVP that is easy to mock data for unit testing.</p><h3>A design pattern star on Android</h3><p>Google encourages MVP on its Android documentation, so this is a very common pattern on it. (STOP putting all your code in activities ! … )</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4LJmr5ic3u6o9QlD5m1zfA.png" /></figure><h3>Implement the MVP on Flutter</h3><p>Flutter has no activity or fragment but the MVP pattern is still really interesting to architect our application code. <br>Here is a quick view of how it works.</p><p><strong>Let’s create a new flutter project with command f<em>lutter create mvp_pattern_tutorial</em></strong></p><p>We have the flutter example code that shows a button to push and increment a counter. Perfect for us, we are going to transform it.</p><h4>1 — Our files</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*Q20Th5Uc_PuW8QHry6InLg.png" /></figure><h4>2 — Make the Presenter</h4><p>Our presenter must stay as much as possible testable without any library. So let’s create it for our demo.</p><pre><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/viewmodel/counter_viewmodel.dart&#39;;</pre><pre><strong>class </strong>CounterPresenter {<br>    <strong>void </strong>onButton1Clicked() {}<br>}</pre><pre><strong>class </strong>BasicCounterPresenter <strong>implements </strong>CounterPresenter {</pre><pre>CounterViewModel _counterViewModel;</pre><pre>@override<br>    <strong>void </strong>onButton1Clicked() {<br>      // <em>TODO: implement onButton1Clicked<br>    </em>}<br>}</pre><p>The presenter is responsible for what a button or any action on the UI will do on our ViewModel</p><h4>3 — The View</h4><p>Our main.dart, that will start our application will now look like this</p><pre><strong>import </strong>&#39;package:flutter/material.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/presenter/counter_presenter.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/views/counter_component.dart&#39;;</pre><pre><strong>void </strong>main() =&gt; runApp(<strong>new </strong>MyApp());</pre><pre><strong>class </strong>MyApp <strong>extends </strong>StatelessWidget {<br>  @override<br>  Widget build(BuildContext context) {<br>    <strong>return new </strong>MaterialApp(<br>      title: &#39;Flutter Demo&#39;,<br>      theme: <strong>new </strong>ThemeData(<br>        primarySwatch: Colors.<em>blue</em>,<br>      ),<br>      home: <strong>new </strong>MyHomePage(<strong>new </strong>BasicCounterPresenter(), title: &#39;Flutter Demo Home Page&#39;),<br>    );<br>  }<br>}</pre><p>You see now MyHomePage has a Presenter in its constructor.</p><p>Well now we want our View (MyHomePage) be as dumb as possible, and the presenter does the logic without using any UI library (not even flutter). <br>Here is the full view code.</p><pre><strong>import </strong>&#39;package:flutter/material.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/presenter/counter_presenter.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/viewmodel/counter_viewmodel.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/views/counter_view.dart&#39;;</pre><pre><strong>class </strong>MyHomePage <strong>extends </strong>StatefulWidget {<br>    <strong>final </strong>CounterPresenter presenter;</pre><pre>MyHomePage(<strong>this</strong>.presenter, {Key key, <strong>this</strong>.title}) : <strong>super</strong>(key: key);</pre><pre><strong>final </strong>String title;</pre><pre>@override<br>    _MyHomePageState createState() =&gt; <strong>new </strong>_MyHomePageState();<br>}</pre><pre><strong>class </strong>_MyHomePageState <strong>extends </strong>State&lt;MyHomePage&gt; <strong>implements </strong>CounterView {</pre><pre>CounterViewModel _viewModel;</pre><pre>@override<br>    <strong>void </strong>initState() {<br>        <strong>super</strong>.initState();<br>        <strong>this</strong>.widget.presenter.counterView = <strong>this</strong>;<br>    }</pre><pre>@override<br>    <strong>void </strong>refreshCounter(CounterViewModel viewModel) {<br>        setState(() {<br>            <strong>this</strong>._viewModel = viewModel;<br>        });<br>    }</pre><pre>@override<br>    Widget build(BuildContext context) {<br>        <strong>return new </strong>Scaffold(<br>            appBar: <strong>new </strong>AppBar(<br>                title: <strong>new </strong>Text(widget.title),<br>            ),<br>            body: <strong>new </strong>Center(<br>                child: <strong>new </strong>Column(<br>                    mainAxisAlignment: MainAxisAlignment.center,<br>                    children: &lt;Widget&gt;[<br>                        <strong>new </strong>Text(<br>                            &#39;You have pushed the button this many times:&#39;,<br>                        ),<br>                        <strong>new </strong>Text(<br>                            _viewModel?.counter.toString(),<br>                            style: Theme.<em>of</em>(context).textTheme.display1,<br>                        ),<br>                    ],<br>                ),<br>            ),<br>            floatingActionButton: <strong>new </strong>FloatingActionButton(<br>                onPressed: () =&gt; <strong>this</strong>.widget.presenter.onButton1Clicked(),<br>                tooltip: &#39;Increment&#39;,<br>                child: <strong>new </strong>Icon(Icons.<em>add</em>),<br>            ),<br>        );<br>    }<br>}</pre><p>Key points here are :<br>- we bind the interface of the view to the Presenter in the <em>initState</em> method<br>- on click, we call the action <em>“onButtonClick”</em> of the presenter<br>- presenter now just have to increment the counter in the ViewModel and call a refresh of the view</p><h4>4 — The presenter</h4><p>Our presenter implements an interface too. Imagine you want to do another same UI with just a few modifications on how you handle events? Easy you just create another implementation of the presenter.</p><p>So,<br>The presenter init the ViewModel on its constructor. <br>We have bound the CounterView interface on the presenter to refresh ViewModel or show a message… But here still, we don’t have any flutter lib, we just know we have a method to do it, not the implementation.</p><pre><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/viewmodel/counter_viewmodel.dart&#39;;<br><strong>import </strong>&#39;package:mvp_flutter_tutorial/ui/counter/views/counter_view.dart&#39;;</pre><pre><strong>class </strong>CounterPresenter {<br>    <strong>void </strong>onButton1Clicked() {}<br>    <strong>set </strong>counterView(CounterView value) {}<br>}</pre><pre><strong>class </strong>BasicCounterPresenter <strong>implements </strong>CounterPresenter {</pre><pre>CounterViewModel _counterViewModel;<br>    CounterView _counterView;</pre><pre>BasicCounterPresenter() {<br>        <strong>this</strong>._counterViewModel = <strong>new </strong>CounterViewModel(0);<br>    }</pre><pre>@override<br>    <strong>void </strong>onButton1Clicked() {<br>       <strong>this</strong>._counterViewModel.counter++;<br>       <strong>this</strong>._counterView.refreshCounter(<strong>this</strong>._counterViewModel);<br>    }</pre><pre>@override<br>    <strong>set </strong>counterView(CounterView value) {<br>        _counterView = value;<br>        <strong>this</strong>._counterView.refreshCounter(<strong>this</strong>._counterViewModel);<br>    }</pre><pre>}</pre><p>Note: we could throw an error if the view is null on the refresh counter calls.</p><h4>5 — The ViewModel</h4><p>Just a counter here but we could imagine that attributes : <br>- messageViewModel<br>- errorViewModel<br>- delay between clicks<br>…</p><pre><strong>class </strong>CounterViewModel {<br>    int counter = 0;</pre><pre>CounterViewModel(<strong>this</strong>.counter);<br>}</pre><h3>File Structure in Flutter</h3><p>flutter-app/<br>|- Android<br>|- build<br>|- ios<br>|- lib<br>|- test<br> <br>The above example was a basic app structure:-</p><p>Now, let’s dive into the lib folder which has the main code for the application.<br> 1. screens — Contains the screens of your application. All files from here get imported into routes.dart<br> 2. util — Contains the utilities/common functions of your application<br> 3. widgets — It contains the common widgets for your applications. For example, Button, TextField, etc.<br> 4. routes. dart — It contains the routes of your application and imports all screens.<br>lib/<br>|- main.dart<br>|- routes.dart<br>|- screens/<br>|- util/<br>|- widgets/<br>|- data/<br>|- services/</p><p>SERVICES-<br>This would handle all network and business logic of your application. For example, once you are authenticated with facebook/google you need to update backend with access tokens you can place that authentication in this folder.<br>services/<br>|- authentication.dart</p><p>DATA-<br>This folder would come into the picture once you integrate redux(or other) stores into the application. Here you would put your reducers, actions etc.<br>data/<br>|- auth<br> |- access_token<br> |- actions.dart<br> |- reducer.dart<br> |- refresh_token<br> |- actions.dart<br> |- reducer.dart<br> |- reducer.dart<br>UTIL-<br>util<br>|- date_utils.dart<br>|- format_utils.dart<br>Util folder contains the business logic of your application. For example, if you are working on an e-commerce application few of them could be:-<br> 1. Calculating the total amount in cart.<br> 2. Showing dates, currency, etc. in a proper format.</p><p><strong>Application Section</strong>: This section is named on the name of the application (like in all the images of this article will be shown as <strong>fluttered</strong> which is the name of my app) and shows the Physical Folder location and contents. This is the main section on which any Flutter app developer will work on. When expanded this section will look like the following:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*0sQfALa2ZGSMPV4gA2Xv6A.png" /><figcaption>fig: 1.2 detailed structured overview</figcaption></figure><ol><li><strong>Android</strong>: As the name suggests, this folder contains all the Android-related files and code for the application. The main file and folder which we have to work on in this are highlighted below:</li><li>◦ res folder: This folder contains all the non-programmable resources which are used in applications like icons, images any style values, etc.<br> ◦ AndroidManifest.xml file: This file contains essential information about the application which is required by Android SDK. Read this document for more details.<br> Apart from these, we don’t have to make any changes in this folder unless we are going to do any platform level customization in the app which is very rarely required and not advisable especially if you don’t know about native Android development.<br><strong><em>ios</em></strong>: Just like the <em>android</em> folder, this folder contains the iOS-related files and code for the application. The main file and folder which we have to work on in this are highlighted below:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*N0X6YqOGwC-GwJ8o.png" /></figure><ul><li><strong><em>Assets.xcassests</em></strong> folder: This folder contains all the icons and images used in the application,</li><li><strong><em>info.plist</em></strong> file: Just like <em>AndroidManifest</em>, this file contains essential information about the application which is required by iOS SDK. Read <a href="https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html">this document</a> for more details.</li></ul><ol><li>Apart from these, we don’t have to make any changes in this folder unless we are going to do any platform level customization in the app which is very rarely required and not advisable especially if you don’t know about native iOS development and Flutter integration with it.</li><li><strong><em>lib</em></strong>:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*2jOo7J5Q3pTJVlWi.png" /></figure><ol><li>This is the main folder where we have to write all our application code, the default project template currently only contains <em>main. dart</em> file which is kind of an entry point for the Flutter application. When we will start creating a multi-screen application following some design patterns, we will have to create more files and folders inside this folder. The Language which is used for Flutter app development is <a href="https://www.dartlang.org/"><strong>Dart</strong></a>, which will explain more about this in future articles.</li><li><strong><em>test</em></strong>:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*ncVzNRUIHKfO7-2-.png" /></figure><ol><li>As the name suggests, this folder is used to store and manage testing code for the application, just like a <em>lib folder</em>, this folder also has only one file by default.</li><li><strong>Files on Root</strong>: These are configuration files which are used by various IDE and language tools explained as below:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/0*2hmJDEmdcKylLxa-.png" /></figure><ul><li><strong><em>.gitignore</em></strong>: This is a hidden file used IDE to store the list of files that need to be ignored when the source code is uploaded/check-into to any Git versioning system like <a href="https://github.com/">Github</a> or <a href="https://bitbucket.org/">Bitbucket</a>.</li><li><strong><em>.metadata</em></strong>: This also is a hidden file used by IDE to track the properties of the Flutter project.</li><li><strong><em>.packages</em></strong>: In every language or SDK, we require a Package manager in order to manage 3rd party or reusable controls or components (like we have Nuget for Visual Studio and .NET). In the case of Dart, the Package Manager is called <a href="https://www.dartlang.org/tools/pub">Pub</a> and this hidden file in used by Pub to manage the packages for the project.</li><li><strong><em>android.iml</em></strong>: This is an XML file used by the IntelliJ engine to get the configuration of JAVA_MODULEused by the project. <strong><em>.iml</em> =&gt; IntelliJ Module File</strong>.</li><li><strong><em>pubspec.lock</em></strong>: Just like <em>.packages</em>, this file is also used by the Pub package manager in order to get the concrete versions and other identifying information for every immediate and transitive dependency a package relies on.</li><li><strong><em>pubspec.yaml</em></strong>: <strong>This is the only file in all these files which we have to make changes in when we have to use any 3rd party </strong><a href="https://pub.dartlang.org/flutter/"><strong>flutter package</strong></a>. This file is used by the Pub package manager to get and load the packages used in the project. Please read <a href="https://www.dartlang.org/tools/pub/pubspec">this documentation</a> about how to make changes in this file. <a href="https://en.wikipedia.org/wiki/YAML">YAML =&gt; Yet Another Multicolumn Layout</a>.</li><li><strong><em>README.md</em></strong>: This is a Markdown file used to mention any information about the project. It’s an optional file.</li><li><strong><em>&lt;appname&gt;.iml</em></strong>: Just like <em>android.iml</em>, this file contains configuration information about the project components which are used by the IntelliJ engine.</li><li><strong><em>&lt;appname&gt;_android.iml</em></strong>: This file also contains Android configuration information about the project which is used by the IntelliJ engine.</li></ul><h3>SQFLITE in Flutter</h3><p>SQLite plugin for Flutter. Supports both iOS and Android.<br> • Support transactions and batches<br> • Automatic version management during open<br> • Helpers for insert/query/update/delete queries<br> • DB operation executed in a background thread on iOS and Android.</p><p>Why SQLite?<br>SQLite is one of the most popular ways to store data locally. For this article, we will be using the package sqflite to connect with SQLite. Sqflite is one of the most used and up to date packages for connecting to SQLite databases in Flutter.</p><p>1. Add dependencies to your project<br>In your project go to pubspec.yaml and look for dependencies. Under dependencies, add the latest version of sqflite and path_provider (use the right numbers from Pub).</p><p>dependencies:</p><p>SDK: flutter</p><p>sqflite: any</p><p>path_provider: any</p><p>NOTE:<br>We use the path_provider package to get the commonly used location such as TemporaryDirectory and ApplicationDocumentsDirectory.</p><p>2. Create a DB Client<br>Now in your project create a new file Database.dart. In the newly created file, we need to create a singleton.<br>Why we need singleton: We use the singleton pattern to ensure that we have only one class instance and provide global point access to it</p><ol><li>Create a private constructor that can be used only inside the class : <br>ex: <br>class DBProvider {<br>DBProvider._();<br>static final DBProvider db= DBProvider._();</li><li>Setup the database<br>Next, we will create the database object and provide it with a getter where we will instantiate the database if it’s not (lazy initialization).</li></ol><p>static Database _database;</p><p>Future&lt;Database&gt; get database async {<br>if (_database != null)<br>return _database;</p><p>// if _database is null we instantiate it<br>_database = await initDB();<br>return _database;<br>}</p><p>If there is no object assigned to the database, we use the initDB function to create the database. In this function, we will get the path for storing the database and create the desired tables:</p><p>initDB() async {</p><p>Directory documentsDirectory = await getApplicationDocumentsDirectory();</p><p>String path = join(documentsDirectory.path, “TestDB.db”);</p><p>return await openDatabase(path, version: 1, onOpen: (db) {</p><p>}, onCreate: (Database db, int version) async {</p><p>await db.execute(“CREATE TABLE Client (“</p><p>“id INTEGER PRIMARY KEY,”</p><p>“first_name TEXT,”</p><p>“last_name TEXT,”</p><p>“blocked BIT”</p><p>“)”);</p><p>});</p><p>}</p><pre><strong><em>NOTE</em></strong><em>: The database name is </em>TestDB <em>and the only table we have is called </em>Client<em>. If you don&#39;t know what&#39;s going on you really need to go and learn some SQL</em> <em>it&#39;s more important than water.</em></pre><h3>3. Create the Model Class</h3><p>The data inside your database will be converted into Dart <a href="https://api.dartlang.org/stable/2.1.0/dart-core/Map-class.html">Maps </a>so first, we need to create the model classes with toMap and fromMap methods. I am not going to cover how to do this manually. If you don’t know how to do this, you should consider reading this <a href="https://medium.com/flutter-community/parsing-complex-json-in-flutter-747c46655f51">article </a>by <a href="https://medium.com/@poojabhaumik">Poojã Bhaumik</a>.</p><p>To create our model classes, I am going to use this <a href="https://app.quicktype.io/#l=dart">website</a>. If you don’t already have it bookmarked, you really should :)</p><p>import ‘dart:convert’;</p><p>Client clientFromJson(String str) {</p><p>final jsonData = json.decode(str);</p><p>return Client.fromJson(jsonData);</p><p>}</p><p>String clientToJson(Client data) {</p><p>final dyn = data.toJson();</p><p>return json.encode(dyn);</p><p>}</p><p>class Client {</p><p>int id;</p><p>String firstName;</p><p>String lastName;</p><p>bool blocked;</p><p>Client({</p><p>this.id,</p><p>this.firstName,</p><p>this.lastName,</p><p>this.blocked,</p><p>});</p><p>factory Client.fromJson(Map&lt;String, dynamic&gt; json) =&gt; new Client(</p><p>id: json[“id”],</p><p>firstName: json[“first_name”],</p><p>lastName: json[“last_name”],</p><p>blocked: json[“blocked”],</p><p>);</p><p>Map&lt;String, dynamic&gt; toJson() =&gt; {</p><p>“id”: id,</p><p>“first_name”: firstName,</p><p>“last_name”: lastName,</p><p>“blocked”: blocked,</p><p>};</p><p>}</p><h3>4. CRUD operations</h3><h3>Create</h3><p>The SQFlite package provides two ways to handle these operations using RawSQL queries or by using table name and a map which contains the data :</p><p>Using rawInsert :</p><p>newClient(Client newClient) async {</p><p>final db = await database;</p><p>var res = await db.rawInsert(</p><p>“INSERT Into Client (id,first_name)”</p><p>“ VALUES (${newClient.id},${newClient.firstName})”);</p><p>return res;</p><p>}</p><p>Insert</p><p>newClient(Client newClient) async {</p><p>final db = await database;</p><p>var res = await db.insert(“Client”, newClient.toMap());</p><p>return res;</p><p>}</p><h4>Read :</h4><p>Get Client by id</p><p>getClient(int id) async {</p><p>final db = await database;</p><p>var res =await db.query(“Client”, where: “id = ?”, whereArgs: [id]);</p><p>return res.isNotEmpty ? Client.fromMap(res.first) : Null ;</p><p>}</p><h3>Profiling and debugging</h3><p>profiling is measuring the execution times and correlating it with various classes/methods/functions. (see the link I gave to the wikipedia page for some commentary on how profilers can work) .</p><p>Profilers are implemented a lot like debuggers too, except that rather than allowing you to stop the program and poke around, they simply let it run and keep track of how much time gets spent in every part of the program. This is particularly useful if you have some code that is running slower than you need it to run, as you can figure out exactly where all the time is going, and concentrate your efforts on fixing just that bottleneck.</p><p>So there are three types of code profilers:<br> 1. Method/line level profiler — You have that low-level standard kind of profiler, which most of you have probably used. Again, it was probably a bad day when you were using it. You were probably chasing a weird CPU problem. You probably don’t use that low-level profiler very often, maybe a couple of times a year.<br> 2. Transaction tracing -The other type that we’ve talked about is that kind of hybrid lightweight profiler that you can use while you’re doing development. They’re awesome to use every single day and they don’t slow you down. They can help you find performance and application problems.<br> 3. APM — And then you have profilers for your servers which is that APM type product that you can run on your servers that has low overhead and you can track performance all the time.</p><p>Diagnosing performance problems<br>To diagnose an app with performance problems, you’ll enable the performance overlay to look at the UI and GPU threads. Before you begin, you want to make sure that you’re running in profile mode, and that you’re not using an emulator. For best results, you might choose the slowest device that your users might use.</p><h4>Connect to a physical device</h4><p>Almost all performance debugging for Flutter applications should be conducted on a physical Android or iOS device, with your Flutter application running in profile mode. Using debug mode, or running apps on simulators or emulators, is generally not indicative of the final behavior of release mode builds. You should consider checking performance on the slowest device that your users might reasonably use.<br>Run in profile mode<br>Flutter’s profile mode compiles and launches your application almost identically to release mode, but with just enough additional functionality to allow debugging performance problems. For example, profile mode provides tracing information to profiling tools.<br>Launch the app in profile mode as follows:<br> • In Android Studio and IntelliJ, use the Run &gt; Flutter Run main.dart in the Profile Mode menu item.<br>From the command line, use the — profile fl</p><p>content_copy<br>$ flutter run — profile</p><h3>The performance overlay</h3><p>The performance overlay displays statistics in two graphs that show where time is being spent in your app. If the UI is janky (skipping frames), these graphs help you figure out why. The graphs display on top of your running app, but they aren’t drawn like a normal widget — the Flutter engine itself paints the overlay and only minimally impacts performance. Each graph represents the last 300 frames for that thread.</p><p>Flutter uses several threads to do its work. All your Dart code runs on the UI thread. Although you have no direct access to any other thread, your actions on the UI thread have performance consequences on other threads.<br> 1. Platform thread<br>The platform’s main thread. Plugin code runs here. For more information, see the UIKit documentation for iOS, or the MainThread documentation for Android. This thread is not shown in the performance overlay.<br> 2. UI thread<br>The UI thread executes Dart code in the Dart VM. This thread includes code that you wrote, and code executed by Flutter’s framework on your app’s behalf. When your app creates and displays a scene, the UI thread creates a layer tree, a lightweight object containing device-agnostic painting commands, and sends the layer tree to the GPU thread to be rendered on the device. Don’t block this thread! Shown in the bottom row of the performance overlay.<br> 3. GPU thread<br>The GPU thread takes the layer tree and displays it by talking to the GPU (graphic processing unit). You cannot directly access the GPU thread or its data but, if this thread is slow, it’s a result of something you’ve done in the Dart code. Skia, the graphics library, runs on this thread, which is sometimes called the rasterizer thread. Shown in the top row of the performance overlay.<br> 4. I/O thread<br>Performs expensive tasks (mostly I/O) that would otherwise block either the UI or GPU threads. This thread is not shown in the performance overlay.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*zqU354QtOhPMqoTdDUnbgg.png" /><figcaption>Performance overlay showing the GPU thread (top), and UI thread (bottom). The vertical green bars represent the current frame.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*cUZKJ0hH1JT8OKqrkkzE8Q.png" /><figcaption>The vertical red bars indicate that the current frame is expensive to both render and paint.<br>When both graphs have red, start by diagnosing the UI thread (Dart VM).</figcaption></figure><h4>From the Flutter inspector</h4><p>The easiest way to enable the PerformanceOverlay widget is in the Flutter inspector, which is available through the Flutter plugin for your IDE. The Inspector view opens by default when running an application. If the inspector isn’t open, you can display it as follows.</p><p>In Android Studio and IntelliJ IDEA:</p><ol><li>Select <strong>View &gt; Tool Windows &gt; Flutter Inspector</strong>.</li><li>In the toolbar, select the icon that looks like a bookshelf (</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/22/0*wh_hBGDqlfEv6tvT.png" /></figure><ol><li>).</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/884/0*gmB4I6PxIrLlYTeS.png" /><figcaption>Android studio profile mode view settings</figcaption></figure><p>The Flutter Inspector is available in Android Studio and IntelliJ. Learn more about what the Inspector can do in the widget<a href="https://flutter.dev/docs/development/tools/inspector"> inspector</a> doc, as well as the <a href="https://www.youtube.com/watch?v=JIcmJNT9DNI">Flutter Inspector talk</a> presented at DartConf 201</p><h4>Debugging</h4><p>The Dart Analyzer<br>Before running your applications, test your code with flutter analyze. This tool (which is a wrapper around the dart analyzer tool) analyzes your code and helps you find possible mistakes. If you’re using a Flutter enabled IDE/editor, this is already happening for you.<br>The Dart analyzer makes heavy use of type annotations that you put in your code to help track problems down. You are encouraged to use them everywhere (avoiding var, untyped arguments, untyped list literals, etc) as this is the quickest and least painful way of tracking down problems.</p><p>Dart Observatory (statement-level single-stepping debugger and profiler)<br>If you started your application using a flutter run, then, while it is running, you can open the Web page at the Observatory URL printed to the console (e.g., Observatory listening on <a href="http://127.0.0.1:8100/">http://127.0.0.1:8100/</a>), to connect to your application directly with a statement-level single-stepping debugger. If you’re using a Flutter enabled IDE/editor, you can also debug your application using its built-in debugger.<br>The observatory also supports profiling, examining the heap, etc. For more information on Observatory, see Observatory’s documentation.<br>If you use Observatory for profiling, make sure to run your application in profile mode, bypassing — profile to the flutter run command. Otherwise, the main thing that appears on your profile is the debug asserts verifying the framework’s various invariants (see “Debug mode assertions” below).</p><p>debugger() statement<br>When using the Dart Observatory (or another Dart debugger integrated into a Flutter enabled IDE/editor), you can insert programmatic breakpoints using the debugger() statement. To use this, you have to put import ‘dart: developer’; at the top of the relevant file.<br>The debugger() statement takes an optional when argument which you can specify to the only break when a certain condition is true, as in:<br>content_copy</p><p>void someFunction(double offset) {<br> debugger(when: offset &gt; 30.0);<br> // …<br>}</p><p>print and debugPrint with flutter logs</p><p>The Dart print() function outputs to the system console, which you can view using flutter logs (which is basically a wrapper around adb logcat).<br>If you output too much at once, then Android sometimes discards some log lines. To avoid this, you can use debugPrint(), from Flutter’s foundation library. This is a wrapper around print which throttles the output to a level that avoids being dropped by Android’s kernel.</p><h4>What Causes Jank</h4><p>Give this mode of operation, jank can be perceived in a Flutter application if either one of the following conditions are met:</p><ul><li>Either the UI or GPU thread component of a pipeline item exceeds the frame budget (typically 16.67 ms for a 60Hz display refresh rate).</li><li>The engine changes the pipeline depth.</li><li>The vsync events from the platform are emitted or latched onto at an inconsistent rate.</li></ul><h4>Observatory from the Command Line</h4><ul><li>Launch the application using <strong>flutter run — profile</strong> (or <strong>debug</strong> if you are prototyping your traces)</li><li>The tools should forward the observatory port to your host and display a line like so: <strong>An Observatory debugger and profiler on iPhone X is available at </strong><a href="http://127.0.0.1:60551/"><strong>http://127.0.0.1:60551/</strong></a></li><li>Launch that URL in your web browser</li></ul><h4>Observatory from the IDE</h4><ul><li>Launch the Flutter Application using the Play button or shortcut.</li><li>In the Run panel, click the stopwatch icon to launch the observatory for that application in your web browser.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UswTVsZeQ5oIt3iGVNz_rQ.png" /><figcaption>How to open the observatory tool for profiling</figcaption></figure><h3>Navigate to the Timeline in the Observatory</h3><p>Either click on the timeline link on the main observatory page or navigate to the timeline directly by opening <a href="http://127.0.0.1:61102/#/timeline(replace"><strong>http://127.0.0.1:61102/#/timeline</strong>(replace</a> the # with the actual port number).</p><p>If you always want to forward the observatory to the same port on the host, specify the<em> — </em><strong><em>observatory-port=&lt;port&gt;</em></strong> command line option. That way, you can just reload your web browser after relaunching the application on the device. I do this to avoid looking up the new observatory port. Enter <strong>flutter help run</strong> at the command line for more details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7lr-78NtCXHC1XEUv-YcBA.png" /><figcaption>Observatory dashboard in the browser</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*icBbj9nTkdu4diI8JLhAvg.png" /><figcaption>set up for the selecting the profiler</figcaption></figure><h3>Collecting a Trace</h3><p>Enable tracing on all trace categories by clicking on <strong><em>All</em></strong> then click the <strong><em>clear button</em></strong> to start tracing on the device. Notice that the “Recorded Streams” are all enabled. The timeline is still empty but the device has started gathering traces. Make sure to interact with the application in a way that adds traces to the Timeline. Usually, rendering a few frames works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gztnLXVAxmpNL8p2YP2lPw.png" /><figcaption>observatory timeline settings</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Dxc3ZTPjf5_Q3KPBOBInFQ.png" /></figure><h3>Debugging Dart code</h3><p>Use your IDE for standard Dart debugging. These instructions describe Android Studio, but you can use your preferred IDE with the Flutter and Dart plugins installed and configured.</p><h3>Dart debugger</h3><ul><li>Open your project in Android Studio. If you don’t have a project yet, create one using the instructions in a Test drive.</li><li>Simultaneously bring up the Debug pane and run the app in the Console view by clicking the bug icon ().</li><li>The first time you launch the app is the slowest. You should see the Debug pane appear at the bottom of the window that looks something like the following:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*isw3bP7dBL6nYo0TT-llSQ.png" /><figcaption>building apk as debug mode</figcaption></figure><p>You can configure where the to debug pane appears, or even tear it off to its own window using the gear to the right in the Debug pane bar. This is true for any inspector in Android Studio.</p><ul><li>Add a breakpoint on the counter++ line.</li><li>In the app, click the <strong>+</strong> button (FloatingActionButton, or FAB, for short) to increment the counter. The app pauses.</li><li>The following screenshot shows:</li><li>Breakpoint in the edit pane.</li><li>State of the app in the debug pane when paused at the breakpoint.</li><li>this variable expanded to display its values.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*5s-5b1mxkgByNLtusnPm1Q.png" /></figure><h3>Flutter inspector</h3><p>There are two other features provided by the Flutter plugin that you may find useful. The Flutter inspector is a tool for visualizing and exploring the Flutter widget tree and helps you:</p><ul><li>Understand existing layouts</li><li>Diagnose layout issues</li></ul><p>Toggle display of the inspector using the vertical button to the right of the Android Studio window.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*ZwYdQEBhLocz_FczwB76hw.png" /></figure><p>Unit tests in the flutter</p><p>The more features your app has, the harder it is to test manually. Automated tests help ensure that your app performs correctly before you publish it, while retaining your feature and bug fix velocity.</p><p>Automated testing falls into a few categories:</p><ul><li>A <a href="https://flutter.dev/docs/testing#unit-tests">unit test</a> tests a single function, method, or class.</li><li>A <a href="https://flutter.dev/docs/testing#widget-tests">widget test</a> (in other UI frameworks referred to as component test) tests a single widget.</li><li>An <a href="https://flutter.dev/docs/testing#integration-tests">integration test</a> tests a complete app or a large part of an app.</li></ul><p>Generally speaking, a well-tested app has many unit and widget tests, tracked by <a href="https://en.wikipedia.org/wiki/Code_coverage">code coverage</a>, plus enough integration tests to cover all the important use cases. This advice is based on the fact that there are trade-offs between different kinds of testing, seen below.</p><h3>Unit tests</h3><p>A unit test tests a single function, method, or class. The goal of a unit test is to verify the correctness of a unit of logic under a variety of conditions. External dependencies of the unit under test are generally <a href="https://flutter.dev/cookbook/testing/mocking">mocked out</a>. Unit tests generally don’t read from or write to disk, render to screen or receive user actions from outside the process running the test.</p><p>Integration tests</p><p>An integration test tests a complete app or a large part of an app. The goal of an integration test is to verify that all the widgets and services being tested work together with others as expected. Furthermore, you can use integration tests to verify your app’s performance.</p><p>Generally, an integration test runs on a real device or an OS emulator, such as iOS Simulator or Android Emulator. The app under test is typically isolated from the test driver code to avoid skewing the results.</p><p>Widget tests</p><p>A widget test (in other UI frameworks referred to as component test) tests a single widget. The goal of a widget test is to verify that the widget’s UI looks and interacts as expected. Testing a widget involves multiple classes and requires a test environment that provides the appropriate widget lifecycle context.</p><p>For example, the Widget being tested should be able to receive and respond to user actions and events, perform layout, and instantiate child widgets. A widget test is, therefore, more comprehensive than a unit test. However, like a unit test, a widget test’s environment is replaced with an implementation much simpler than a full-blown UI system</p><p>iOS Support<br> <br> Install flutter on Mac<br> Once installed navigate to locate ios folder inside the project file and run below command<br> flutter build ios<br> <br> In case if you get below error<br> Cannot find “xcodebuild”. Xcode 9.0 or greater is required to develop for iOS.<br> Encountered error while building for the device.<br> <br> Please install Xcode from AppStore and run below command<br> sudo xcode-select — switch /Applications/Xcode.app/Contents/Developer<br> <br> Setup proper provisioning profile and certificate for code signing identity and run below command on terminal<br> <br> <strong>flutter build ios</strong><br> <br> You should be able to open Xcode workspace — (Ex: Runner.xcworkspace) inside the iOS folder under the project file and Build the application.<br> <br> Some dependency we need to check for example if Firebase is integrated then we need to include <strong>GoogleService-Info.plist</strong> file manually. (edited).</p><h3><strong>Jenkins</strong></h3><p><em>In this article, I will document how to achieve a fully working continuous integration system for an android application using Jenkins.</em></p><blockquote>We at <a href="http://nonstopio.com/">NonStopIO Technologies</a>, wanted to automated unit testing, and creating the builds. After the initial round of discussion with internal team ans we picked up Jenkins as our continuous integration tool and following is our learning from it.</blockquote><p><em>Firstly, I downloaded Jenkins from the official </em><a href="https://jenkins.io/">website</a><em>.</em></p><h3>Next Step: Configure Jenkins</h3><ol><li>Manage Jenkins &gt; Configure System</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/949/1*yYnfCDmv44DksfKYmpXXtw.png" /><figcaption>download Jenkins from official Jenkins</figcaption></figure><h3>Next Step: Configure Jenkins</h3><ol><li>Manage Jenkins &gt; Configure System</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/937/1*rLu0c3-lDy8N0QxLWQ7rdA.png" /><figcaption>Setting up new build apk</figcaption></figure><p>Mentioned the ANDROID_HOME as my Android SDK path variable in <strong>Global properties.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vTyeg_lrpExdJCKryRrUXA.png" /><figcaption>setup Android-Home path in Jenkins</figcaption></figure><p>2. Manage Jenkins &gt; Global Tool Configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/541/1*fqJEvZrzJShQWR5qhJq16g.png" /></figure><p>Here I told Jenkins where it can find GIT.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4_K_sm_OIsrVWpceeM4jOg.png" /><figcaption>Adding git URL to Flutter</figcaption></figure><h3>Next Step: Add New Item</h3><p><strong>Adding New Item is the easy part. Enter Item Name [ Android Application/Project Name ] and Select Freestyle project.</strong></p><p><em>Click OK.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*ORlVvx2dikkwjtW4hHV1Pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Bfy0FIc0MevWHd5zdtdEwQ.png" /></figure><h3>Next Step: Configure New Item</h3><p>Next, go to <strong>Source Code Management. </strong>Configure your repository with Jenkins like below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LOEn5ZcKkMGk5aKgDF4NWQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-0LVzzDdYzDOGPOxPTnHEw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*4cBp2_Vdw5We6gyvSor1lg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-YYkLsyIyQcLKsBhnFcR8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hirihURiTpqkCEUj6TcF5w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSG9NyQqlX5mgEJjUk1ZVA.png" /></figure><h4>What is the future in flutter?</h4><p>A <strong>Future</strong> is used to represent a potential value, or error, that will be available at some time in the <strong>future</strong>. Receivers of a <strong>Future</strong> can register callbacks that handle the value or error once it is available.</p><h3>Is Dart a statically typed language?</h3><p>Yes, Dart 2 is statically typed. For more information, read about <a href="https://dart.dev/guides/language/sound-dart">Dart’s type system</a>.</p><p>With its combination of static and runtime checks, Dart has a sound type system, which guarantees that the expression of one type cannot produce a value of another type. No surprises!</p><p>Even with type-safe Dart, you can annotate any variable with dynamic if you need the flexibility of a dynamic language. The dynamic type itself is static but can contain any type at runtime. Of course, that removes many of the benefits of a type-safe language for that variable.</p><h3><strong>Circular Loader Implementation</strong></h3><ul><li>The loading screen will be developed as a Widget in Flutter.</li><li>Extending State class to contain the loading message</li></ul><h3>Dependencies:</h3><p><strong>progress_hud ^1.1.0</strong></p><h3>Import class file:</h3><h3>import ‘package:progress_hud/progress_hud.dart’;</h3><p><strong>Loader color and message:</strong></p><p><strong>progressHUD </strong>= <strong>new </strong>ProgressHUD(</p><p>backgroundColor: Colors.<em>white</em>,</p><p>color: Colors.<em>grey</em>,</p><p>containerColor: Colors.<em>white</em>,</p><p>borderRadius: 5.0,</p><p>text: <strong>‘Loading…’</strong>,</p><p>);</p><h3><strong>Crashlytics Integration using Fabrics</strong></h3><ul><li>Registration of application with Fabric.</li><li>To setup Crashlytics on Android side, you need to set under your manifest the Fabric ID like:</li></ul><p>&lt;meta-data</p><p>android:name=”io.fabric.ApiKey”</p><p>android:value=”YOUR_ID_HERE” /&gt;</p><ul><li>You also need to change you build.gradle file like:</li></ul><p>buildscript {</p><p>repositories {</p><p>…</p><p>maven { url ‘https://maven.fabric.io/public&#39; }</p><p>}</p><p>dependencies {</p><p>classpath ‘io.fabric.tools:gradle:1.+’</p><p>…</p><p>}</p><p>}</p><p>And apply the fabric plugin apply plugin: ‘io.fabric’</p><ul><li>Under your main method, add:</li></ul><p>FlutterError.onError = (FlutterErrorDetails details) <strong>async</strong> {</p><p><strong>await</strong> FlutterCrashlytics().onError(details);</p><p>};</p><h3><strong>Firebase Analytics Integration :</strong></h3><ul><li>Registration of application with Firebase.</li><li>You also need to change your pubspace.yaml file like:</li></ul><p><strong>dependencies:</strong></p><p><strong>flutter:</strong></p><p><strong>SDK: </strong>flutter</p><p><strong>firebase_analytics: ^2.1.1+3</strong></p><p>Under your main method, add:</p><ul><li>Create FirebaseAnalytics instance like below.</li></ul><p><strong>static </strong>FirebaseAnalytics <em>analytics </em>= FirebaseAnalytics();</p><p><strong>static </strong>FirebaseAnalyticsObserver <em>observer </em>=</p><p>FirebaseAnalyticsObserver(analytics: <em>analytics</em>);</p><ul><li>After creating instance use below method to trigger the event in application.</li></ul><p><strong>await analytics</strong>.setCurrentScreen(</p><p>screenName: servicename,</p><p>screenClassOverride: <strong>this</strong>.<strong>runtimeType</strong>.toString()</p><p>);</p><ul><li>After events triggered check the triggered events in Firebase console <a href="https://console.firebase.google.com/">https://console.firebase.google.com</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1905dbb66e2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hard ware integration in a flutter]]></title>
            <link>https://medium.com/@rajesh.muthyala/hard-ware-integration-in-a-flutter-ab0eafd7ea82?source=rss-44721f9dd99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab0eafd7ea82</guid>
            <category><![CDATA[installation]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[hardware]]></category>
            <dc:creator><![CDATA[Rajesh muthyala]]></dc:creator>
            <pubDate>Mon, 13 May 2019 12:37:36 GMT</pubDate>
            <atom:updated>2019-05-13T12:37:36.745Z</atom:updated>
            <content:encoded><![CDATA[<p>pub.dartlang.org was the service provider for the native access of hardware for a flutter.</p><p><a href="https://pub.dartlang.org/flutter">https://pub.dartlang.org/flutter</a></p><p>To Use Plugin:</p><p>declare a dependency on the pubspec.yaml of the project<br> 1. dependencies:<br> speech_recognition: &quot;^0.2.0+1&quot;</p><p>2. get the package and build the app<br>flutter packages get</p><p>flutter packages get</p><p>3. Import packages in your dart file</p><p>ex: import &#39;package:speech_recognition/speech_recognition.dart&#39;;</p><p>Sometimes Flutter needs to check special permission for IOS we need P.list for IOS.</p><p>for Android Manifest.xml<br> <br> 1. Permission handler 3.0.0 <br> <br> A permissions plugin for Flutter. This plugin provides a cross-platform (iOS, Android) API to request and check permissions.</p><p>Check if permission is granted.<br> • Request permission for a specific feature.<br> • Open app settings so the user can enable permission.<br> • Show a rationale for requesting permission (Android).</p><p>Add dependency in pubspec.yaml <br>dependencies:<br> permission_handler: ‘².2.0’</p><p>Add dependency in pubspec.yaml <br>dependencies:<br> permission_handler: ‘².2.0’</p><p>Import permission handler .dart;<br>import ‘package:permission_handler/permission_handler.dart’;</p><p>Map&lt;PermissionGroup, PermissionStatus&gt; permissions = await PermissionHandler().requestPermissions([PermissionGroup.contacts]);</p><p>List of permissions to be need permission</p><p>Calander, Camera, contacts, location, microphone, photos, remainders</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab0eafd7ea82" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[App size in Flutter]]></title>
            <link>https://medium.com/@rajesh.muthyala/app-size-in-flutter-5e56c464dea1?source=rss-44721f9dd99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5e56c464dea1</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Rajesh muthyala]]></dc:creator>
            <pubDate>Mon, 13 May 2019 11:10:16 GMT</pubDate>
            <atom:updated>2019-05-13T11:10:16.450Z</atom:updated>
            <content:encoded><![CDATA[<p>The apk size in debug mode for flutter is too big because</p><p>In August 2018, we measured the size of a minimal Flutter app (no Material Components, just a single Center widget, built with flutter build apk), bundled and compressed as a release APK, to be approximately 4.7MB.</p><p>For this simple app, the core engine is approximately 3.2MB (compressed), the framework + app code is approximately 840KB (compressed), the LICENSE file is 55KB (compressed), necessary Java code (classes.dex) is 57KB (compressed), and there is approximately 533KB of (compressed) ICU data.</p><p>Of course, YMMV, and we recommend that you measure your own app, by running flutter build apk and looking at build/app/outputs/apk/release/app-release.apk.</p><p>Please refer below link for the:</p><p>For different framework and different sizes</p><p><a href="https://android.jlelse.eu/comparing-apk-sizes-a0eb37bb36f.">https://android.jlelse.eu/comparing-apk-sizes-a0eb37bb36f.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5e56c464dea1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter for Mobile Applications]]></title>
            <link>https://medium.com/@rajesh.muthyala/flutter-for-mobile-applications-da9f7b2b8c07?source=rss-44721f9dd99d------2</link>
            <guid isPermaLink="false">https://medium.com/p/da9f7b2b8c07</guid>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Rajesh muthyala]]></dc:creator>
            <pubDate>Mon, 13 May 2019 10:19:29 GMT</pubDate>
            <atom:updated>2019-05-13T10:19:29.304Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Flutter?</h3><p>Flutter is a mobile app SDK for building high-performance, high-fidelity, apps for iOS and Android, from a single codebase.</p><p>The goal is to enable developers to deliver high-performance apps that feel natural on different platforms. We embrace differences in scrolling behaviors, typography, icons, and more.</p><h3>Why use Flutter?</h3><p>What are some advantages of Flutter? It helps you:</p><ul><li>Be highly productive</li><li>Develop for iOS and Android from a single codebase</li><li>Do more with less code, even on a single OS, with a modern, expressive language and a declarative approach</li><li>Prototype and iterate easily</li><li>Experiment by changing code and reloading as your app runs (with hot reload)</li><li>Fix crashes and continue debugging from where the app left off</li><li>Create beautiful, highly-customized user experiences</li><li>Benefit from a rich set of Material Design and Cupertino (iOS-flavor) widgets built using Flutter’s own framework</li><li>Realize custom, beautiful, brand-driven designs, without the limitations of OEM widget sets</li></ul><h3>Things you might wanna consider before moving to flutter development</h3><h3>1. It is not a LANGUAGE, it’s an SDK:</h3><p>Flutter is not a language, rather an SDK just like Android SDK. For Android development <strong>Java/Kotlin</strong> are the programming languages, for cross-platform development using flutter, <strong>DART</strong> is the official programming language.</p><p>According to the official website of a flutter: “Flutter is Google’s mobile app SDK for crafting high-quality native interfaces on iOS and Android in record time. Flutter works with existing code, is used by developers and organizations around the world, and is free and open source.”</p><p>An SDK (Software Development Kit) is really a toolkit. It contains all the libraries, tools, documentation, etc. required to build software. It is an accessory and not a programming language. If you want to learn flutter development, you have to consider learning the DART language, which is pretty easy if you’re already familiar with any OOP language.</p><h3>2. It is still in RELEASE PREVIEW</h3><p>Although it is being used by companies such as Alibaba, they are only using it in some parts of their app. <a href="https://www.flutter.io/">Flutter is in its </a>RELEASE PREVIEW and will have a stable launch on 4th December 2018. This is one of the reasons why some developers are still skeptical about going all out with flutter and porting their apps to flutter.</p><p>Having said this, I personally did not find any bugs while developing an app using flutter. I can’t say about other developers. If you found any bugs or hiccups, do mention in the comments below.</p><h3>3. It does not have a very large support community</h3><p>You might have to wait a little longer to get your questions answered on <strong>Stack Overflow</strong> XD. Flutter is still relatively new and does not have a community as large as other cross-platform solutions such as React Native or pure native apps.</p><p>The community is growing day by day and I believe after it’s <a href="https://developers.google.com/events/flutter-live/">stable launch on 4th December 2018</a> it would really explode.</p><p>But if you are someone who is afraid of documentation (although I believe Flutter has one of the best documentations present online. I personally didn’t need to refer to any other source than the official docs) then this might be a setback to you.</p><h3>4. Everything is a Widget</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/0*MhLzYoDUgY73xOuT.png" /></figure><p>Now this one might take some time getting used to. Everything in Flutter is a widget. Even the app itself is a complete widget.</p><p>It is not intuitive for anyone getting started, to think <strong>widgetly</strong> (yes, I just made that up :P). The layouts are widgets, the typography is a widget, color is a widget, a button is a widget.</p><p>It doesn’t sound <strong>intuitive</strong>. When we think of widgets the first thing that comes into our mind is that it might be a part of an application. It might be a module. But to think that it is a complete app itself is something that’s going to take some time to wrap your heads around.</p><p>It might take you <strong>a few days to a month</strong> to get comfortable with flutter. Adding margins, paddings and other attributes are not intuitive at first. Also, you’ll need to spend some time understanding <strong>Box constraints</strong>.</p><p>But once you get a hang of it, you’ll get to know that it was totally worth the pain.</p><h3>5. DART is the official programming language</h3><p>Say what <strong>DART</strong>!!</p><p>That’s the <strong>reaction</strong> of most of the people when they first hear about DART. DART is a general-purpose programming language developed by Google in 2011. It is a client optimized language used to build beautiful mobile and web <strong>applications</strong>.</p><p>Developers at <strong>Google</strong> and elsewhere use Dart to create high-quality, mission-critical apps for iOS, Android, and the web. With features aimed at client-side development, Dart is a <strong>great fit </strong>for both mobile and web apps.</p><p>The apps built using <strong>DART</strong> are real native apps whose code compiles down to JAVA byte code, so at the machine level, it is indistinguishable from real native apps.</p><p>Having said all that, it is still not a very <strong>popular</strong> programming language and you might have to spend some time understanding all the syntactical sugar.</p><h3>6. A bigger APK size</h3><p>Don’t be surprised if you see your newly created, fresh out of the oven flutter app bigger in size than it’s native counterpart by <strong>50–60%</strong>.</p><p>Flutter apps (even React Native apps) have a considerably larger size than their native counterparts. <strong>I have even seen some trivial flutter apps 6–7 MB in size</strong>.</p><p>So, this is something you might wanna consider if your app is already large in size. You don’t want to scare off your users with a huge bloated <strong>APK</strong>.</p><h3>7. Not all features are supported</h3><p>If your app communicates with any hardware via <strong>Bluetooth </strong>then you’d have to develop these features <strong>separately</strong> for iOS and Android and integrate them into a flutter. In this case, one of the major selling points of cross-platform development i.e. time, will <strong>not be much beneficial</strong> as you’d end up spending time to create these features natively for both the apps.</p><h3>8. Still not comparable to a pure Native App</h3><p>This is a point that’s applicable to not only flutter but all the cross-platform solutions such as react native etc. Their performance is not even near to that of a native app.</p><p><a href="https://ayusch.com/native-vs-hybrid/"><em>I have done a full comparison here.</em></a></p><p>In comparison to native apps, they use approximately 30% more memory and are also less CPU efficient.</p><h4>Flutter Architecture — The Technical Overview</h4><p>Flutter is developed using C, C++, Dart, and Skia (a 2D rendering engine). The architecture diagram below presents a better picture of the three key layers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/635/0*65AMye5YbVnV0b8x" /></figure><p>above image specifies the structure of flutter framework:-</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=da9f7b2b8c07" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>