<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Taku.dev</title>
        <link>https://staging.takudev.net/</link>
        <description>This is Takuya Iwashiro's Web Dev Blog</description>
        <lastBuildDate>Sat, 11 May 2024 17:26:03 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <image>
            <title>Taku.dev</title>
            <url>https://staging.takudev.net//favicon-32x32.png</url>
            <link>https://staging.takudev.net/</link>
        </image>
        <copyright>All rights reserved 2024, Takuya Iwashiro</copyright>
        <item>
            <title><![CDATA[How to set up new flutter project with asdf (June, 2023)]]></title>
            <link>https://staging.takudev.net//articles/2_how-to-set-up-new-flutter-project-june-2023</link>
            <guid>https://staging.takudev.net//articles/2_how-to-set-up-new-flutter-project-june-2023</guid>
            <pubDate>Wed, 28 Jun 2023 07:28:27 GMT</pubDate>
            <description><![CDATA[This article will show you how to create a new flutter project integrated with asdf, vscode in a hands-on way.]]></description>
            <content:encoded><![CDATA[<p>This article will show you how to create a new flutter project integrated with asdf, vscode in a hands-on way.</p>
<h2>Environment</h2>
<ul>
<li>macOS Ventura 13.4.1 (M1)</li>
<li>Homebrew 4.0.24</li>
<li>VSCode 1.79.2</li>
<li>Xcode 14.3.1</li>
<li>Android Studio Flamingo</li>
<li>Chrome 114.0.5735.133</li>
<li>asdf v0.12.0</li>
</ul>
<h2>Prerequisite</h2>
<p>If your mac is Apple Silicon Mac, you must have the Rosetta translation environment available for some ancillary tools. You can install this manually by running</p>
<pre><code class="language-bash">sudo softwareupdate --install-rosetta --agree-to-license
</code></pre>
<p>And you need to create and start simulators each platforms (Xcode, Android Studio).</p>
<ul>
<li><a href="https://docs.flutter.dev/get-started/install/macos#set-up-the-ios-simulator">Set up the iOS simulator</a></li>
<li><a href="https://docs.flutter.dev/get-started/install/macos#set-up-the-android-emulator">Set up the Android emulator</a></li>
</ul>
<p>Of course, you can also connect your own devices to your mac instead of simulators. </p>
<p>After all, create a project.</p>
<pre><code class="language-bash">cd ~ &amp;&amp; mkdir my-flutter-project
cd my-flutter-project
</code></pre>
<h2>Install tools</h2>
<p>Add plugins by</p>
<pre><code class="language-bash">asdf plugin add dart
asdf plugin add flutter
asdf plugin add ruby
</code></pre>
<p>Install tools by</p>
<pre><code class="language-bash">asdf install dart 3.0.5
asdf install flutter 3.10.5-stable
asdf install ruby 3.2.2
</code></pre>
<p>Apply specified version in this project by</p>
<pre><code class="language-bash">asdf local dart 3.0.5
asdf local flutter 3.10.5-stable
asdf local ruby 3.2.2
</code></pre>
<p>Install cocapods by</p>
<pre><code class="language-bash">sudo gem install cocoapods
</code></pre>
<h2>Configure VSCode Setting</h2>
<p>Add setting file for this project by</p>
<pre><code class="language-bash">mkdir .vscode
echo -e &quot;{\n  \&quot;dart.flutterSdkPath\&quot;: \&quot;$HOME/.asdf/installs/flutter/3.10.5-stable\&quot;\n}&quot; &gt; .vscode/settings.json
</code></pre>
<p>And then, install the following VSCode&#39;s extensions.</p>
<ul>
<li><a href="https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter">flutter</a></li>
<li><a href="https://marketplace.visualstudio.com/items?itemName=Dart-Code.dart-code">Dart</a></li>
</ul>
<h2>Check Environment</h2>
<p>Check flutter whether it is from asdf.</p>
<pre><code class="language-bash">which flutter
// expected path → $HOME/.asdf/shims/flutter
</code></pre>
<p>if you set up correctly, VSCode show you flullter command  via command palette.</p>
<p><img src="https://images.takudev.net/flutter_extension_f39049df3c.png" alt="flutter-command-palette-1.png"></p>
<p>For example, selecting <strong>Flutter New Project</strong></p>
<p><img src="https://images.takudev.net/flutter_project_2adf80a117.png" alt="flutter-command-palette-2.png"></p>
<p>Conveniently, flutter has <a href="https://docs.flutter.dev/get-started/install/macos#run-flutter-doctor">doctor command</a>. you can check easily your project environment with executing it form terminal.</p>
<pre><code class="language-bash">flutter doctor
</code></pre>
<p><img src="https://images.takudev.net/flutter_doctor_fa17e9bf10.png" alt="flutter-doctor.png"></p>
<p>Finally, you&#39;re ready to start project!</p>
<h2>Create Project</h2>
<p>Create project by</p>
<pre><code class="language-bash">flutter create .
</code></pre>
<p>And create <strong>launch.json</strong> for debugging multiple devices.</p>
<pre><code class="language-bash">touch .vscode/launch.json
</code></pre>
<p>And you can set up some devices what you would like by  configure this file.</p>
<p>For example,</p>
<pre><code class="language-json">{
  &quot;version&quot;: &quot;0.2.0&quot;,
  &quot;configurations&quot;: [
    {
      &quot;name&quot;: &quot;Current Device&quot;,
      &quot;request&quot;: &quot;launch&quot;,
      &quot;type&quot;: &quot;dart&quot;
    },
    {
      &quot;name&quot;: &quot;Pixel_4_API_30&quot;,
      &quot;request&quot;: &quot;launch&quot;,
      &quot;type&quot;: &quot;dart&quot;,
      &quot;deviceId&quot;: &quot;xxxx&quot;
    },
    {
      &quot;name&quot;: &quot;iPhone 14&quot;,
      &quot;request&quot;: &quot;launch&quot;,
      &quot;type&quot;: &quot;dart&quot;,
      &quot;deviceId&quot;: &quot;xxxx&quot;
    },
    {
      &quot;name&quot;: &quot;Web(Chrome)&quot;,
      &quot;request&quot;: &quot;launch&quot;,
      &quot;type&quot;: &quot;dart&quot;,
      &quot;deviceId&quot;: &quot;chrome&quot;
    },
  ],
  &quot;compounds&quot;: [
    {
      &quot;name&quot;: &quot;All Mobile Devices&quot;,
      &quot;configurations&quot;: [
        &quot;Pixel_4_API_30&quot;,
        &quot;iPhone SE (3rd generation)&quot;,
        &quot;iPhone 14&quot;
      ]
    },
  ]
}
</code></pre>
<p>you can get device ids from xcode or <code>adb devices</code>.</p>
<h2>Start flutter app</h2>
<p>you can start this project&#39;s flutter app from VSCode.</p>
<p><img src="https://images.takudev.net/flutter_debug_026d5c3b87.png" alt="flutter-doctor.png"></p>
<p><img src="https://images.takudev.net/392a6d519239_20230629_ce47350ff3.png" alt="flutter-doctor.png"></p>
]]></content:encoded>
        </item>
    </channel>
</rss>