<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fré Dumazy</title>
    <description>The latest articles on DEV Community by Fré Dumazy (@dumazy).</description>
    <link>https://dev.to/dumazy</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F166174%2Fe1d9244b-e99e-4150-9b4e-20e6f6f57a39.jpeg</url>
      <title>DEV Community: Fré Dumazy</title>
      <link>https://dev.to/dumazy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dumazy"/>
    <language>en</language>
    <item>
      <title>Firebase for Flutter in DartPad</title>
      <dc:creator>Fré Dumazy</dc:creator>
      <pubDate>Thu, 11 Nov 2021 13:02:06 +0000</pubDate>
      <link>https://dev.to/dumazy/firebase-for-flutter-in-dartpad-5gi0</link>
      <guid>https://dev.to/dumazy/firebase-for-flutter-in-dartpad-5gi0</guid>
      <description>&lt;p&gt;During the &lt;a href="https://www.youtube.com/watch?v=BlMZ0XK8ZOI&amp;amp;t=1s" rel="noopener noreferrer"&gt;Firebase Summit 2021 Keynote&lt;/a&gt; Firebase announced the support for its Flutter SDKs in &lt;a href="https://dartpad.dev/" rel="noopener noreferrer"&gt;DartPad&lt;/a&gt;. This is something that provides a lot of opportunities and will definitely make it easier to experiment with both Firebase as well as Flutter. Even though the setup is pretty straight forward, I'd like to show it step by step.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase setup
&lt;/h2&gt;

&lt;p&gt;I don't want to go into too much detail about how to setup a project in Firebase since there's already a lot more resources on that and their &lt;a href="https://firebase.google.com/docs" rel="noopener noreferrer"&gt;own documentation&lt;/a&gt; provides everything you need to know. The important thing to know is that you need to have a Firebase project and have &lt;a href="https://firebase.google.com/docs/web/setup" rel="noopener noreferrer"&gt;a web app registered&lt;/a&gt;. If you go into the project settings and down to 'Your apps', you can select the 'Config' option in the 'SDK setup and configuration'. This gives a clear overview of the values you'll need.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  DartPad
&lt;/h2&gt;

&lt;p&gt;In DartPad, start by displaying the "Pub package versions" by clicking on the ℹ️ in the bottom right corner. This will show all the packages that you can import in DartPad. You should be able to see the &lt;code&gt;firebase_*&lt;/code&gt; packages listed. If you're experiencing issues, this can be a good reference to know which version of these you are actually using.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Initialize Firebase
&lt;/h2&gt;

&lt;p&gt;Initializing the Firebase SDK is almost only a matter of copying your web app's configuration into the &lt;code&gt;FirebaseOptions&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:flutter/material.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:firebase_core/firebase_core.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="n"&gt;Future&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;void&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="kd"&gt;async&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;WidgetsFlutterBinding&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;ensureInitialized&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Firebase&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nl"&gt;options:&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;FirebaseOptions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;apiKey:&lt;/span&gt; &lt;span class="s"&gt;"AIzaAbCdEf..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;authDomain:&lt;/span&gt; &lt;span class="s"&gt;"my-project-id.firebaseapp.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;projectId:&lt;/span&gt; &lt;span class="s"&gt;"my-project-id"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;storageBucket:&lt;/span&gt; &lt;span class="s"&gt;"my-project-id.appspot.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;messagingSenderId:&lt;/span&gt; &lt;span class="s"&gt;"012345678912"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="nl"&gt;appId:&lt;/span&gt; &lt;span class="s"&gt;"1:012345678912:web:abc123..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;runApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;MyApp&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are 3 steps in this process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Call &lt;code&gt;WidgetsFlutterBinding.ensureInitialized();&lt;/code&gt; to avoid  calls to the framework before it's actually ready.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Initialize the Firebase SDK with the values that are found in the Firebase Console under your web app's configuration. Depending on your app, it's probably important that you &lt;code&gt;await&lt;/code&gt; this before moving on to the last step.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The last step is simply running your initial widget with the &lt;code&gt;runApp()&lt;/code&gt; function.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Calling the Firebase SDK
&lt;/h2&gt;

&lt;p&gt;Now you just need to verify if this is correct. I'll use &lt;a href="https://firebase.google.com/docs/firestore" rel="noopener noreferrer"&gt;Cloud Firestore&lt;/a&gt; as an example here, but there are other Firebase APIs you can use in DartPad as well, such as &lt;a href="https://firebase.google.com/docs/auth" rel="noopener noreferrer"&gt;Firebase Authentication&lt;/a&gt;. Say you have a collection of 'people' that you want to display in your DartPad app.&lt;/p&gt;

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

&lt;p&gt;Then the code you'll need is nothing different than using the Firebase SDK for Flutter on another platform.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight dart"&gt;&lt;code&gt;&lt;span class="c1"&gt;// new import to add&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="s"&gt;'package:firebase_core/firebase_core.dart'&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// main method as shown above&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyApp&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;MaterialApp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;home:&lt;/span&gt; &lt;span class="n"&gt;Scaffold&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nl"&gt;body:&lt;/span&gt; &lt;span class="n"&gt;Center&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;child:&lt;/span&gt; &lt;span class="n"&gt;PeopleList&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
        &lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PeopleList&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="n"&gt;StatelessWidget&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nd"&gt;@override&lt;/span&gt;
  &lt;span class="n"&gt;Widget&lt;/span&gt; &lt;span class="n"&gt;build&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;BuildContext&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;StreamBuilder&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;QuerySnapshot&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kd"&gt;dynamic&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&amp;gt;(&lt;/span&gt;
      &lt;span class="nl"&gt;stream:&lt;/span&gt; &lt;span class="n"&gt;FirebaseFirestore&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;instance&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;collection&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'people'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;snapshots&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
      &lt;span class="nl"&gt;builder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;hasData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;CircularProgressIndicator&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;snapshot&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;requireData&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ListView&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
          &lt;span class="nl"&gt;itemCount:&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="nl"&gt;itemBuilder:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;docs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;index&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;ListTile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
              &lt;span class="nl"&gt;title:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'firstName'&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
              &lt;span class="nl"&gt;subtitle:&lt;/span&gt; &lt;span class="n"&gt;Text&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;'lastName'&lt;/span&gt;&lt;span class="p"&gt;]),&lt;/span&gt;
            &lt;span class="p"&gt;);&lt;/span&gt;
          &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As a result, the people are listed when running the app.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Setting up the Firebase SDK in DartPad is really easy and actually takes less steps than using it on another platform. I can see this having huge benefits for teaching and sharing samples. Give it a try at &lt;a href="https://dartpad.dev/" rel="noopener noreferrer"&gt;dartpad.dev&lt;/a&gt;! &lt;/p&gt;

&lt;h2&gt;
  
  
  Code sample
&lt;/h2&gt;

&lt;p&gt;If you'd like to see the full sample for this article to experiment with, it's available &lt;a href="https://dartpad.dev/b7e373d4fc0ef66d97edcf90bbc48328" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You'll need to use your own Firebase web app config and make sure you have the 'people' collection available as shown in the example above.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other notes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;I'm not a 100% sure that you need to call &lt;code&gt;WidgetsFlutterBinding.ensureInitialized();&lt;/code&gt; as the initial step. In this example it works fine without, but I added it because more complex use cases might require it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you start a new Firebase project and Cloud Firestore to test this and you're not able to fetch the data, check your &lt;a href="https://firebase.google.com/docs/firestore/security/get-started" rel="noopener noreferrer"&gt;security rules&lt;/a&gt;. I've set mine to &lt;strong&gt;test mode&lt;/strong&gt; for this article but this might not be the case for you.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This tutorial only focuses on the minimum to set up Firebase on DartPad. There might be better ways to call the Firestore APIs or to structure the code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>flutter</category>
      <category>flutterdev</category>
      <category>firebase</category>
      <category>programming</category>
    </item>
    <item>
      <title>Flutter sandbox script</title>
      <dc:creator>Fré Dumazy</dc:creator>
      <pubDate>Sat, 31 Oct 2020 14:40:43 +0000</pubDate>
      <link>https://dev.to/dumazy/flutter-sandbox-script-18fc</link>
      <guid>https://dev.to/dumazy/flutter-sandbox-script-18fc</guid>
      <description>&lt;p&gt;When I want to try out something small in Flutter, I mostly have two options. Either use DartPad or create a small sandbox project locally.&lt;/p&gt;

&lt;h2&gt;
  
  
  DartPad vs local project
&lt;/h2&gt;

&lt;p&gt;I don't always like to use DartPad because it doesn't allow me to use the setup I'm used to on my machine. Code completion isn't that great, there's no option to easily click through the framework's source code and we cannot add certain libraries.&lt;/p&gt;

&lt;p&gt;Having a sandbox project locally is nicer to work with but it requires some tedious setup. Go to a directory, create a new project, remove all the verbose comments in &lt;code&gt;main.dart&lt;/code&gt; and, if you want to run on a real iOS device, set up signing in Xcode. Quite a hassle, so I took some steps to make it easier.&lt;/p&gt;

&lt;h2&gt;
  
  
  Create a clean project
&lt;/h2&gt;

&lt;p&gt;First of all, I created a new Flutter project and set it up just as how I wanted it to have as a starting point. I made sure it was able to run on a real iOS device and simplified the &lt;code&gt;main.dart&lt;/code&gt; file:&lt;br&gt;
&lt;/p&gt;

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Sandbox',
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text("Sandbox"),
      ),
    );
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For me, this is what I mostly would like to have as a starting point for trying something out.&lt;/p&gt;

&lt;p&gt;Once this was all set up, I simply created a local Git repository and commit this on the master branch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git init
git add .
git commit -m "Initial commit"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, to start with a clean slate, I just open this project and run &lt;code&gt;git reset --hard&lt;/code&gt; to go back to this starting point. But if you've created other files that aren't tracked by Git, you need to run &lt;code&gt;git clean -f -d&lt;/code&gt; as well to remove those. This was all a bit too cumbersome for me.&lt;/p&gt;

&lt;h2&gt;
  
  
  Script it
&lt;/h2&gt;

&lt;p&gt;I simply created a script that resets this project and opens it in VS Code. It's basically just a few lines, but I wanted to add something extra to it.&lt;/p&gt;

&lt;p&gt;If I don't have any connected devices, I want to be able to run my code on an iOS simulator or Android emulator. So I added two options to the script: &lt;code&gt;-i&lt;/code&gt; for starting the simulator, &lt;code&gt;-a&lt;/code&gt; for starting the emulator or &lt;code&gt;-ia&lt;/code&gt; to start both, of course.&lt;/p&gt;

&lt;p&gt;Here's the script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#!/bin/bash

# Absolute path of the Flutter sandbox project
sandbox_path="/Users/fre.dumazy/Developer/Playground/flutter_sandbox"
# Name of Android emulator to open.
# Check with `emulator -list-avds`
avd_name="Pixel_4_API_30"

main() {
    processOptions "$@"
    resetSandbox
    openVsCode
}

openVsCode () {
    # Open the project in VS Code at the main.dart file
    code "$sandbox_path" "$sandbox_path/lib/main.dart"
}

usage () {
    echo "Usage: $0 [-i] [-a]"
}

processOptions () {
    while getopts ":ia" flag; do
        case "${flag}" in
            i) 
                startSimulator
                ;;
            a) 
                startEmulator
                ;;
            *)
                usage
                ;;
        esac
    done
}

startSimulator () {
    open -a Simulator
}

startEmulator () {
    # Start emulator in a background process and ignore logs in terminal
    emulator -avd "$avd_name" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 &amp;amp;
}

resetSandbox () {
    (cd "$sandbox_path" \
     &amp;amp;&amp;amp; git reset --hard &amp;gt; /dev/null 2&amp;gt;&amp;amp;1 \
     &amp;amp;&amp;amp; git clean -f -d &amp;gt; /dev/null 2&amp;gt;&amp;amp;1)
}

main "$@"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some values need to be configured at the top, but once that's set up, I can use it over and over again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Alias it
&lt;/h2&gt;

&lt;p&gt;Once this script was made, I added it as an alias in my &lt;code&gt;bash.profile&lt;/code&gt; so I could call this from any directory in the terminal.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias fsandbox='~/scripts/flutter_sandbox.sh'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now I can just type &lt;code&gt;fsandbox&lt;/code&gt; when ever I want to fiddle with Flutter. &lt;/p&gt;

&lt;p&gt;It's nothing special, but enables me to quickly have a sandbox project set up and avoids me from trying out stuff in existing projects, or losing time with DartPad.&lt;br&gt;
I'll probably add more features to the script in the future. One of the things I'd like is that previous changes are first committed to a separate branch with the last modification date and time as branch name, so I don't accidentally lose useful code snippets.&lt;/p&gt;

&lt;p&gt;If you haven't set up anything like this, try it out, it might help you. If you do have another way that enables you to quickly try something out, let me know, I'd love to hear it :-)&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>bash</category>
    </item>
    <item>
      <title>Upload to TestFlight with Fastlane and 2FA</title>
      <dc:creator>Fré Dumazy</dc:creator>
      <pubDate>Wed, 26 Aug 2020 11:27:59 +0000</pubDate>
      <link>https://dev.to/dumazy/upload-to-testflight-with-fastlane-and-2fa-11k8</link>
      <guid>https://dev.to/dumazy/upload-to-testflight-with-fastlane-and-2fa-11k8</guid>
      <description>&lt;p&gt;I recently (accidentally) turned on two-factor authentication (2FA) for an Apple account that we use to submit iOS builds to TestFlight via our CI pipeline. Because of this, our CI system could not longer upload new builds to TestFlight.&lt;/p&gt;

&lt;p&gt;Looking at the &lt;a href="https://docs.fastlane.tools/best-practices/continuous-integration/"&gt;Fastlane documentation for continuous integration&lt;/a&gt;, I saw there was a possibility to use &lt;em&gt;application specific passwords&lt;/em&gt; that allow other systems to upload the iOS builds on your behalf.&lt;/p&gt;

&lt;p&gt;So I generated an application specific password at &lt;a href="https://appleid.apple.com"&gt;appleid.apple.com&lt;/a&gt; and added it as environment variable &lt;code&gt;FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD&lt;/code&gt;. However I wasn't able to get this working until I figured something out in the &lt;a href="https://docs.fastlane.tools/actions/pilot/"&gt;pilot documentation&lt;/a&gt;. It states: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;pilot/upload_to_testflight can use an Application Specific Password via the FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD envirionment variable to upload a binary if both the skip_waiting_for_build_processing and apple_id options are set. (If any of those are not set, it will use the normal Apple login process that might require 2FA authentication.)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The &lt;code&gt;upload_to_testflight&lt;/code&gt; action in the &lt;code&gt;Fastfile&lt;/code&gt; was actually missing these two parameters, at least the &lt;code&gt;apple_id&lt;/code&gt; was missing here. After trying to add it, it still wasn't working, but now I got the following error message:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;apple_id&lt;/code&gt; value is incorrect. The correct value should be taken from Apple ID property in the App Information section in App Store Connect.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I thought I have to specify the Apple account's email address as &lt;code&gt;apple_id&lt;/code&gt;, just like it is in a Fastlane's &lt;code&gt;Appfile&lt;/code&gt;, but this actually expects &lt;strong&gt;the app's apple id&lt;/strong&gt;, for example &lt;code&gt;123456789&lt;/code&gt;, which can be found on App Store Connect. After changing my upload command to this, it finally used the application specific password from the environment variable and was able to upload the iOS build to TestFlight:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;upload_to_testflight(
  skip_waiting_for_build_processing: true,
  apple_id: "123456789"
)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I lost quite some time getting the uploads to work in a CI system for a 2FA account, so I hope I'm able to help somebody by posting this here. Let me know if this helped you :) &lt;/p&gt;

</description>
      <category>2fa</category>
      <category>ios</category>
      <category>testflight</category>
      <category>fastlane</category>
    </item>
    <item>
      <title>Accidentally removed Flutter binary on macOS</title>
      <dc:creator>Fré Dumazy</dc:creator>
      <pubDate>Fri, 07 Feb 2020 12:07:11 +0000</pubDate>
      <link>https://dev.to/dumazy/accidentally-removed-flutter-binary-on-macos-4e4k</link>
      <guid>https://dev.to/dumazy/accidentally-removed-flutter-binary-on-macos-4e4k</guid>
      <description>&lt;p&gt;I've accidentally removed a binary file named &lt;code&gt;Flutter&lt;/code&gt; on my Mac via Storage Management.&lt;/p&gt;

&lt;p&gt;Afterwards I ran into this issue:&lt;br&gt;
&lt;code&gt;The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/path/to/app/ios/Flutter/Flutter.framework)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;How I've eventually fixed it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fix Flutter SDK: Via a reinstall, but maybe changing channels and triggering a new build of the Flutter tool might work as well.&lt;/li&gt;
&lt;li&gt;Clean out the Cocoapods cache: &lt;code&gt;pod cache clean --all&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Remove the Cocoapods cache directory: &lt;code&gt;rm -rf "${HOME}/Library/Caches/CocoaPods"&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Repair the Pub cache: &lt;code&gt;pub cache repair&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Start from a fresh checkout of the project. &lt;code&gt;.packages&lt;/code&gt; should not be generated yet.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;flutter packages get&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Run (or build) the iOS app&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some of these steps probably aren't necessary or could be done in a better way, but this is what worked for me.&lt;br&gt;
I just wanted to publish this in case it might help somebody in the future. That somebody might even be me.&lt;/p&gt;

&lt;p&gt;If you've encountered the same issue before and was able to fix this, let me know how you did it :)&lt;/p&gt;

</description>
      <category>flutter</category>
      <category>ios</category>
      <category>cocoapods</category>
    </item>
  </channel>
</rss>
