<?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 Matthew Smith on Medium]]></title>
        <description><![CDATA[Stories by Matthew Smith on Medium]]></description>
        <link>https://medium.com/@matthew.smith_66715?source=rss-69664ffa26b2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*YG29TPg6eOFZNr3h.</url>
            <title>Stories by Matthew Smith on Medium</title>
            <link>https://medium.com/@matthew.smith_66715?source=rss-69664ffa26b2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:08:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@matthew.smith_66715/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[Maps in Flutter]]></title>
            <link>https://medium.com/@matthew.smith_66715/maps-in-flutter-a1ac49ab554b?source=rss-69664ffa26b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/a1ac49ab554b</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[maps]]></category>
            <dc:creator><![CDATA[Matthew Smith]]></dc:creator>
            <pubDate>Tue, 23 Jan 2018 02:16:03 GMT</pubDate>
            <atom:updated>2018-01-23T02:16:03.844Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*E6d-rt-ij_vCFHiJG_badw.png" /></figure><p>At AppTree, we recently <a href="https://medium.com/@matthew.smith_66715/why-we-chose-flutter-and-how-its-changed-our-company-for-the-better-271ddd25da60">made the jump to Flutter</a> to replace our existing iOS and Android applications. A major part of our application is mapping.</p><p>Flutter is still in alpha and as such, still has functional areas yet to be completely built out. However we find Flutter to be so useful that we prefer to fill any gaps ourselves rather than waiting to adopt it when it’s fully matured. Fortunately, the Flutter team has come up with a great solution by allowing early adopters to build <a href="https://flutter.io/developing-packages/">plugins</a>.</p><p><strong>Introducing the </strong><a href="https://pub.dartlang.org/packages/map_view"><strong>MapView plugin</strong></a></p><p>As anybody who has used it knows, the GoogleMaps SDK has a large API. We are attempting to tackle the most common use cases first. We started with:</p><ul><li>Markers</li><li>Camera Updates</li><li>Map callbacks</li><li>The ability to show maps inline ( via the <a href="https://developers.google.com/maps/documentation/static-maps/">Google Maps Static API</a> )</li></ul><p>Currently, rendering a native iOS or Android view like a MapView inside of your Flutter hierarchy <a href="https://github.com/flutter/flutter/issues/73">is a work in progress</a>. Our alternative solution is to use the <a href="https://developers.google.com/maps/documentation/static-maps/">Google Maps Static API</a> for showing maps inline while using the Google Maps SDK for iOS and Android to allow the user to interact with the maps full screen.</p><p>We’ve also built in some convenience methods for generating a static maps given the same viewport and markers you have on the full interactive map.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*U2L7HerTtWxbm3ZE2J9HmQ.gif" /></figure><p>To demonstrate the use of the plugin, I’ve built a simple app called “NomNom”. The purpose of this application is to find and favorite great restaurants in Portland. You can download the sample project source code <a href="https://github.com/matthewtsmith/flutter_map_demo">here</a>.</p><h3>Creating your API Key</h3><p>When using the Google Maps plugin, you first need to create your Google Maps API key. Sign in to <a href="https://console.developers.google.com/">https://console.developers.google.com/</a>. If you’ve never used the Google API console before it may ask you to setup a new project.</p><p>Once you have your project selected, use the button on the dashboard labeled “Enable APIs and Services”. Depending on the features you use within the plugin, there are 3 APIs to enable</p><ul><li>Android — Enable the ‘Google Maps Android API’</li><li>iOS — Enable the ‘Google Maps iOS API’</li><li>Static Inline Maps — Enable the ‘Google Static Maps API’</li></ul><p>For the purposes of this demo, we are also using the ‘Google Places API Web Service’. Enable this one as well.</p><p>Next you need to generate an API key. In the drawer on the left hand side, tap on ‘Credentials’. Then tap the ‘Create Credentials’ button and select ‘API Key’.</p><p>This will create a new API key that has access to all of the API’s you’ve enabled. It is recommended to restrict the key for production use but for the purposes of this example we’ll leave it as is.</p><p>Now that you have the API key, you’ll want to add it to your sample project. At the top of the main.dart file modify the following line to use your API key:</p><pre>var apiKey = &quot;&lt;your_api_key&gt;&quot;;</pre><p>You’ll notice our main() function looks like this:</p><pre>void main() {<br>  var manager = new FavoritesManager();<br>  MapView.setApiKey(apiKey);<br>  runApp(new MyApp(manager));<br>}</pre><p>It’s important that the MapView.setApiKey() method is called before accessing any of the map plugins APIs.</p><h3>Displaying a full screen interactive map</h3><p>The first thing that a user will want to do in NomNom is start adding their favorite restaurants. When a user taps the + button in the lower right hand corner of the screen, we want to display our full screen map. That is handled by the Future _addFavorite() method inmain.dart.</p><pre>Future _addFavorite() async {<br>  //1. Show the map<br>  mapView.show(<br>      new MapOptions(<br>          showUserLocation: true,<br>          title: &quot;Choose a favorite&quot;,<br>          initialCameraPosition: new CameraPosition(new Location(45.512287, -122.645913), 18.0)),<br>      toolbarActions: &lt;ToolbarAction&gt;[new ToolbarAction(&quot;Close&quot;, 1)]);<br>  <br>  //2. Listen for the onMapReady<br>  var sub = mapView.onMapReady.listen((_) =&gt; _updateRestaurantsAroundUser());<br>  compositeSubscription.add(sub);<br><br>  //3. Listen for camera changed events<br>  sub =<br>      mapView.onCameraChanged.listen((cam) =&gt; _updateRestaurantsAroundUser());<br>  compositeSubscription.add(sub);<br><br>  //4. Listen for toolbar actions<br>  sub = mapView.onToolbarAction.listen((id) {<br>    if (id == 1) {<br>      mapView.dismiss();<br>    }<br>  });<br>  compositeSubscription.add(sub);<br>}</pre><ol><li>First we show the map.</li></ol><p>The first argument to MapView.show is the MapOptions. Here you can define things like the initial view port, the map type ( Normal, Satellite, Hybrid ) and whether to show the users location.</p><p>The show method also takes an optional list of ToolbarAction. To keep the full screen map as flexible as possible, we allow you to pass in your own toolbar items. Each toolbar item has a title and identifier.</p><p>2. Next we’ll listen for onMapReady. This method is called once the map is initialized. In our example, we want to find restaurants in the visible viewport of the map so we call _updateRestaurantsAroundUser(). More on that method later.</p><p>3. In Nom Nom, as the user moves the map, we want to update the markers on the map to show the restaurants in the new viewport. We can call the same _updateRestaurantsAroundUser() method to do that.</p><p>4. Lastly, we want to listen for any toolbar actions. Using onToolbarAction we can listen for any toolbar button presses. This stream sends the identifier that you provided when you created the ToolbarItemin step 1. In this case we only have one toolbar item that closes the map view if the user wants to cancel out of adding a favorite.</p><h3>Finding restaurants within the MapView</h3><p>As users move the map around we want to show pins on the map for the restaurants in that area. To find the restaurants we are going to use the Google Places API. This API is not part of the MapView plugin but luckily a quick search on <a href="http://pub.dartlang.org/">pub.dartlang.org</a> produced <a href="https://pub.dartlang.org/packages/google_maps_webservice">this plugin</a> so we can easily add this functionality to our app.</p><p>As mentioned earlier, the onCameraChanged callback calls _updateRestaurantsAroundUser. Let’s break down this method:</p><pre>Future _updateRestaurantsAroundUser() async {<br>  //1. Ask the mapView for the center lat,lng of it&#39;s viewport.<br>  var mapCenter = await mapView.centerLocation;<br>  //2. Search for restaurants using the Places API<br>  var placeApi = new places.GoogleMapsPlaces(apiKey);<br>  var placeResponse = await placeApi.searchNearbyWithRadius(<br>      new places.Location(mapCenter.latitude, mapCenter.longitude), 200,<br>      type: &quot;restaurant&quot;);<br><br>  if (placeResponse.hasNoResults) {<br>    print(&quot;No results&quot;);<br>    return;<br>  }<br>  var results = placeResponse.results;<br><br>  //3. Call our _updateMarkersFromResults method update the pins on the map<br>  _updateMarkersFromResults(results);<br><br>  //4. Listen for the onInfoWindowTapped callback so we know when the user picked a favorite.<br>  var sub = mapView.onInfoWindowTapped.listen((m) {<br>    var selectedResult = results.firstWhere((r) =&gt; r.id == m.id);<br>    if (selectedResult != null) {<br>      _addPlaceToFavorites(selectedResult);<br>    }<br>  });<br>  compositeSubscription.add(sub);<br>}</pre><ol><li>First we ask the mapView for it’s current center location. This is the center point we will use to search fo restaurants.</li><li>Next we use the Places plugin to request nearby restaurants.</li><li>Now that we have the results we’ll want to update the markers on the map. To do this we call _updateMarkersFromResults(results);. More on this method later.</li><li>Lastly, when the user taps on the name of the restaurant, we want to add it as a favorite. To be notified of this tap, we can use the onInfoWindowTapped stream. The item emitted on this stream is the Marker that the user tapped on. Now that we know what marker they’ve selected, we can add that place to their favorites list by calling _addPlaceToFavorites.</li></ol><h3>Adding Markers to the Map</h3><p>In our last step, after finding restaurants, we called _updateMarkersFromResults to place pins on the map. Lets explore this method.</p><p>The MapView plugin contains the following methods</p><ul><li>MapView.setMarkers</li><li>MapView.addMarker</li><li>MapView.removeMarker</li></ul><p>We could use the setMarkers but that will remove all current markers and then set them again. The disadvantage to this approach is that you are clearing all marker states. This means that if you currently have a marker selected, that selection will be cleared when removed. Instead we want to only add new places and remove places that are no longer visible on the map. For that, we are going to use the addMarker and removeMarker methods.</p><pre>void _updateMarkersFromResults(List&lt;places.PlacesSearchResult&gt; results) {<br>  //1. Turn the list of `PlacesSearchResult` into `Markers`<br>  var markers = results<br>      .map((r) =&gt; new Marker(<br>          r.id, r.name, r.geometry.location.lat, r.geometry.location.lng))<br>      .toList();<br>  <br>  //2. Get the list of current markers<br>  var currentMarkers = mapView.markers;<br>  <br>  //3. Create a list of markers to remove<br>  var markersToRemove = currentMarkers.where((m) =&gt; !markers.contains(m));<br>  <br>  //4. Create a list of new markers to add<br>  var markersToAdd = markers.where((m) =&gt; !currentMarkers.contains(m));<br>  <br>  //5. Remove the relevant markers from the map<br>  markersToRemove.forEach((m) =&gt; mapView.removeMarker(m));<br>  markersToAdd.forEach((m) =&gt; mapView.addMarker(m));<br>}</pre><ol><li>First we need to turn the list of PlaceSearchResults we got back from the Places API into a list of Marker . The Marker class takes an identifier, name, and lat/lng. Optionally, you can also provide a pin color.</li><li>Get the current markers that were previously added to the map. This is going to be the list we compare against to determine whether a marker needs to be added or removed</li><li>Create a list of markers to remove by finding any marker that is no longer contained in our updated results.</li><li>Create a list of markers to add by finding any marker in results that does not currently exist in the currentMarkers.</li><li>For each marker in the remove and add list, call the removeMarker or addMarker.</li></ol><h3>Conclusion</h3><p>We hope that with this plugin you’ll be able to start using maps in your Flutter applications. At AppTree, we will continue to evolve this plugin to try to cover the expansive Google Maps API. If you are interested in filing feature requests or contributing you can find the source <a href="https://github.com/apptreesoftware/flutter_google_map_view">here</a>. Our team also tries to stay active on the <a href="https://gitter.im/flutter/flutter">Flutter Gitter channel</a> so we will also try to respond to questions there as we see them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a1ac49ab554b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why we chose Flutter and how it’s changed our company for the better.]]></title>
            <link>https://medium.com/@matthew.smith_66715/why-we-chose-flutter-and-how-its-changed-our-company-for-the-better-271ddd25da60?source=rss-69664ffa26b2------2</link>
            <guid isPermaLink="false">https://medium.com/p/271ddd25da60</guid>
            <category><![CDATA[web]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Matthew Smith]]></dc:creator>
            <pubDate>Tue, 23 Jan 2018 02:15:30 GMT</pubDate>
            <atom:updated>2018-01-23T02:15:30.983Z</atom:updated>
            <content:encoded><![CDATA[<h4>An appeal to the native iOS and Android developers of the world — there is a better way.</h4><p>Google’s <a href="https://flutter.io/">Flutter</a> is a mobile app development framework that allows you to quickly build applications for iOS and Android. <a href="https://hackernoon.com/whats-revolutionary-about-flutter-946915b09514">Read about what is revolutionary about Flutter.</a></p><h3>A little background</h3><p>My days of native development go back to <a href="https://en.wikipedia.org/wiki/Installer.app">Installer</a> where I first developed a Podcast app. Over the past decade I’ve created dozens of applications for customers like Comcast and Associated Press. I’ve been a native developer to the core.</p><p>Over the course of my career, I’ve spent a lot of time building custom enterprise software. These experiences led me from agency/contract work to try to solve a problem… enterprise software is ridiculously hard to build, deploy, support and terrible to use. I co-founded <a href="https://www.apptreesoftware.com/">AppTree Software</a> and we set out to make enterprise software easier.</p><p>We set out to build a platform to make it easier for developers to build, support and deploy enterprise applications. We built mobile clients and SDKs so that your apps could inherit solutions to the complex problems of enterprise software right out of the box. Our goal being that you’d only have to worry about your specific business logic.</p><h3>Taking the `native` approach</h3><p>Due to the nature of enterprise software, we needed to handle hundreds of thousands of records, work offline, and be extremely secure. Naturally, we wrote our apps natively using the iOS and Android SDKs. At every turn, I rejected cross platform frameworks. They were too slow, the tooling was bad, and your UI still had to be written twice.</p><p>While native development provided the end result we needed, it was a lot overhead in both initial coding and ongoing support. To get the performance and control we needed with native app clients meant writing everything twice, hiring was difficult, and the compile times… my god the compile times (looking at you Swift). We did everything we could to make our app clients similar across the two platforms. We used Swift on iOS and Kotlin on Android. We used Realm as a cross platform data store, we used RxSwift and RxJava.</p><p>We then decided to add a third platform into the mix… the web. I set out to find a language and tooling for the our web client that met the demands of our platform and landed on Dart.</p><p>We proceeded to take all the capability in our mobile apps and build it again in Dart so our customers could run their applications in a browser.</p><h3>Hitting a wall</h3><p>Feature development began to drag. Now we were writing every feature three times. We had three distinct teams and as with all startups, we were trying to move very fast. Our overall productivity slowed, all of my time was spent synchronizing features and ideas across teams, architecture started to diverge, and QA time increased and quality suffered.</p><p>As part of the Dart community, we heard the rumblings of Flutter. Being a native developer for many years, I had grown a healthy skepticism towards cross platform frameworks. However, this seemed different. We loved our experience with Dart so far and <a href="https://flutter.io/technical-overview/">the approach</a> that the Flutter team was taking to the cross platform problem felt right.</p><p>Our excitement about Flutter grew at Google Developer Group meetup in Portland on the subject of Flutter. Coming out of the meetup, we were interested. Flutter felt like it might work for us.</p><p>I went to work that night building a presentation for myself to see where I landed on the Flutter question. By the end of this exercise, I was convinced that our company should move to Flutter. And we should do it immediately.</p><p>Here it is…</p><h3>The Pitch</h3><p>My presentation started with the cons of using something like Flutter.</p><p><strong>Why we should not use Flutter</strong></p><ul><li>New technology, APIs can change</li><li>No built in Flutter support for things like Maps, Camera. Must use native APIs</li><li>No support for Realm. We must rethink persistent storage.</li><li>Not a lot of third party library support. We use Pusher, Signature Capture, Photo editing etc.</li></ul><p><strong>Do the above reasons matter?</strong></p><ul><li><strong>New technology, APIs can change</strong> — Not really, Google has been using internally for production, there are multiple apps in the app stores. I really only see them adding missing APIs.</li><li><strong>No built in Flutter support for things like Maps, Camera. Must use native APIs — </strong>No, We’ve already written these in iOS and Android. That code can be mostly re-used via a <a href="https://flutter.io/developing-packages/">plugin</a>. See our resulting <a href="https://pub.dartlang.org/packages/map_view">maps plugin</a>.</li><li><strong>No support for Realm. We must rethink persistent storage. — </strong>Yes, this matters and it will be a majority of our work in the re-write.</li><li><strong>Not a lot of third party library support. We use Pusher, Signature Capture, Photo editing etc — </strong>Similar to maps, we can write a plugin wrapper around the third party libraries so they can be used in Flutter. Which we did <a href="https://pub.dartlang.org/packages/pusher_flutter">here</a>, <a href="https://pub.dartlang.org/packages/barcode_scan">here</a> and <a href="https://pub.dartlang.org/packages/flutter_web_view">here</a>.</li></ul><p><strong>Why Flutter: The UI Framework</strong></p><ul><li>Modern API. The Flutter team has done an amazing job coming up with an API that solves our most common mobile needs all while keeping it highly customizable.</li><li>Perfectly fits our navigation needs. Also lets us share navigation concepts across web.</li><li>Open Source</li><li>Reactive Views</li><li>Modern &amp; fast tooling</li><li>Does it’s own rendering using Skia. It finally means that your UI and navigation can be written once and shared across iOS and Android.</li></ul><p><strong>Why Flutter: The development cycle</strong></p><ul><li>Android Full Compile — 2:10 sec</li><li>Android Incremental Compile — 20sec</li><li>iOS Full Compile — 2:40 sec</li><li>iOS Incremental Compile — 40 sec</li><li>Flutter Full Compile — 25 seconds. On iOS, this includes building the Dart code, running pod install, and the xcodebuild command. The results are similar on Android since it uses the gradle build process.</li><li>Incremental Compile — sub second thanks to the amazing <a href="https://flutter.io/hot-reload/">hot reload</a>.</li></ul><p><strong>Why Flutter: Unit testing</strong></p><p>Android Unit Testing</p><ul><li>Good support. Can run on the JVM without Android if you mock Android specific classes.</li><li>Compile time 5 sec</li><li>Run time 1.5 sec</li></ul><p>iOS Unit testing</p><ul><li>Can only run on iOS simulator. ( There are ways to get around this by moving non iOS dependent code into sub frameworks, this would have been a major re-work for us.)</li><li>Compile time 40–2:40sec</li><li>Run time 10 sec.</li></ul><p>Dart</p><ul><li>Fantastic support. Easy to specify which tests can run on VM.</li><li>Sub second compile time</li><li>Runtime 1 sec.</li></ul><p>But of course the greatest benefit is we are only writing our tests once.</p><p><strong>Why Flutter: Code Sharing</strong></p><ul><li>95% code re-use across iOS and Android. Our own plugins being the only exception</li><li>60% code re-use between Flutter and Web.</li><li>Major architecture changes only happen once, not across 3 different platforms.</li><li>Because Flutter is it’s own UI/Widget library, we do not have to deal with implementation details of iOS &amp; Android (ie. Android Activity, Fragments, message passing etc.)</li></ul><p><strong>Why Flutter: QA Testing</strong></p><ul><li>Very high confidence that tests of iOS will be valid for Android &amp; Web.</li><li>Specific Platform QA can be limited to when native components are used</li><li>50% reduction in QA time</li></ul><p><strong>Why Flutter: Team Scalability</strong></p><ul><li>Much easier to hire. We now look to take the best candidate regardless if they are from Web, iOS or Android.</li><li>We have 3x the bandwidth now that all of our teams are consolidated on a single code base.</li><li>Knowledge sharing is at an all time high</li></ul><h3><strong>Giving it a go</strong></h3><p>Having sold myself on Flutter, I gave the same presentation to my CEO. He was also convinced. I then gave the presentation to the team and got everyone on the same page.</p><p>The only way to tell if this would really work for us is to try it. We set a six week deadline to see how far we could get with flutter.</p><p>Within three weeks, we had a working prototype app client. We were able to do it this quickly because of a tremendous amount of code we were able to share from our Dart web client project.</p><p>We started our Flutter rewrite in October. We will be releasing our first Flutter version into production in January.</p><p>To provide some perspective, our Android app took over a year to write <strong>after </strong>our iOS app was already done.</p><p>Not only is this because there is just a lot of code to write, but you also have to find the right people to fill out a team and then train them on the complexities of your product. No more. Now we are one team and adding a new member can be a much more incremental process.</p><p>Also, rather than splitting our talents among three distinct platforms we focused members of our team on different aspects of Flutter; UI, architecture and plugins.</p><p>Our productivity on new feature development has roughly tripled. Here’s why:</p><p>Not only do we have the obvious gains from having only one code base between iOS and Android, we are able to share ~70% (at the moment of this writing it’s 67%) of our web client code with the mobile clients. But it doesn’t end there. When we test a feature in any of the platforms, unless it’s a platform specific UI change, we are effectively testing across all three platforms at once. We did not expect this gain, but it’s real and it’s significant. We also found that because we were able to merge what was a fragmented team into one team with a common skill set, we spend less time being blocked by each other and can more easily work together. And honestly, we are happier. While it’s fun to build a new feature, it becomes a chore to then have to recreate it two more times. Then have to write the platform specific unit tests. Then QA the same thing again.</p><p>Mobile development is fun again.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=271ddd25da60" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>