<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Flutter | アリッシアの朝</title>
	<atom:link href="https://alicia-ing.com/category/programming/flutter/feed/" rel="self" type="application/rss+xml" />
	<link>https://alicia-ing.com</link>
	<description></description>
	<lastBuildDate>Sun, 18 Oct 2026 12:33:09 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.4</generator>

<image>
	<url>https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia-32x32.webp</url>
	<title>Flutter | アリッシアの朝</title>
	<link>https://alicia-ing.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【Flutter】Gemini APIの使い方｜AIに質問するアプリを作成</title>
		<link>https://alicia-ing.com/programming/flutter/gemini-api-application/</link>
					<comments>https://alicia-ing.com/programming/flutter/gemini-api-application/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 18 Oct 2026 12:31:55 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=9239</guid>

					<description><![CDATA[アプリに AI を組み込みたいとき、手軽に試せるのが Google の Gemini API です。文章を送ると、AI が考えた返事が文章で返ってきます。 Flutter からは、パッケージを1つ追加するだけで Gemi [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">入力欄に書いた質問（マイクで話した質問も）を Gemini に送り、AI の返事を画面に表示するアプリを作れます。</p>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="960" height="540" src="https://alicia-ing.com/wp-content/uploads/2026/10/complete-4.webp" alt="" class="wp-image-9241" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/complete-4.webp 960w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-4-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-4-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-4-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-4-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-4-640x360.webp 640w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
</div></div>



<p class="wp-block-paragraph">アプリに AI を組み込みたいとき、手軽に試せるのが Google の <strong>Gemini API</strong> です。文章を送ると、AI が考えた返事が文章で返ってきます。</p>



<p class="wp-block-paragraph">Flutter からは、パッケージを1つ追加するだけで Gemini を呼び出せます。ただし、<strong>混雑して返事が来ないことがある</strong>、<strong>返事に記号がそのまま出る</strong>など、動かしてみて初めて気づく落とし穴もあります。</p>



<p class="wp-block-paragraph">本記事では、質問を送って返事を表示するまでの流れを解説します。また、混雑して返事が来ないときに、自動でやり直す仕組みも入れます。使っているパッケージが非推奨になった点と、これから始める人向けの選び方も紹介します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutter のアプリから Gemini（AI）を呼び出したい人</li>



<li>Gemini API に質問を送って、返事を画面に出すまでの流れを知りたい人</li>



<li>返事が来ない（混雑する）ときの対策を知りたい人</li>



<li>APIキーの扱いで気をつけることを知りたい人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">Gemini API（google_generative_ai）</h2>



<figure class="wp-block-image size-full"><img decoding="async" width="1376" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request.webp" alt="" class="wp-image-9249" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request.webp 1376w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request-300x167.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request-767x428.webp 767w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request-1024x572.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-api-key-request-240x135.webp 240w" sizes="(max-width: 1376px) 100vw, 1376px" /></figure>



<p class="wp-block-paragraph">Gemini API はGoogle の AI「Gemini」を使うための窓口で、<strong>質問の文章を送るとGemini が考えた返事が文章で返ってきます</strong>。</p>



<p class="wp-block-paragraph">そのため、Flitterに入れることでAIを用いたアプリが作成可能になります。</p>



<p class="wp-block-paragraph">Flutter からは、<strong>google_generative_ai</strong> というパッケージで呼び出せます。本記事のコードは、このパッケージの 0.4.7 で作っています。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p class="wp-block-paragraph">Gemini を選んだのは、<strong>無料範囲があるから</strong>です。ChatGPT や Claude の API は、試すだけでも使った分の料金がかかるため、まずは Geminiで連携を作りました。</p>
</div></div>



<p class="wp-block-paragraph">一方で、Geminiも上限を超えると従量課金になり、モデルによってChatGPTの方が安くなることがあります。</p>



<h3 class="wp-block-heading">APIキーの取得</h3>



<p class="wp-block-paragraph">Gemini API を使うには <strong>APIキー</strong>（アプリが自分のものだと Google に伝えるための合言葉）が必要です。</p>



<ol class="wp-block-list">
<li>Google AI Studio を開き、左下の鍵のアイコン（<strong>Get API key</strong>）を押す</li>



<li>「API キー」のページで、右上の <strong>API キーを作成</strong> を押す</li>



<li>作ったキーをコピーしておく</li>
</ol>



<figure class="wp-block-image size-full"><img decoding="async" width="1917" height="1078" src="https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key.webp" alt="" class="wp-image-9243" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key.webp 1917w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-766x431.webp 766w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-1024x576.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-1536x864.webp 1536w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-get-api-key-640x360.webp 640w" sizes="(max-width: 1917px) 100vw, 1917px" /></figure>



<p class="wp-block-paragraph">作ったキーは、この一覧に並びます。「請求階層」が<strong>無料枠</strong>になっていれば、料金はかからない範囲で使えます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1917" height="1078" src="https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key.webp" alt="" class="wp-image-9244" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key.webp 1917w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-766x431.webp 766w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-1024x576.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-1536x864.webp 1536w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/ai-studio-create-api-key-640x360.webp 640w" sizes="(max-width: 1917px) 100vw, 1917px" /></figure>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p class="wp-block-paragraph">無料枠でも、基本的なテストで使う程度なら、制限に当たることはほとんどありません。安心してFlutterと連携してください。</p>
</div></div>



<p class="wp-block-paragraph">APIキーは<strong>パスワードと同じように扱います</strong>。GitHub などに上げないようにしてください。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://ai.google.dev/gemini-api/docs/api-key">Using Gemini API keys</a></p>



<h3 class="wp-block-heading">パッケージの追加と.envの設定</h3>



<p class="wp-block-paragraph"><strong>pubspec.yaml に2つのパッケージを追加</strong>します。google_generative_ai が Gemini を呼ぶパッケージ、flutter_dotenv が APIキーを別ファイルから読むパッケージです。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>dependencies:
  google_generative_ai: ^0.4.7
  flutter_dotenv: ^6.0.1

flutter:
  assets:
    - .env</code></pre></div>



<p class="wp-block-paragraph">プロジェクトの直下（pubspec.yaml と同じ場所）に .env というファイルを作り、your_api_key_here の部分を、コピーしたキーに書き換えます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>GEMINI_API_KEY=api_key</code></pre></div>



<p class="wp-block-paragraph">アプリの起動時に、この .env を読み込みます。main.dart の main の最初に、次の2行を入れます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>WidgetsFlutterBinding.ensureInitialized();
await dotenv.load(fileName: &#39;.env&#39;);</code></pre></div>



<p class="wp-block-paragraph">キーをコードに直接書かず .env に分けておくと、<strong>コードだけを人に見せたり公開したりしても、キーが一緒に出ていきません</strong>。.env は .gitignore に入れておきましょう。ただし、Web で動かすときには別の注意があります（「エラーと解決策・対策」で説明します）。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://pub.dev/packages/google_generative_ai">google_generative_ai</a></p>



<h2 class="wp-block-heading">google_generative_aiは非推奨｜これから始めるならFirebase AI Logic</h2>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">google_generative_ai は、公式のパッケージページで<strong>非推奨（Deprecated）</strong>と表示されています。今後、機能の追加や変更はされない予定です。</p>
</div>



<p class="wp-block-paragraph">本記事のコードは、まず手元で Gemini を試すために google_generative_ai で作りました。いまも動きますが、<strong>これから作り始めるアプリ、特に人に公開するアプリでは、後継の Firebase AI Logic（firebase_ai パッケージ）を使う</strong>のがおすすめです。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>項目</th><th>google_generative_ai</th><th>firebase_ai（Firebase AI Logic）</th></tr></thead><tbody><tr><td>状態</td><td>非推奨。今後は変更されない</td><td>開発が続いている</td></tr><tr><td>準備</td><td>APIキーだけ</td><td>Firebase のプロジェクトが必要</td></tr><tr><td>アプリを守る仕組み</td><td>なし</td><td>App Check（正規のアプリからの呼び出しかを確かめる仕組み）を強く推奨</td></tr><tr><td>呼び出し方</td><td>GenerativeModel(&#8230;) を作り、generateContent</td><td>FirebaseAI.googleAI().generativeModel(&#8230;) を作り、generateContent</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">呼び出し方はよく似ていて、<strong>モデルを作って generateContent に質問を渡す</strong>流れは同じです。本記事の解説は、そのまま firebase_ai でも役に立ちます。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://firebase.google.com/docs/ai-logic/get-started?platform=flutter">Get started with the Gemini API using the Firebase AI Logic SDKs</a></p>



<h2 class="wp-block-heading">gemini-3.6-flashとflash-liteの使い分け</h2>



<p class="wp-block-paragraph">Gemini には、性能と速さの違う<strong>モデル</strong>（AI の種類）がいくつかあります。どのモデルを使うかは、コードの中でモデル名の文字列を書いて選びます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>モデル名</th><th>特徴</th><th>本記事での使い方</th></tr></thead><tbody><tr><td>gemini-3.6-flash</td><td>速さと性能のバランスがよい</td><td>普段はこちらで返事を作る</td></tr><tr><td>gemini-3.5-flash-lite</td><td>一番速く、費用も安い</td><td>混雑して flash が返事をしないときの予備</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">本記事では、<strong>普段は flash を使い、混雑しているときだけ flash-lite に切り替えます</strong>。返事の質を保ちつつ、返事が来ないまま待たされることを減らすためです。</p>



<p class="wp-block-paragraph">モデルは新しいものが次々に出ます。公式のモデル一覧には、gemini-3.6-flash より新しい世代の flash も載っています。<strong>モデル名は文字列1か所なので、新しいモデルに替えるときはそこを書き換えるだけ</strong>です。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://ai.google.dev/gemini-api/docs/models">Gemini models</a></p>



<h2 class="wp-block-heading">Gemini APIに質問し返答する</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1408" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/gemini-service_response.webp" alt="" class="wp-image-9250" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/gemini-service_response.webp 1408w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-service_response-300x164.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-service_response-766x418.webp 766w, https://alicia-ing.com/wp-content/uploads/2026/10/gemini-service_response-1024x559.webp 1024w" sizes="(max-width: 1408px) 100vw, 1408px" /></figure>



<p class="wp-block-paragraph">ここまでの内容をもとに、次の動きをする画面を作ります。</p>



<ul class="wp-block-list">
<li>入力欄に質問を書く（マイクで話して入れてもよい）</li>



<li>「Geminiに聞く」を押すと、質問を Gemini に送る</li>



<li>返事を待つ間は、ボタンにくるくるを出して押せなくする</li>



<li>返事が届いたら、入力欄の下に表示する（長い返事はスクロールできる）</li>



<li>混雑していたら、少し待ってやり直し、それでもだめなら予備のモデルで返事を作る</li>
</ul>



<p class="wp-block-paragraph">マイクで話した内容を入力欄に入れる部分は、speech_to_text で作っています。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>speech_to_text で音声入力を作る方法を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/speech-to-text-voiceinput/" title="【Flutter】speech_to_textで音声入力し文字起こし" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="320" height="180" src="https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-voiceinput-320x180.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-voiceinput-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-voiceinput-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-voiceinput-640x360.webp 640w" sizes="(max-width: 320px) 100vw, 320px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】speech_to_textで音声入力し文字起こし</div><div class="blogcard-snippet internal-blogcard-snippet">Flutterのspeech_to_textで音声入力を作る方法を解説。話した内容をリアルタイムで文字にし、認識が止まっても自動で聞き取り直すコードと、マイク許可・エラー対処を紹介します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2026.10.11</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">ソースコード</h3>



<ul class="wp-block-list">
<li>gemini_service.dart</li>
</ul>



<p class="wp-block-paragraph">Gemini とのやり取りをまとめたクラスです。lib/services/ に置きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>class GeminiService {
  GeminiService() {
    // .env から APIキーを読む
    final apiKey = dotenv.env[&#39;GEMINI_API_KEY&#39;];
    if (apiKey != null && apiKey.isNotEmpty && apiKey != &#39;your_api_key_here&#39;) {
      _model = GenerativeModel(model: &#39;gemini-3.6-flash&#39;, apiKey: apiKey);
      // 混雑しているときに使う予備のモデル
      _fallbackModel = GenerativeModel(model: &#39;gemini-3.5-flash-lite&#39;, apiKey: apiKey);
    }
  }

  GenerativeModel? _model;
  GenerativeModel? _fallbackModel;

  bool get isConfigured =&gt; _model != null;

  // 質問を送り、返事の文章を返す
  Future&lt;String&gt; ask(String prompt) async {
    final model = _model;
    final fallbackModel = _fallbackModel;
    if (model == null || fallbackModel == null) {
      throw StateError(&#39;GEMINI_API_KEY が未設定です。.env に自分のAPIキーを設定してください。&#39;);
    }

    final content = [Content.text(prompt)];
    try {
      return _textOf(await _withRetryOnOverload(() =&gt; model.generateContent(content)));
    } on GenerativeAIException catch (e) {
      if (!_isOverloaded(e)) rethrow;
      // やり直しても混雑していたら、予備のモデルで返事を作る
      return _textOf(await fallbackModel.generateContent(content));
    }
  }

  // 混雑していたら2秒待って、1回だけやり直す
  Future&lt;GenerateContentResponse&gt; _withRetryOnOverload(
    Future&lt;GenerateContentResponse&gt; Function() call,
  ) async {
    try {
      return await call();
    } on GenerativeAIException catch (e) {
      if (!_isOverloaded(e)) rethrow;
      await Future&lt;void&gt;.delayed(const Duration(seconds: 2));
      return call();
    }
  }

  // エラーの文に 503 や UNAVAILABLE があれば「混雑」とみなす
  static bool _isOverloaded(GenerativeAIException e) =&gt;
      e.message.contains(&#39;503&#39;) || e.message.contains(&#39;UNAVAILABLE&#39;);

  static String _textOf(GenerateContentResponse response) =&gt;
      response.text ?? &#39;(応答がありませんでした)&#39;;
}</code></pre></div>



<ul class="wp-block-list">
<li>speech_input_page.dart</li>
</ul>



<p class="wp-block-paragraph">画面の State に持たせる部分です。「Geminiに聞く」を押すと _askGemini が呼ばれます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>final GeminiService _gemini = GeminiService();
bool _isAsking = false; // 返事を待っている間は true
String _answer = &#39;&#39;; // Gemini の返事

// 入力欄の文章を Gemini に送り、返事を表示する
Future&lt;void&gt; _askGemini() async {
  final prompt = _textController.text.trim();
  if (prompt.isEmpty) return;

  // 先に _isAsking を true にしてボタンを押せなくする（返事待ちの間の二重送信を防ぐ）
  setState(() {
    _isAsking = true;
    _statusMessage = &#39;&#39;;
    _isError = false;
    _answer = &#39;&#39;;
  });

  // 聞き取り中なら、マイクを止めてから送る
  if (_isListening) {
    await _speech.stop();
    if (!mounted) return;
    setState(() =&gt; _isListening = false);
  }

  try {
    final answer = await _gemini.ask(prompt);
    if (!mounted) return; // 待っている間に画面が閉じられていたら何もしない
    setState(() =&gt; _answer = answer);
  } catch (e) {
    if (!mounted) return;
    setState(() {
      _statusMessage = &#39;Gemini呼び出しエラー: $e&#39;;
      _isError = true;
    });
  } finally {
    // 成功しても失敗しても、最後に必ずボタンを押せる状態に戻す
    if (mounted) setState(() =&gt; _isAsking = false);
  }
}</code></pre></div>



<p class="wp-block-paragraph">build の中に並べる部品です。送信ボタンと、返事の表示です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>// Gemini に送るボタン（返事待ちの間は押せず、くるくるを出す）
FilledButton.icon(
  onPressed: _isAsking ? null : _askGemini,
  icon: _isAsking
      ? const SizedBox(
          width: 16,
          height: 16,
          child: CircularProgressIndicator(strokeWidth: 2),
        )
      : const Icon(Icons.send),
  label: const Text(&#39;Geminiに聞く&#39;),
),

// Gemini の返事（長い返事はスクロールできる）
if (_answer.isNotEmpty)
  Expanded(
    child: SingleChildScrollView(
      // 右下のマイクボタンに、返事の最後が隠れないように余白を空ける
      padding: const EdgeInsets.only(bottom: 80),
      child: SelectableText(_answer), // 選択してコピーできる
    ),
  ),</code></pre></div>



<h3 class="wp-block-heading">解説</h3>



<p class="wp-block-paragraph">Gemini とのやり取りは <strong>GeminiService にまとめ</strong>、画面は「いつ送るか」と「何を表示するか」だけを受け持ちます。画面からは _gemini.ask(質問) を呼ぶだけなので、あとで firebase_ai などに替えるときも、<strong>直すのは GeminiService だけ</strong>で済みます。</p>



<p class="wp-block-paragraph">画面が持つ状態は次の2つです（音声入力やエラー表示の状態は省略しています）。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>変数</th><th>意味</th></tr></thead><tbody><tr><td>_isAsking</td><td>いま返事を待っているか（ボタンを押せなくする・くるくるを出すのに使う）</td></tr><tr><td>_answer</td><td>Gemini から届いた返事</td></tr></tbody></table></div></figure>



<h4 class="wp-block-heading">GeminiService：APIキーを読んでモデルを作る</h4>



<p class="wp-block-paragraph">最初に .env から APIキーを読み、<strong>GenerativeModel にモデル名とキーを渡してモデルを作ります</strong>。普段使う flash と、予備の flash-lite の2つを作っておきます。</p>



<p class="wp-block-paragraph">キーが読めなかったときはモデルを作らず、isConfigured が false になります。.envに書き換え忘れのときも、キーがないものとして扱います。</p>



<h4 class="wp-block-heading">ask：質問を送って返事を受け取る</h4>



<p class="wp-block-paragraph">Content.text(質問) で質問を包み、<strong>generateContent に渡すと、Gemini の返事が返ってきます</strong>。返事の文章は response.text に入っています。返事が空のときは null になるので、(応答がありませんでした) と表示します。</p>



<p class="wp-block-paragraph">generateContent は返事が届くまで時間がかかるので、await で待ちます。待っている間も、画面は固まらずに動き続けます。</p>



<h4 class="wp-block-heading">_withRetryOnOverload：混雑したら待ってやり直す</h4>



<p class="wp-block-paragraph">Gemini が混雑していると、<strong>返事の代わりに「503」「UNAVAILABLE」を含むエラーが返る</strong>ことがあります。混雑は少し待つと解消することが多いので、<strong>2秒待ってから1回だけやり直します</strong>。</p>



<p class="wp-block-paragraph">それでも混雑していたら、ask の側で<strong>予備の flash-lite に切り替えて返事を作ります</strong>。混雑以外のエラー（キーが間違っているなど）は、待っても直らないので、やり直さずにそのまま画面へ伝えます（rethrow）。</p>



<h4 class="wp-block-heading">_askGemini：二重送信を防いで送る</h4>



<p class="wp-block-paragraph">_askGemini は、次の順に動きます。</p>



<ol class="wp-block-list">
<li>入力欄が空なら何もしない</li>



<li><strong>先に _isAsking を true にする</strong>。ボタンの onPressed が null になり、押せなくなる</li>



<li>聞き取り中なら、マイクを止めてから送る（話している途中の文字が混ざらないようにする）</li>



<li>_gemini.ask で返事を待ち、届いたら _answer に入れて表示する</li>



<li>失敗したら、エラーの文を赤字で表示する</li>



<li><strong>finally で、成功しても失敗しても _isAsking を false に戻す</strong></li>
</ol>



<p class="wp-block-paragraph">2 を先にしておかないと、返事を待っている間にボタンを何度も押せてしまい、同じ質問が何回も送られます。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p class="wp-block-paragraph">送信中に何回も押すと、Gemini の返事でエラーが起きるのではと考えて、送信中はボタンを押せなくしました。</p>
</div></div>



<p class="wp-block-paragraph">mounted は「この画面がまだ表示されているか」です。返事を待っている間に画面が閉じられていたら、setState を呼ばないようにしています（閉じた画面を更新しようとするとエラーになるため）。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>ボタンを押せなくする書き方を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/button-onpress/" title="【Flutter】ボタンの種類と使い方｜押せなくする・色を変える" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="320" height="180" src="https://alicia-ing.com/wp-content/uploads/2026/10/button-onpress-320x180.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/button-onpress-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/button-onpress-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/button-onpress-640x360.webp 640w" sizes="(max-width: 320px) 100vw, 320px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】ボタンの種類と使い方｜押せなくする・色を変える</div><div class="blogcard-snippet internal-blogcard-snippet">Flutterのボタンの種類（Filled・Elevated・Outlined・Text・Icon）の違いと使い分けを解説。onPressedにnullを渡して押せなくする方法と、状態で色が変わるマイクボタンの作り方も紹介します。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2026.10.14</div></div></div></div></a>
</div>



<h4 class="wp-block-heading">返事の表示：スクロールとコピー</h4>



<p class="wp-block-paragraph">返事は長くなりやすいので、SingleChildScrollView に入れて<strong>スクロールできる</strong>ようにします。SelectableText を使うと、<strong>返事を選択してコピー</strong>できます。</p>



<h2 class="wp-block-heading">エラーと解決策・対策</h2>



<p class="wp-block-paragraph">以下では、想定しうるエラーの解決方法を紹介します。APIキーを第三者に公開するのは非常に危険ですので、取り扱いには十分に注意してください。</p>



<h3 class="wp-block-heading">503 UNAVAILABLE（混雑）で返事が来ない</h3>



<p class="wp-block-paragraph">Gemini 側が混雑していると、503（UNAVAILABLE）のエラーが返ります。こちらのコードの誤りではないので、<strong>時間をおいてやり直せば返事が来る</strong>ことが多いです。</p>



<div class="wp-block-cocoon-blocks-balloon-ex-box-1 speech-wrap sb-id-2 sbs-stn sbp-l sbis-cb cf block-box not-nested-style cocoon-block-balloon"><div class="speech-person"><figure class="speech-icon"><img decoding="async" src="https://alicia-ing.com/wp-content/uploads/2023/05/cropped-alicia.webp" alt="筆者" class="speech-icon-image"/></figure><div class="speech-name">筆者</div></div><div class="speech-balloon">
<p class="wp-block-paragraph">実際に混雑に当たったときは、ボタンを押し直してもエラーが表示されるだけでした。そこで、同じモデルで粘るより、別のモデルに切り替えて返事をもらう方がよいと考えました。</p>
</div></div>



<p class="wp-block-paragraph">公式のトラブルシューティングでは、<strong>少し待ってからやり直し、やり直すたびに待つ時間を延ばす</strong>方法がすすめられています。</p>



<p class="wp-block-paragraph">本記事のコードは、この考え方を簡単にして「2秒待って1回やり直す」にしています。さらに、<strong>やり直してもだめなときは予備のモデルに切り替える</strong>のは、待たされる時間を減らすための工夫です（公式の手順にはありません）。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://ai.google.dev/gemini-api/docs/troubleshooting">Troubleshooting guide</a></p>



<h3 class="wp-block-heading">返事に「##」や「**」がそのまま出る</h3>



<p class="wp-block-paragraph">完成イメージのように、返事に「##」や「**」がそのまま出ることがあります。<strong>Gemini はマークダウン</strong>（見出しや太字を記号で表す書き方）<strong>で返事を書く</strong>ことが多く、SelectableText は記号をそのまま文字として表示するためです。</p>



<p class="wp-block-paragraph">直し方は2通りあります。</p>



<ul class="wp-block-list">
<li><strong>表示側で整える：</strong> マークダウンを見た目に変えて表示するパッケージを使う。よく紹介される flutter_markdown は開発が終了しているので、後継として案内されている <strong>flutter_markdown_plus</strong> を使う</li>



<li><strong>記号を使わせない：</strong> 質問と一緒に「マークダウンや記号を使わず、普通の文章で答えて」と指示する</li>
</ul>



<p class="wp-block-paragraph">返事を読み上げたり吹き出しに出したりする場合は、<strong>記号を使わせない方法が向いています</strong>。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://pub.dev/packages/flutter_markdown_plus">flutter_markdown_plus</a></p>



<h3 class="wp-block-heading">「GEMINI_API_KEY が未設定です」と出る</h3>



<p class="wp-block-paragraph"><strong>APIキーが読めていない</strong>状態です。次を確認してください。</p>



<ul class="wp-block-list">
<li>.env がプロジェクトの直下（pubspec.yaml と同じ場所）にあるか</li>



<li>pubspec.yaml の flutter: の assets: に .env を書いたか（書き忘れると、アプリに .env が入らない）</li>



<li>.env の書き方が GEMINI_API_KEY=キー になっているか（your_api_key_here のままになっていないか）</li>
</ul>



<p class="wp-block-paragraph">pubspec.yaml を直したあとは、ホットリロードではなく、<strong>アプリを止めてから起動し直して</strong>ください。</p>



<h3 class="wp-block-heading">WebではAPIキーが見えてしまう</h3>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">.env を assets に入れると、<strong>Web で公開したときに、.env のファイルがそのまま配信されます</strong>。誰でも中の APIキーを読めてしまうので、手元で試すだけにして、build/web を公開しないでください。</p>
</div>



<p class="wp-block-paragraph">Web に限らず、スマホのアプリに入れたキーも、取り出そうと思えば取り出せます。公式も、<strong>Web やスマホのアプリにキーを直接入れないこと</strong>、本番ではサーバーを間に置いて呼び出すことをすすめています。</p>



<p class="wp-block-paragraph">人に使ってもらうアプリでは、APIキーをアプリに入れない作りにします。<strong>Firebase AI Logic（firebase_ai）に移す</strong>か、<strong>自分のサーバーを間に置いて Gemini を呼ぶ</strong>形にしましょう。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://ai.google.dev/gemini-api/docs/api-key">Using Gemini API keys</a></p>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">Flutter から Gemini API を使う流れは、<strong>モデルを作り、generateContent に質問を渡して、response.text で返事を受け取る</strong>、の3つです。</p>



<ul class="wp-block-list">
<li>Gemini とのやり取りは GeminiService にまとめ、画面は送るタイミングと表示だけを受け持つ</li>



<li>返事を待つ間はボタンを押せなくし、finally で必ず元に戻す</li>



<li>混雑（503）は待ってやり直す。だめなら軽いモデルに切り替える</li>



<li>返事のマークダウン記号は、表示側で整えるか、使わないように指示する</li>



<li>google_generative_ai は非推奨。公開するアプリは Firebase AI Logic かサーバー経由にして、APIキーをアプリに入れない</li>
</ul>



<p class="wp-block-paragraph">まずは手元で質問を送って返事が返ってくるところまで動かし、AI に何を任せたいかを試してみてください。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/gemini-api-application/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】ボタンの種類と使い方｜押せなくする・色を変える</title>
		<link>https://alicia-ing.com/programming/flutter/button-onpress/</link>
					<comments>https://alicia-ing.com/programming/flutter/button-onpress/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Tue, 13 Oct 2026 22:00:00 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=9197</guid>

					<description><![CDATA[アプリには、必ずと言っていいほどボタンがあります。Flutter にはボタンの種類がいくつもあり、「どれを使えばいいのか」「押せなくするにはどうするのか」と迷いやすい部品です。 本記事では、よく使う5種類のボタンを並べて [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">Flutter の5種類のボタンの違いを動かして確かめ、状態で色とアイコンが変わるマイクボタン（FloatingActionButton）と、押せなくする切り替えを作れます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="960" height="540" src="https://alicia-ing.com/wp-content/uploads/2026/10/complete-3.webp" alt="" class="wp-image-9223" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/complete-3.webp 960w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-3-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-3-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-3-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-3-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-3-640x360.webp 640w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
</div></div>



<p class="wp-block-paragraph">アプリには、必ずと言っていいほどボタンがあります。Flutter にはボタンの種類がいくつもあり、「<strong>どれを使えばいいのか</strong>」「<strong>押せなくするにはどうするのか</strong>」と迷いやすい部品です。</p>



<p class="wp-block-paragraph">本記事では、よく使う<strong>5種類のボタン</strong>を並べて押し比べたあと、音声入力の開始と停止に使うマイクボタンを作ります。<strong>聞き取り中は赤くなり、スイッチで押せなく</strong>もできます。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutter のボタンの種類と使い分けを知りたい人</li>



<li>押したときの処理（onPressed）の書き方を知りたい人</li>



<li>状態によってボタンの色やアイコンを変えたい人</li>



<li>ボタンを押せなくする方法を知りたい人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">Flutterのボタンの種類</h2>



<p class="wp-block-paragraph">よく使うボタンは、次の5つです。（FilledButton・ElevatedButton・OutlinedButton・TextButton・IconButton）どれも、押したときの処理を <strong>onPressed に渡す</strong>と動きます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>ボタン</th><th>見た目</th><th>使いどころ</th></tr></thead><tbody><tr><td>FilledButton</td><td>色で塗りつぶされている</td><td>その<strong>画面でいちばん大事な操作</strong></td></tr><tr><td>ElevatedButton</td><td>影があり、浮いて見える</td><td>目立たせたい操作。背景と区別したいとき</td></tr><tr><td>OutlinedButton</td><td>枠線だけ</td><td>補助的な操作</td></tr><tr><td>TextButton</td><td>文字だけ</td><td>控えめな操作</td></tr><tr><td>IconButton</td><td>アイコンだけ</td><td>ツールバーなど、場所を取りたくないとき</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">使い分けの目安は、「<strong>目立たせたい操作ほど、塗りつぶしや影のあるボタンにする</strong>」ことです。1つの画面に塗りつぶしのボタンを並べすぎると、どれが大事か分からなくなります。</p>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">古い記事に出てくる RaisedButton、FlatButton などは、いまは使われていません。新しく書くときは、上の5つを使ってください。</p>
</div>



<h3 class="wp-block-heading">押せなくする：onPressed に null</h3>



<p class="wp-block-paragraph">どのボタンも、<strong>onPressed に null を渡す</strong>と、押せなくなります。公式の説明でも、onPressed が null のボタンは無効になります。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>ElevatedButton(
  onPressed: isReady ? () { /* 処理 */ } : null,
  child: const Text(&#39;送信&#39;),
)</code></pre></div>



<p class="wp-block-paragraph">条件によって、処理の関数と null を切り替える書き方です。</p>



<h2 class="wp-block-heading">FloatingActionButton</h2>



<p class="wp-block-paragraph">FloatingActionButton は、画面の上に浮いて見える丸いボタンです。画面でいちばん大事な操作（作る、共有する、録音を始めるなど）に使います。公式の説明では、1つの画面に置くのは<strong>多くても1つ</strong>にするよう案内されています。</p>



<p class="wp-block-paragraph">Scaffold の floatingActionButton に渡すと、通常は画面の右下に置かれます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>画面の枠組みを作る Scaffold について解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/scaffold/" title="【Flutter】画面を構成するScaffoldウィジェット一覧" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/11/scaffold-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/scaffold-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/11/scaffold-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/11/scaffold-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】画面を構成するScaffoldウィジェット一覧</div><div class="blogcard-snippet internal-blogcard-snippet">Scaffoldはアプリの構造やレイアウトを提供するウィジェット（Widget）で、Flutterでは必要不可欠な要素です。ウィジット一覧と使い方を解説しています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p class="wp-block-paragraph">主なプロパティは次のとおりです。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プロパティ</th><th>役割</th></tr></thead><tbody><tr><td>onPressed</td><td>押したときの処理。null だと押せなくなる</td></tr><tr><td>child</td><td>ボタンの中身。ふつうはアイコン</td></tr><tr><td>tooltip</td><td>長押ししたときに出る、ボタンの説明</td></tr><tr><td>backgroundColor</td><td>ボタンの色</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://api.flutter.dev/flutter/material/FloatingActionButton-class.html">FloatingActionButton</a>（Flutter公式）</p>



<p class="wp-block-paragraph">この記事では、次の画面を作ります。</p>



<ul class="wp-block-list">
<li>右下のマイクボタンを押すと、聞き取り中（赤）と停止中を切り替わる。アイコンと説明文も変わる</li>



<li>「マイクボタン許可」スイッチをオフにすると、マイクボタンを押せなくなる</li>



<li>5種類のボタンを押すと、押した回数が増える</li>
</ul>



<h2 class="wp-block-heading">ソースコード</h2>



<ul class="wp-block-list">
<li>mic_button.dart</li>
</ul>



<p class="wp-block-paragraph">マイクボタンの部品です。状態で色とアイコンを変えます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

/// 音声入力の開始／停止ボタン。聞き取り中は赤くなる。
/// onPressed が null のときは押せない。
class MicButton extends StatelessWidget {
  const MicButton({
    super.key,
    required this.isListening,
    required this.onPressed,
  });

  final bool isListening;
  final VoidCallback? onPressed;

  @override
  Widget build(BuildContext context) {
    return FloatingActionButton(
      onPressed: onPressed,
      tooltip: isListening ? &#39;停止&#39; : &#39;音声入力開始&#39;,
      backgroundColor: isListening ? Colors.red : null,
      child: Icon(isListening ? Icons.mic : Icons.mic_none),
    );
  }
}</code></pre></div>



<ul class="wp-block-list">
<li>button_page.dart</li>
</ul>



<p class="wp-block-paragraph">画面です。状態と、5種類のボタンを持ちます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;../widgets/mic_button.dart&#39;;

class ButtonPage extends StatefulWidget {
  const ButtonPage({super.key, required this.title});

  final String title;

  @override
  State&lt;ButtonPage&gt; createState() =&gt; _ButtonPageState();
}

class _ButtonPageState extends State&lt;ButtonPage&gt; {
  bool _isListening = false;
  bool _enabled = true;
  int _tapCount = 0;

  void _toggleListening() =&gt; setState(() =&gt; _isListening = !_isListening);

  void _countUp() =&gt; setState(() =&gt; _tapCount++);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Text(_isListening ? &#39;聞き取り中(デモ)&#39; : &#39;停止中&#39;),
            SwitchListTile(
              title: const Text(&#39;マイクボタン許可&#39;),
              value: _enabled,
              onChanged: (value) =&gt; setState(() =&gt; _enabled = value),
            ),
            const Divider(),
            Text(&#39;ボタンの種類（押した回数: $_tapCount）&#39;),
            const SizedBox(height: 12),
            Wrap(
              spacing: 12,
              runSpacing: 12,
              children: [
                FilledButton(onPressed: _countUp, child: const Text(&#39;Filled&#39;)),
                ElevatedButton(onPressed: _countUp, child: const Text(&#39;Elevated&#39;)),
                OutlinedButton(onPressed: _countUp, child: const Text(&#39;Outlined&#39;)),
                TextButton(onPressed: _countUp, child: const Text(&#39;Text&#39;)),
                IconButton(
                  onPressed: _countUp,
                  tooltip: &#39;Icon&#39;,
                  icon: const Icon(Icons.thumb_up),
                ),
              ],
            ),
          ],
        ),
      ),
      floatingActionButton: MicButton(
        isListening: _isListening,
        onPressed: _enabled ? _toggleListening : null,
      ),
    );
  }
}</code></pre></div>



<ul class="wp-block-list">
<li>main.dart</li>
</ul>



<p class="wp-block-paragraph">動かすための最小の入口です。mic_button.dart は lib/widgets/、button_page.dart は lib/pages/ に置きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;pages/button_page.dart&#39;;

void main() {
  runApp(
    const MaterialApp(home: ButtonPage(title: &#39;ボタン&#39;)),
  );
}</code></pre></div>



<h3 class="wp-block-heading">解説</h3>



<p class="wp-block-paragraph">画面（ButtonPage）が、「聞き取り中か」「マイクボタンを押せるか」「押した回数」の3つの状態を持ちます。マイクボタンの見た目は、MicButton が受け取った値だけで決まります。</p>



<h4 class="wp-block-heading">MicButton：状態で色とアイコンを変える</h4>



<p class="wp-block-paragraph"><strong>isListening が true のときだけ赤く</strong>し、アイコンとツールチップも切り替えています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>backgroundColor: isListening ? Colors.red : null,
child: Icon(isListening ? Icons.mic : Icons.mic_none),</code></pre></div>



<p class="wp-block-paragraph">条件が true か false かで値を選ぶ書き方です。backgroundColor に null を渡すと、テーマで決まっている標準の色になります。</p>



<p class="wp-block-paragraph">色だけでなくアイコンも変えているので、色の違いが見分けにくい人にも、状態が伝わります。</p>



<h4 class="wp-block-heading">onPressed に null を渡す</h4>



<p class="wp-block-paragraph">MicButton の onPressed は、VoidCallback? という型で受け取ります。? は、null も受け取れるという意味です。</p>



<p class="wp-block-paragraph">画面側では、スイッチの状態で、処理と null を切り替えます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>onPressed: _enabled ? _toggleListening : null,</code></pre></div>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">公式の説明では、FloatingActionButton の onPressed を null にすると押せなくなりますが、<strong>見た目で押せないことが分かりにくい</strong>ので、おすすめしないとされています。押せなくするときは、<strong>あわせて backgroundColor を変えて</strong>、押せないことが見た目で分かるようにしてください。例は次のとおりです。</p>
</div>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>backgroundColor: onPressed == null
    ? Colors.grey
    : (isListening ? Colors.red : null),</code></pre></div>



<h4 class="wp-block-heading">部品に切り出す理由</h4>



<p class="wp-block-paragraph">マイクボタンを MicButton として別のクラスに切り出すと、<strong>見た目の決まりごと（赤くする、アイコンを変える）を1か所にまとめられます</strong>。画面側は、状態を渡すだけで済みます。同じボタンを別の画面で使うときにも、そのまま使えます。</p>



<h4 class="wp-block-heading">_countUp：5種類のボタンに同じ処理を渡す</h4>



<p class="wp-block-paragraph">5種類のボタンには、すべて同じ _countUp を渡しています。押した回数が増えることで、どのボタンも同じように onPressed で動くことが確かめられます。</p>



<h2 class="wp-block-heading">実装</h2>



<ol class="wp-block-list">
<li>Flutter のプロジェクトを作る（追加するパッケージはありません）</li>



<li>2つのファイルを、上の場所に置く</li>



<li>main.dart を書き換えて、実行する</li>
</ol>



<p class="wp-block-paragraph">マイクボタンを押すと赤くなり、もう一度押すと元に戻ります。スイッチをオフにすると、マイクボタンを押せなくなります。</p>



<h2 class="wp-block-heading">まとめ</h2>



<ul class="wp-block-list">
<li>ボタンは FilledButton・ElevatedButton・OutlinedButton・TextButton・IconButton の5種類を使い分ける</li>



<li>押したときの処理は onPressed に渡し、null を渡すと押せなくなる</li>



<li>FloatingActionButton は、画面でいちばん大事な操作に1つだけ置く</li>



<li>押せなくするときは、見た目も変えて、押せないと分かるようにする</li>



<li>状態で変わる見た目は、部品に切り出して1か所にまとめる</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/button-onpress/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】ドロップダウンの作り方｜選択肢を作り選べなくする</title>
		<link>https://alicia-ing.com/programming/flutter/dropdownbuttonformfield/</link>
					<comments>https://alicia-ing.com/programming/flutter/dropdownbuttonformfield/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Mon, 12 Oct 2026 22:00:00 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=9195</guid>

					<description><![CDATA[アプリで言語や国を選んでもらうとき、一覧から1つを選ぶドロップダウン（プルダウン）がよく使われます。 Flutter でドロップダウンを作る部品はいくつかあります。 本記事では、フォームの仕組みにも組み込める Dropd [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">言語などの選択肢から1つを選べるドロップダウンを作り、選んだ値の取り出しと、スイッチで選べなくする切り替えまでを DropdownButtonFormField で実装できます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="960" height="540" src="https://alicia-ing.com/wp-content/uploads/2026/10/complete-2.webp" alt="" class="wp-image-9216" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/complete-2.webp 960w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-2-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-2-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-2-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-2-640x360.webp 640w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-2-320x180.webp 320w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
</div></div>



<p class="wp-block-paragraph">アプリで言語や国を選んでもらうとき、一覧から1つを選ぶドロップダウン（プルダウン）がよく使われます。</p>



<p class="wp-block-paragraph">Flutter でドロップダウンを作る部品はいくつかあります。</p>



<p class="wp-block-paragraph">本記事では、フォームの仕組みにも組み込める <strong>DropdownButtonFormField</strong> を使います。<strong>画面に出す文字と、プログラムが受け取る値を分ける方法</strong>、最初に選んでおく値の決め方、選べなくする方法を、動くコードで説明します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutter でドロップダウン（プルダウン）を作りたい人</li>



<li>選択肢をリストから作る方法を知りたい人</li>



<li>画面に出す名前と、プログラムが使う値を分けたい人</li>



<li>ドロップダウンを、条件によって選べなくしたい人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">DropdownButtonFormField（ドロップダウン）</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1376" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field.webp" alt="" class="wp-image-9213" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field.webp 1376w, https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field-300x167.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field-767x428.webp 767w, https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field-1024x572.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/dropdown-button-form-field-320x180.webp 320w" sizes="(max-width: 1376px) 100vw, 1376px" /></figure>



<p class="wp-block-paragraph">DropdownButtonFormField は、<strong>押すと選択肢の一覧が開き、1つを選べる部品</strong>です。公式の説明では、ドロップダウンの部品である DropdownButton を、フォームの入力欄として使えるように包んだものです。複数の入力欄をまとめて検証したいときに使う Form の中に置けますが、Form がなくても使えます。</p>



<p class="wp-block-paragraph">この記事で使うプロパティは3つです。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プロパティ</th><th>役割</th></tr></thead><tbody><tr><td>items</td><td>選択肢の一覧（DropdownMenuItem のリスト）。必須</td></tr><tr><td>initialValue</td><td>最初に選んでおく値</td></tr><tr><td>onChanged</td><td>選び直したときに呼ばれる関数</td></tr></tbody></table></div></figure>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">古い記事では、最初に選んでおく値に value を使っています。公式では <strong>value は非推奨</strong>になっており、<strong>initialValue を使う</strong>よう案内されています（v3.33.0-1.0.pre の後に非推奨）。新しく書くときは initialValue を使ってください。</p>
</div>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://api.flutter.dev/flutter/material/DropdownButtonFormField-class.html">DropdownButtonFormField</a></p>



<p class="wp-block-paragraph">本記事では、次の動きをする画面を作ります。</p>



<ul class="wp-block-list">
<li>言語の一覧から1つを選べる</li>



<li>選んだ言語の名前と ID を、ドロップダウンの下に表示する</li>



<li>「変更を許可する」スイッチをオフにすると、ドロップダウンが押せなくなる</li>
</ul>



<h2 class="wp-block-heading">ソースコード</h2>



<ul class="wp-block-list">
<li>language.dart</li>
</ul>



<p class="wp-block-paragraph">選択肢1つ分のクラスと、一覧のデータです。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>/// 選択肢1つ分。id は選んだときに渡る値、name は画面に出る文字。
class Language {
  const Language(this.id, this.name);

  final String id;
  final String name;
}

const languages = [
  Language(&#39;ja-JP&#39;, &#39;日本語 (日本)&#39;),
  Language(&#39;en-US&#39;, &#39;English (United States)&#39;),
  Language(&#39;fr-FR&#39;, &#39;Français (France)&#39;),
];</code></pre></div>



<ul class="wp-block-list">
<li>language_dropdown.dart</li>
</ul>



<p class="wp-block-paragraph">ドロップダウン部分の部品です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;../models/language.dart&#39;;

class LanguageDropdown extends StatelessWidget {
  const LanguageDropdown({
    super.key,
    required this.languages,
    required this.selectedId,
    required this.enabled,
    required this.onChanged,
  });

  final List&lt;Language&gt; languages;
  final String? selectedId;
  final bool enabled;
  final ValueChanged&lt;String?&gt; onChanged;

  @override
  Widget build(BuildContext context) {
    return DropdownButtonFormField&lt;String&gt;(
      initialValue: selectedId,
      decoration: const InputDecoration(
        border: OutlineInputBorder(),
        labelText: &#39;言語&#39;,
      ),
      items: [
        for (final language in languages)
          DropdownMenuItem(value: language.id, child: Text(language.name)),
      ],
      // onChanged が null のとき、ドロップダウンは押せなくなる。
      onChanged: enabled ? onChanged : null,
    );
  }
}</code></pre></div>



<ul class="wp-block-list">
<li>dropdown_page.dart</li>
</ul>



<p class="wp-block-paragraph">画面です。選んだ値と、変更できるかどうかの状態を持ちます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;../models/language.dart&#39;;
import &#39;../widgets/language_dropdown.dart&#39;;

class DropdownPage extends StatefulWidget {
  const DropdownPage({super.key, required this.title});

  final String title;

  @override
  State&lt;DropdownPage&gt; createState() =&gt; _DropdownPageState();
}

class _DropdownPageState extends State&lt;DropdownPage&gt; {
  String? _selectedId = languages.first.id;
  bool _enabled = true;

  String get _selectedName =&gt;
      languages.firstWhere((l) =&gt; l.id == _selectedId).name;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            LanguageDropdown(
              languages: languages,
              selectedId: _selectedId,
              enabled: _enabled,
              onChanged: (id) =&gt; setState(() =&gt; _selectedId = id),
            ),
            const SizedBox(height: 12),
            Text(&#39;選んだ言語: $_selectedName（ID: $_selectedId）&#39;),
            const SizedBox(height: 12),
            SwitchListTile(
              title: const Text(&#39;変更を許可する&#39;),
              value: _enabled,
              onChanged: (value) =&gt; setState(() =&gt; _enabled = value),
            ),
          ],
        ),
      ),
    );
  }
}</code></pre></div>



<ul class="wp-block-list">
<li>main.dart</li>
</ul>



<p class="wp-block-paragraph">動かすための最小の入口です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;pages/dropdown_page.dart&#39;;

void main() {
  runApp(
    const MaterialApp(home: DropdownPage(title: &#39;ドロップダウン&#39;)),
  );
}</code></pre></div>



<h3 class="wp-block-heading">解説</h3>



<p class="wp-block-paragraph">選択肢のデータ（language.dart）、ドロップダウンの部品（language_dropdown.dart）、画面（dropdown_page.dart）を分けています。ドロップダウンの部品は、選択肢の一覧、いま選んでいる値、選べるかどうか、選び直したときの処理を、外から受け取るだけです。選んだ値は画面側が持ちます。</p>



<h4 class="wp-block-heading">Language：選ぶ値と画面の文字を分ける</h4>



<p class="wp-block-paragraph">選択肢を、ただの文字列のリストにすることもできます。この記事では、<strong>id（プログラムが使う値）と name（画面に出す文字）</strong>の2つを持つクラスにしました。</p>



<p class="wp-block-paragraph">分けておくと、画面の<strong>表示を変えても、プログラムが受け取る値が変わりません</strong>。たとえば表示を「日本語 (日本)」から「Japanese」に変えても、受け取る値は ja-JP のままです。</p>



<h4 class="wp-block-heading">items：リストから選択肢を作る</h4>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>items: [
  for (final language in languages)
    DropdownMenuItem(value: language.id, child: Text(language.name)),
],</code></pre></div>



<p class="wp-block-paragraph"><strong>リストの中に for を書く</strong>と、一覧のデータから選択肢を作れます。DropdownMenuItem の value が、選んだときに受け取る値、child が画面に出る文字です。一覧に項目を足すだけで、選択肢も増えます。</p>



<h4 class="wp-block-heading">initialValue：最初に選んでおく値</h4>



<p class="wp-block-paragraph">initialValue に、最初に選んでおく値を渡します。ここに渡す値は、<strong>items の value のどれか1つと一致している必要</strong>があります。</p>



<p class="wp-block-paragraph">initialValue は、最初の1回に使う値です。選び直したあとの値は、onChanged で受け取って画面側で持ちます。</p>



<h4 class="wp-block-heading">onChanged：選び直したときの処理と、選べなくする方法</h4>



<p class="wp-block-paragraph">onChanged には、選び直したときに呼ばれる関数を渡します。引数が、選ばれた value です。この画面では setState で _selectedId を更新し、下の表示を変えています。</p>



<p class="wp-block-paragraph">ドロップダウンを選べなくしたいときは、<strong>onChanged に null を渡します</strong>。公式の説明では、onChanged が null のとき、ドロップダウンは無効になります。この画面では、スイッチの状態 enabled が false のときに null を渡しています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>onChanged: enabled ? onChanged : null,</code></pre></div>



<p class="wp-block-paragraph">無効のときに出す案内文は、disabledHint で指定できます。</p>



<h2 class="wp-block-heading">実装</h2>



<ol class="wp-block-list">
<li>Flutter のプロジェクトを作る（追加するパッケージはありません）</li>



<li>3つのファイルを、上の場所に置く</li>



<li>main.dart を書き換えて、実行する</li>
</ol>



<p class="wp-block-paragraph">ドロップダウンを押して言語を選ぶと、下の表示が変わります。スイッチをオフにすると、ドロップダウンを押せなくなります。</p>



<h2 class="wp-block-heading">エラーと解決策・対策</h2>



<p class="wp-block-paragraph">以下では、公式の説明で示されているエラーと対処を紹介します。実際に起きたエラーではなく、起こりやすい点をまとめたものです。</p>



<h3 class="wp-block-heading">There should be exactly one item with [DropdownButton]&#8217;s value</h3>



<p class="wp-block-paragraph">initialValue に、items の value に存在しない値を渡すと、このメッセージで止まります。公式の説明では、一致する項目がないとき、または2つ以上あるときに出ます。</p>



<ul class="wp-block-list">
<li>initialValue の値が、items の value のどれかと一致しているか確認する</li>



<li>同じ value の項目が2つ以上ないか確認する</li>



<li>最初は何も選ばない状態にしたいときは、initialValue を null にする</li>
</ul>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">DropdownButtonFormField は、items、initialValue、onChanged の3つを渡せば動きます。</p>



<ul class="wp-block-list">
<li>選択肢は、プログラムが使う値と画面に出す文字を分けたクラスで作る</li>



<li>選択肢のリストは、リスト内の for で作る</li>



<li>最初に選んでおく値は initialValue（古い value は非推奨）</li>



<li>onChanged に null を渡すと、ドロップダウンを選べなくできる</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/dropdownbuttonformfield/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】TextFieldの使い方｜文字の取得・書き換え</title>
		<link>https://alicia-ing.com/programming/flutter/textfield-input/</link>
					<comments>https://alicia-ing.com/programming/flutter/textfield-input/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 11 Oct 2026 22:00:00 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=9191</guid>

					<description><![CDATA[アプリの入力欄は、手で打った文字を読むだけでなく、プログラムから文字を入れたり、中身が変わるたびに何かを表示したりしたい場面がよくあります。 Flutter では、入力欄の部品 TextField に、中身を操作するため [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">手で文字を打てて、ボタンでコードから文字を入れたり全部消したりでき、文字数もリアルタイムで表示される入力欄を、TextField と TextEditingController で作れます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="960" height="540" src="https://alicia-ing.com/wp-content/uploads/2026/10/complete-1.webp" alt="" class="wp-image-9205" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/complete-1.webp 960w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-1-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-1-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-1-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-1-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-1-640x360.webp 640w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
</div></div>



<p class="wp-block-paragraph">アプリの入力欄は、手で打った文字を読むだけでなく、プログラムから文字を入れたり、中身が変わるたびに何かを表示したりしたい場面がよくあります。</p>



<p class="wp-block-paragraph">Flutter では、入力欄の部品 <strong>TextField</strong> に、中身を操作するための <strong>TextEditingController</strong> を組み合わせると、どちらもできます。</p>



<p class="wp-block-paragraph">本記事では、サンプル文を入れる、全部消す、文字数を表示する、という3つの動きを持つ入力欄を作りながら、TextField と TextEditingController の使い方を説明します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutter で入力欄（テキストボックス）を作りたい人</li>



<li>入力された文字を、コードから読み取りたい人</li>



<li>ボタンなどで、コードから入力欄の文字を書き換えたい人</li>



<li>TextEditingController を、なぜ後片付けしなければいけないのか知りたい人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">TextField（テキスト入力欄）</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1376" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box.webp" alt="" class="wp-image-9206" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box.webp 1376w, https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box-300x167.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box-767x428.webp 767w, https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box-1024x572.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/textfield-input-box-240x135.webp 240w" sizes="(max-width: 1376px) 100vw, 1376px" /></figure>



<p class="wp-block-paragraph">TextField は、<strong>文字を入力するための入力欄の部品</strong>です。最小の書き方は次のとおりです。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>const TextField()</code></pre></div>



<p class="wp-block-paragraph">見た目や動きは、プロパティで変えます。この記事で使うものは次の3つです。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プロパティ</th><th>役割</th></tr></thead><tbody><tr><td>controller</td><td>入力欄の中身を操作する TextEditingController を渡す</td></tr><tr><td>maxLines</td><td>表示する行数。2以上にすると複数行の入力欄になる</td></tr><tr><td>decoration</td><td>枠線や、何も入力されていないときの案内文（hintText）を決める</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://api.flutter.dev/flutter/material/TextField-class.html">TextField</a>（Flutter公式）</p>



<h2 class="wp-block-heading">TextEditingController（入力欄の中身を操作する）</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1376" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller.webp" alt="" class="wp-image-9207" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller.webp 1376w, https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller-300x167.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller-767x428.webp 767w, https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller-1024x572.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/text-editing-controller-320x180.webp 320w" sizes="(max-width: 1376px) 100vw, 1376px" /></figure>



<p class="wp-block-paragraph">TextEditingController は、<strong>入力欄の中身を読んだり書いたりするための部品</strong>です。TextField の <strong>controller に渡す</strong>と、2つの部品がつながります。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>final TextEditingController _controller = TextEditingController();

TextField(controller: _controller)</code></pre></div>



<p class="wp-block-paragraph">つなげたあとは、次のことができます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>やりたいこと</th><th>書き方</th></tr></thead><tbody><tr><td>いまの文字を読む</td><td>_controller.text</td></tr><tr><td>文字を書き換える</td><td>_controller.text = &#8216;新しい文字&#8217;</td></tr><tr><td>全部消す</td><td>_controller.clear()</td></tr><tr><td>中身が変わったことを知る</td><td>_controller.addListener(&#8230;)、またはウィジェットで監視する</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph"><strong>入力された文字を取る方法</strong>は、TextEditingController 以外にもあります。それぞれ、呼ばれるタイミングが違います。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>方法</th><th>タイミング</th></tr></thead><tbody><tr><td>onChanged</td><td>1文字入力するたびに呼ばれる</td></tr><tr><td>onSubmitted</td><td>入力を終えたとき（キーボードの確定ボタンなど）に呼ばれる</td></tr><tr><td>TextEditingController</td><td>好きなタイミングで text を読める。コードから書き換えもできる</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">読むだけなら onChanged や onSubmitted でも足ります。この記事のように、コードから文字を入れたり、文字数を出し続けたりするなら、<strong>TextEditingController が向いています</strong>。</p>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://api.flutter.dev/flutter/widgets/TextEditingController-class.html">Flutter 公式 API</a></p>



<p class="wp-block-paragraph">この記事では、次の動きをする入力欄を作ります。</p>



<ul class="wp-block-list">
<li>手で文字を入力できる（複数行）</li>



<li>入力欄の下に、いまの文字数が出る</li>



<li>「サンプルを入れる」ボタンで、コードから文章が入る。カーソルは文字の最後に置く</li>



<li>「全部消す」ボタンで、入力欄が空になる</li>
</ul>



<h2 class="wp-block-heading">ソースコード</h2>



<ul class="wp-block-list">
<li>text_input_page.dart</li>
</ul>



<p class="wp-block-paragraph">入力欄、文字数の表示、2つのボタンを持つ画面です。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

class TextInputPage extends StatefulWidget {
  const TextInputPage({super.key, required this.title});

  final String title;

  @override
  State&lt;TextInputPage&gt; createState() =&gt; _TextInputPageState();
}

class _TextInputPageState extends State&lt;TextInputPage&gt; {
  static const _sampleText = &#39;Hello, nice to meet you.&#39;;

  final TextEditingController _controller = TextEditingController();

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  /// コードから文字を入れ、カーソルを文字の最後に置く。
  void _insertSample() {
    _controller.text = _sampleText;
    _controller.selection = TextSelection.collapsed(offset: _sampleText.length);
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            TextField(
              controller: _controller,
              maxLines: 6,
              decoration: const InputDecoration(
                border: OutlineInputBorder(),
                hintText: &#39;直接入力してください&#39;,
              ),
            ),
            const SizedBox(height: 12),
            // 中身が変わるたびに、文字数を作り直す。
            ListenableBuilder(
              listenable: _controller,
              builder: (context, _) =&gt; Text(&#39;${_controller.text.length} 文字&#39;),
            ),
            const SizedBox(height: 12),
            Row(
              children: [
                FilledButton(
                  onPressed: _insertSample,
                  child: const Text(&#39;サンプルを入れる&#39;),
                ),
                const SizedBox(width: 12),
                OutlinedButton(
                  onPressed: _controller.clear,
                  child: const Text(&#39;全部消す&#39;),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}</code></pre></div>



<ul class="wp-block-list">
<li>main.dart</li>
</ul>



<p class="wp-block-paragraph">動かすための最小の入口です。text_input_page.dart は lib/pages/ に置きます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;pages/text_input_page.dart&#39;;

void main() {
  runApp(
    const MaterialApp(home: TextInputPage(title: &#39;テキスト入力&#39;)),
  );
}</code></pre></div>



<h3 class="wp-block-heading">解説</h3>



<p class="wp-block-paragraph">画面は StatefulWidget で作っています。TextEditingController は、画面が表示されている間ずっと同じものを使い続けるので、State のフィールドとして1つだけ作ります。</p>



<p class="wp-block-paragraph">使っている部品は、入力欄の TextField、文字数を出す ListenableBuilder、操作する2つのボタンです。</p>



<h4 class="wp-block-heading">ListenableBuilder：文字数を更新し続ける</h4>



<p class="wp-block-paragraph">文字数の Text は ListenableBuilder で包んでいます。listenable に TextEditingController を渡すと、中身が変わるたびに builder の中が作り直されます。</p>



<p class="wp-block-paragraph">TextEditingController は、中身が変わると監視している側に知らせる仕組みを持っています（変化を知らせる部品の仲間として作られています）。ListenableBuilder は、公式の説明では、監視している対象が変わったときに、その部分の画面を作り直す部品で、builder は変化の知らせが来るたびに呼ばれます。ここでは、その知らせを受け取って、文字数の表示だけを更新します。</p>



<p class="wp-block-paragraph">onChanged の中で setState を呼んでも文字数は出せます。ただ、その場合は画面全体が作り直されます。ListenableBuilder なら、<strong>作り直す範囲を文字数の部分だけに絞れます</strong>。</p>



<h4 class="wp-block-heading">_insertSample：コードから文字を入れる</h4>



<p class="wp-block-paragraph">_controller.text = _sampleText; で、入力欄の文字が置き換わります。</p>



<p class="wp-block-paragraph">ただし、公式の説明では、text を書き換えると、<strong>選択範囲や変換中の範囲が消えます</strong>。文字を入れたあと、カーソルをどこに置くかも決まらなくなります。</p>



<p class="wp-block-paragraph">そこで、次の行で<strong>カーソルを文字の最後に置いています</strong>。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>_controller.selection = TextSelection.collapsed(offset: _sampleText.length);</code></pre></div>



<p class="wp-block-paragraph">TextSelection.collapsed は、範囲を選ばず、1か所にカーソルを置く指定です。offset に文字数を渡すと、文字の最後になります。</p>



<p class="wp-block-paragraph">文字とカーソルを同時に決めたいときは、公式の説明のとおり、value に TextEditingValue をまとめて入れる方法もあります。</p>



<h4 class="wp-block-heading">clear：全部消す</h4>



<p class="wp-block-paragraph">_controller.clear は、入力欄を空にする関数です。ボタンの onPressed に、そのまま渡せます。</p>



<h4 class="wp-block-heading">dispose：後片付け</h4>



<p class="wp-block-paragraph">TextEditingController は、使い終わったら dispose で後片付けします。公式の説明にも、不要になったら <strong>dispose する</strong>、と書かれています。画面が閉じるときに呼ばれる State の dispose の中で、_controller.dispose() を呼びます。</p>



<h2 class="wp-block-heading">エラーと解決策・対策</h2>



<p class="wp-block-paragraph">以下では、公式の説明で注意されている、つまずきやすい点と対処を紹介します。実際に起きたエラーではなく、起こりやすい点をまとめたものです。</p>



<h3 class="wp-block-heading">文字を入れたのに、カーソルが思った場所にない</h3>



<p class="wp-block-paragraph">_controller.text だけを書き換えた場合、選択範囲が消えるため、カーソルの位置が思った場所にならないことがあります。上のコードのように selection も指定するか、value にまとめて入れてください。</p>



<h3 class="wp-block-heading">入力のたびに、変な動きや無限ループになる</h3>



<p class="wp-block-paragraph">addListener の中で、同じ TextEditingController の text を書き換えると、書き換えがまた知らせとして届くため、<strong>無限に繰り返すおそれ</strong>があります。公式の説明でも、この点が注意されています。入力内容を整えたいときは、入力時に文字を変換する TextInputFormatter を使ってください。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">TextField は入力欄の部品、TextEditingController はその中身を操作する部品です。</p>



<ul class="wp-block-list">
<li>controller に渡すと、text で読み書きできる</li>



<li>text を書き換えると選択範囲が消えるので、カーソルの位置は selection で決める</li>



<li>中身の変化に合わせて表示を変えるなら、ListenableBuilder で作り直す範囲を絞れる</li>



<li>使い終わったら dispose で後片付けする</li>



<li></li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/textfield-input/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】speech_to_textで音声入力し文字起こし</title>
		<link>https://alicia-ing.com/programming/flutter/speech-to-text-voiceinput/</link>
					<comments>https://alicia-ing.com/programming/flutter/speech-to-text-voiceinput/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sat, 10 Oct 2026 14:47:43 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=9185</guid>

					<description><![CDATA[Flutterで英会話アプリや音声メモアプリを作るとき話した言葉を文字に入力が第一歩です。 Flutterではspeech_to_textというパッケージを使うと、スマホやブラウザに入っている音声認識の機能を、短いコード [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box not-nested-style cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph"> 話しかけた内容がそのまま画面に文字で出続け、音声認識が止まっても自動で聞き取り直す音声入力画面を、speech_to_text で作れます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="960" height="540" src="https://alicia-ing.com/wp-content/uploads/2026/10/complete.webp" alt="" class="wp-image-9199" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/complete.webp 960w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-240x135.webp 240w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/complete-640x360.webp 640w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
</div></div>



<p class="wp-block-paragraph">Flutterで英会話アプリや音声メモアプリを作るとき話した言葉を文字に入力が第一歩です。</p>



<p class="wp-block-paragraph">Flutterでは<strong>speech_to_text</strong>というパッケージを使うと、スマホやブラウザに入っている音声認識の機能を、短いコードで呼び出せます。ただし、そのままだと無音が続いたときなどに認識が止まってしまいます。</p>



<p class="wp-block-paragraph">本記事では、話している途中の文字を表示しながら、止まったら自動で聞き取り直す画面を作ります。パッケージの呼び出しは別のクラスに分け、画面側のコードをすっきりさせます。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutter で音声入力を作りたい人</li>



<li>speech_to_text の基本的な流れ（初期化、聞き取り開始、結果の受け取り）を知りたい人</li>



<li>話している途中の文字を、画面にリアルタイムで表示したい人</li>



<li>音声認識が途中で止まる問題への対処を知りたい人</li>
</ul>
</div></div>



<h2 class="wp-block-heading">speech_to_text（音声認識パッケージ）</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1376" height="768" src="https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package.webp" alt="" class="wp-image-9200" srcset="https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package.webp 1376w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package-300x167.webp 300w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package-767x428.webp 767w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package-1024x572.webp 1024w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package-320x180.webp 320w, https://alicia-ing.com/wp-content/uploads/2026/10/speech-to-text-package-240x135.webp 240w" sizes="(max-width: 1376px) 100vw, 1376px" /></figure>



<p class="wp-block-paragraph">speech_to_text は、端末に入っている音声認識の機能を Flutter から使うためのパッケージです。Android、iOS、Web に対応しています。</p>



<p class="wp-block-paragraph">注意したいのは、このパッケージが想定している使い方です。公式の説明では、想定しているのはコマンドや短いフレーズで、長い会話を途切れなく文字にしたり、ずっと聞き続けたりする使い方は想定外とされています。</p>



<p class="wp-block-paragraph">そのため、今回のように「開いている間ずっと聞き取る」画面を作るときは、止まったら聞き取り直す仕組みを自分で用意します。</p>



<h3 class="wp-block-heading">インストール</h3>



<p class="wp-block-paragraph"><strong>pubspec.yaml の dependencies に追加</strong>します。この記事のコードは ^7.4.0 で作っています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>dependencies:
  speech_to_text: ^7.4.0
</code></pre></div>



<h3 class="wp-block-heading">事前設定（マイクの許可）</h3>



<p class="wp-block-paragraph">マイクを使うため、プラットフォームごとに設定が必要です。設定の内容は公式ページの記載にもとづきます。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>プラットフォーム</th><th>設定</th></tr></thead><tbody><tr><td>Android</td><td>AndroidManifest.xml に RECORD_AUDIO と INTERNET などの権限を追加する。ターゲット SDK が 30 以上なら、android.speech.RecognitionService を指定した queries も追加する</td></tr><tr><td>iOS</td><td>Info.plist に NSSpeechRecognitionUsageDescription と NSMicrophoneUsageDescription を追加する</td></tr><tr><td>Web</td><td>設定は不要。ただし対応しているブラウザは一部のみ</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">参考：<a target="_self" href="https://pub.dev/packages/speech_to_text">speech_to_text 公式ページ</a></p>



<h2 class="wp-block-heading">話した内容を文字にする音声入力画面</h2>



<p class="wp-block-paragraph">ここまでの内容をもとに、次の動きをする画面を作ります。</p>



<ul class="wp-block-list">
<li>画面を開くと、すぐ聞き取りを始める</li>



<li>話している途中の文字も、確定した文字も、画面に出し続ける</li>



<li>右上のマイクのアイコンが、聞き取り中は赤、停止中は灰色になる</li>



<li>認識が止まったら、少し待って自動で聞き取り直す</li>
</ul>



<h2 class="wp-block-heading">ソースコード</h2>



<ul class="wp-block-list">
<li>speech_service.dart</li>
</ul>



<p class="wp-block-paragraph">speech_to_text を包むクラス。パッケージの細かい呼び出しをここに集める</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:speech_to_text/speech_to_text.dart&#39; as stt;

class SpeechService {
  final stt.SpeechToText _speech = stt.SpeechToText();

  Future&lt;bool&gt; initialize({
    required void Function(bool isListening) onStatusChange,
    required void Function(String message) onError,
  }) {
    return _speech.initialize(
      onStatus: (status) =&gt; onStatusChange(status == &#39;listening&#39;),
      onError: (error) =&gt; onError(error.errorMsg),
    );
  }

  /// 話した内容を、認識できた分だけ onResult に渡し続ける。
  /// 一区切り話し終えると isFinal が true になる。
  Future&lt;void&gt; listen({
    required void Function(String recognizedWords, bool isFinal) onResult,
    String? localeId,
  }) {
    return _speech.listen(
      onResult: (result) =&gt; onResult(result.recognizedWords, result.finalResult),
      listenOptions: stt.SpeechListenOptions(
        localeId: localeId,
        partialResults: true,
      ),
    );
  }

  Future&lt;void&gt; stop() =&gt; _speech.stop();
}
</code></pre></div>



<ul class="wp-block-list">
<li>voice_input_page.dart</li>
</ul>



<p class="wp-block-paragraph">画面。表示する文字と状態だけを持つ</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;dart:async&#39;;
import &#39;package:flutter/material.dart&#39;;
import &#39;../services/speech_service.dart&#39;;

class VoiceInputPage extends StatefulWidget {
  const VoiceInputPage({super.key, required this.title});

  final String title;

  @override
  State&lt;VoiceInputPage&gt; createState() =&gt; _VoiceInputPageState();
}

class _VoiceInputPageState extends State&lt;VoiceInputPage&gt; {
  final SpeechService _speech = SpeechService();

  bool _speechEnabled = false;
  bool _isListening = false;
  Timer? _restartTimer;

  String _committedText = &#39;&#39;; // 話し終えて確定した分
  String _partialText = &#39;&#39;; // いま話している途中の分
  String _statusMessage = &#39;&#39;;

  @override
  void initState() {
    super.initState();
    _initSpeech();
  }

  @override
  void dispose() {
    _restartTimer?.cancel();
    _speech.stop();
    super.dispose();
  }

  Future&lt;void&gt; _initSpeech() async {
    final available = await _speech.initialize(
      onStatusChange: _handleStatus,
      onError: _handleError,
    );
    if (!mounted) return;
    setState(() {
      _speechEnabled = available;
      if (!available) _statusMessage = &#39;この端末では音声認識を利用できません&#39;;
    });
    if (available) _listen();
  }

  Future&lt;void&gt; _listen() async {
    if (!mounted || !_speechEnabled || _isListening) return;
    await _speech.listen(onResult: _handleResult);
  }

  void _handleResult(String words, bool isFinal) {
    setState(() {
      if (isFinal) {
        _committedText = &#39;$_committedText $words&#39;.trim();
        _partialText = &#39;&#39;;
      } else {
        _partialText = words;
      }
    });
  }

  // 認識が止まったら、少し待って聞き取り直す。
  void _handleStatus(bool listening) {
    if (!mounted) return;
    setState(() =&gt; _isListening = listening);
    if (!listening && _speechEnabled) {
      _restartTimer?.cancel();
      _restartTimer = Timer(const Duration(milliseconds: 300), _listen);
    }
  }

  void _handleError(String message) {
    if (!mounted) return;
    setState(() {
      _isListening = false;
      _statusMessage = &#39;音声認識エラー: $message&#39;;
      // マイクの許可がないときは、やり直しても同じなので止める。
      if (message.contains(&#39;permission&#39;)) _speechEnabled = false;
    });
  }

  String get _displayText =&gt; &#39;$_committedText $_partialText&#39;.trim();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
        actions: [
          Padding(
            padding: const EdgeInsets.only(right: 16),
            child: Icon(
              _isListening ? Icons.mic : Icons.mic_off,
              color: _isListening ? Colors.red : Colors.grey,
            ),
          ),
        ],
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Expanded(
              child: SingleChildScrollView(
                child: Text(
                  _displayText.isEmpty ? &#39;話しかけてください&#39; : _displayText,
                  style: Theme.of(context).textTheme.headlineSmall,
                ),
              ),
            ),
            Text(_statusMessage),
          ],
        ),
      ),
    );
  }
}
</code></pre></div>



<ul class="wp-block-list">
<li>main.dart</li>
</ul>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>import &#39;package:flutter/material.dart&#39;;

import &#39;pages/voice_input_page.dart&#39;;

void main() {
  runApp(
    const MaterialApp(home: VoiceInputPage(title: &#39;音声入力&#39;)),
  );
}
</code></pre></div>



<h3 class="wp-block-heading">解説</h3>



<p class="wp-block-paragraph">音声認識の呼び出しはSpeechServiceに集め、画面のVoiceInputPageは「いま何が表示されているか」だけを持ちます。こうしておくと、あとで別のパッケージに替えるときも、直すのは SpeechService だけで済みます。</p>



<p class="wp-block-paragraph">画面が持つ状態は次の4つです。</p>



<figure class="wp-block-table"><div class="scrollable-table"><table class="has-fixed-layout"><thead><tr><th>変数</th><th>意味</th></tr></thead><tbody><tr><td>_speechEnabled</td><td>この端末で音声認識が使えるか</td></tr><tr><td>_isListening</td><td>いま聞き取り中か（アイコンの色に使う）</td></tr><tr><td>_committedText</td><td>話し終えて確定した文字</td></tr><tr><td>_partialText</td><td>いま話している途中の文字</td></tr></tbody></table></div></figure>



<h3 class="wp-block-heading">各関数の機能</h3>



<h4 class="wp-block-heading">initialize：音声認識を使える状態にする</h4>



<p class="wp-block-paragraph">initializeは、<strong>音声認識を使える状態にする最初の処理</strong>です。使えるときは true、使えないときは false が返ります。公式の説明では、initializeは一度だけ呼ぶ想定で、2回目以降の呼び出しは無視されます。そのため、状態の変化とエラーを受け取る関数は、最初の呼び出しで渡します。</p>



<p class="wp-block-paragraph">SpeechService.initialize では、受け取った状態が listening のときだけ true として画面に伝えます。</p>



<h4 class="wp-block-heading">listen：聞き取りを始める</h4>



<p class="wp-block-paragraph"><strong>listen で聞き取り</strong>を始めます。ポイントは partialResults: true です。これを指定すると、話し終わるのを待たず、話している途中の文字が結果に何度も届きます。話しながら文字が増えていく動きは、この設定のおかげです。</p>



<p class="wp-block-paragraph"><strong>localeIdを省略すると、端末の標準の言語で聞き取り</strong>ます。言語を指定したいときは、locales() で取れる言語の一覧にある ID を渡します。</p>



<h4 class="wp-block-heading">_handleResult：途中の文字と確定した文字を分ける</h4>



<p class="wp-block-paragraph">結果は isFinal で2つに分かれます。</p>



<ul class="wp-block-list">
<li>isFinal が false：話している途中。_partialText を上書きする</li>



<li>isFinal が true：一区切り話し終えた。_committedText の後ろに足し、_partialText を空にする</li>
</ul>



<p class="wp-block-paragraph">画面には、2つをつなげた _displayText を出します。</p>



<h4 class="wp-block-heading">_handleStatus：止まったら聞き取り直す</h4>



<p class="wp-block-paragraph"><strong>音声認識は、無音が続くなどで自分から止まります。</strong>公式の説明のとおり、ずっと聞き続ける使い方は想定されていないためです。</p>



<p class="wp-block-paragraph">そこで、状態が「聞き取り中」から変わったら、Timer で 300 ミリ秒待ってから _listen を呼び直します。止まった直後には呼び直さず、少し間を置いてから再開しています。</p>



<h4 class="wp-block-heading">_handleError：許可がないときは止める</h4>



<p class="wp-block-paragraph">エラーの文字にpermission が含まれていたら、マイクの許可がありません。何度やり直しても同じ結果になるので_speechEnabled を false にして再開を止めます。</p>



<h4 class="wp-block-heading">dispose：後片付け</h4>



<p class="wp-block-paragraph">画面を閉じるときに、再開用のTimerを止め、聞き取りも止めます。</p>



<h2 class="wp-block-heading">実装</h2>



<ol class="wp-block-list">
<li>Flutter のプロジェクトを作り、speech_to_text を pubspec.yaml に追加して flutter pub get を実行する</li>



<li>先ほどの「事前設定」を済ませる</li>



<li>上のコードを lib/ に置き、実行する</li>



<li>初回はマイクの許可を求められるので、許可する</li>
</ol>



<p class="wp-block-paragraph">画面を開くと聞き取りが始まり、アイコンが赤になります。話しかけると、途中の文字が出て、話し終えると確定します。</p>



<h2 class="wp-block-heading">エラーと解決策・対策</h2>



<p class="wp-block-paragraph">以下では、想定しうるエラーの解決方法を紹介します。</p>



<h3 class="wp-block-heading">「この端末では音声認識を利用できません」と出る</h3>



<p class="wp-block-paragraph"><strong>initialize が false を返した状態</strong>です。音声認識が使えない環境で起きます。公式の説明では、ビルドはできても音声認識に対応していないプラットフォームがあり、その場合は initialize が false を返します。</p>



<p class="wp-block-paragraph">先に述べた事前設定が済んでいるか、対応しているブラウザや端末かを確認してください。</p>



<h3 class="wp-block-heading">「音声認識エラー」に permission と出る</h3>



<p class="wp-block-paragraph"><strong>マイクの許可がありません。</strong>端末やブラウザの設定で、アプリにマイクの使用を許可してください。このコードでは、許可がないと分かった時点で聞き取りのやり直しを止めます。</p>



<h3 class="wp-block-heading">言語が思った言語にならない</h3>



<p class="wp-block-paragraph">localeId を省略すると、端末の標準の言語で聞き取ります。ほかの言語で話したいときは、<strong>locales() で取れる言語の ID を listen の localeId</strong> に渡してください。</p>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">speech_to_text の流れは、initialize で準備し、listen で聞き取り、結果を受け取る、の3つです。</p>



<ul class="wp-block-list">
<li>partialResults: true で、話している途中の文字を出せる</li>



<li>isFinal で、途中の文字と確定した文字を分けて持つ</li>



<li>音声認識は自分から止まるので、状態の変化を見て聞き取り直す</li>



<li>パッケージの呼び出しは SpeechService に分け、画面は状態だけを持つ</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/speech-to-text-voiceinput/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】画面を構成するScaffoldウィジェット一覧</title>
		<link>https://alicia-ing.com/programming/flutter/scaffold/</link>
					<comments>https://alicia-ing.com/programming/flutter/scaffold/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Tue, 14 Nov 2023 22:30:16 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=4450</guid>

					<description><![CDATA[Scaffoldは、Flutterで作るアプリケーションの中で最も使用されるウィジェット（Widget）の一つです。Scaffoldなしでは、Flutterは全く使えないといえるでしょう。 本記事では、Scaffoldの [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">Scaffoldは、Flutterで作るアプリケーションの中で<strong>最も使用されるウィジェット（Widget）の一つ</strong>です。<br>Scaffoldなしでは、<strong>Flutterは全く使えない</strong>といえるでしょう。</p>



<p class="wp-block-paragraph">本記事では、Scaffoldの各プロパティについて紹介し、どんな時に使用するか解説します。</p>



<div class="wp-block-cocoon-blocks-blank-box-1 blank-box block-box has-border-color has-blue-border-color">
<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">本記事は、<strong>FlutterのインストールとVScodeの拡張機能のインストールは完了していることを想定</strong>しています。</p>



<p class="wp-block-paragraph">未完了の場合は、以下の記事を合わせて読んでください。</p>
</div>



<p class="wp-block-paragraph">Flutterの開発を進めるには、<strong>FlutterのパッケージをPCにインストール</strong>する必要があります。<br>さらに、VScodeの拡張機能を使えば、時短して開発できます。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>FlutterでVScodeの環境設定を解説</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/vscode-setting/" title="【Flutter】VSCodeでWindowsの開発を環境構築" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】VSCodeでWindowsの開発を環境構築</div><div class="blogcard-snippet internal-blogcard-snippet">Windowsを使ってflutterでvscodeの環境構築を解説をしています。アプリの開発はOSごとに使用できる言語が異なりますが、Flutterはどちらも対応していて、企業の参入もしています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.11.05</div></div></div></div></a>
</div>
</div>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutterでアプリを作りたい。</li>



<li>Scaffoldの使い方を知りたい。</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Scaffold</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget.webp" alt="" class="wp-image-4630" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/ScaffoldWiget-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">FlutterのScaffoldは、<strong>アプリケーションの基本的な構造やレイアウトを提供するウィジェット</strong>です。Scaffoldウィジェットは、<strong>通常アプリの標準的な画面構造を定義</strong>します。</p>



<p class="wp-block-paragraph">Scaffoldにはいくつか主要な要素があり、<strong>管理できるUI部品は、VScodeで確認</strong>できます。<br>コードエディタ上でマウスカーソルを合わせて、<strong>「Ctrl」を押しながらクリック</strong>してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/property-1.gif" alt="" class="wp-image-4636"/></figure>



<p class="wp-block-paragraph">「Scaffold.dart」が開かれて、使用できるプロパティーが表示されます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>class Scaffold extends StatefulWidget {
  /// Creates a visual scaffold for Material Design widgets.
  const Scaffold({
    super.key,
    this.appBar,
    this.body,
    this.floatingActionButton,
    this.floatingActionButtonLocation,
    this.floatingActionButtonAnimator,
    this.persistentFooterButtons,
    this.persistentFooterAlignment = AlignmentDirectional.centerEnd,
    this.drawer,
    this.onDrawerChanged,
    this.endDrawer,
    this.onEndDrawerChanged,
    this.bottomNavigationBar,
    this.bottomSheet,
    this.backgroundColor,
    this.resizeToAvoidBottomInset,
    this.primary = true,
    this.drawerDragStartBehavior = DragStartBehavior.start,
    this.extendBody = false,
    this.extendBodyBehindAppBar = false,
    this.drawerScrimColor,
    this.drawerEdgeDragWidth,
    this.drawerEnableOpenDragGesture = true,
    this.endDrawerEnableOpenDragGesture = true,
    this.restorationId,
  });
}</code></pre></div>



<p class="wp-block-paragraph">これらのマテリアルを使用してアプリを作成していきます。</p>



<p class="wp-block-paragraph">本記事では、アプリケーションバー・画面本体・ボトムバーなどの<strong>画面構成部品</strong>とボタンやドロワーなどの<strong>UI部品</strong>に分けて紹介をします。</p>



<h3 class="wp-block-heading">key</h3>



<p class="wp-block-paragraph">keyは、公式ページが述べているように、<br><strong>同じ型のウィジェットが複数ある</strong>場合、区別するために使用するものです。</p>



<p class="wp-block-paragraph">扱いが難しいので、<strong>複雑なアプリケーションを作らない場合は、無視しても大丈夫</strong>です。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">A&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/foundation/Key-class.html">Key</a>&nbsp;is an identifier for&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/Widget-class.html">Widget</a>s,&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/Element-class.html">Element</a>s and&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/semantics/SemanticsNode-class.html">SemanticsNode</a>s.</p>



<p class="wp-block-paragraph">A new widget will only be used to update an existing element if its key is the same as the key of the current widget associated with the element.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/foundation/Key-class.html">Key class &#8211; foundation library &#8211; Dart API</a></cite></blockquote>



<h3 class="wp-block-heading">appBar</h3>



<p class="wp-block-paragraph">appBarは、<strong>スクリーンの上部に表示するアプリケーションバーを定義するプロパティ</strong>です。<br>スクロールできるアプリバーを作成する場合は、&nbsp;SliverAppBarを使用します。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">App bars are typically used in the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/appBar.html">Scaffold.appBar</a>&nbsp;property, which places the app bar as a fixed-height widget at the top of the screen. For a scrollable app bar, see&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/SliverAppBar-class.html">SliverAppBar</a>, which embeds an&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/AppBar-class.html">AppBar</a>&nbsp;in a sliver for use in a&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/CustomScrollView-class.html">CustomScrollView</a>.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/AppBar-class.html">AppBar class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<h3 class="wp-block-heading">body</h3>



<p class="wp-block-paragraph">アプリケーションバー(appBar)とボトムバー(bottomNavigationBar)の間に配置される要素ー要するに、<strong>アプリの本体となり情報の提供や操作をする場所</strong>になります。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The widget in the body of the scaffold is positioned at the top-left of the available space between the app bar and the bottom of the scaffold. To center this widget instead, consider putting it in a&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/Center-class.html">Center</a>&nbsp;widget and having that be the body. To expand this widget instead, consider putting it in a&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/SizedBox/SizedBox.expand.html">SizedBox.expand</a>.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/body.html">body property &#8211; Scaffold class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<h3 class="wp-block-heading">floatingActionButton</h3>



<p class="wp-block-paragraph"><strong>画面上に円形のボタンとして配置</strong>されます。<br>1画面に1つだけ使用されて、作成や共有、ナビゲーションなどのアプリケーションの主要な動作を促進します。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">A floating action button is a circular icon button that hovers over content to promote a primary action in the application. Floating action buttons are mo０st commonly used in the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/floatingActionButton.html">Scaffold.floatingActionButton</a>&nbsp;field.</p>



<p class="wp-block-paragraph">Use at most a single floating action button per screen. Floating action buttons should be used for positive actions such as &#8220;create&#8221;, &#8220;share&#8221;, or &#8220;navigate&#8221;. (If more than one floating action button is used within a&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/Route-class.html">Route</a>, then make sure that each button has a unique&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/FloatingActionButton/heroTag.html">heroTag</a>, otherwise an exception will be thrown.)</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/FloatingActionButton-class.html">FloatingActionButton class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<p class="wp-block-paragraph">floatingActionButtonを使用すると、<strong>画面の右下にボタンが配置</strong>されます。このボタンを中央に配置、<strong>ボトムバーと重ねる</strong>には、「floatingActionButtonLocation」を使用します。</p>



<p class="wp-block-paragraph">floatingActionButtonAnimatorは、<strong>ボタンにアニメーションを制御する</strong>プロパティです。</p>



<h3 class="wp-block-heading">persistentFooterButtons</h3>



<p class="wp-block-paragraph"><strong>bodyプロパティの下に複数のボタンを配置</strong>できます。<br>また、bodyをスクロールしても、これらのボタンは、画面上に保持されます。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">A set of buttons that are displayed at the bottom of the scaffold.</p>



<p class="wp-block-paragraph">Typically this is a list of&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/TextButton-class.html">TextButton</a>&nbsp;widgets. These buttons are persistently visible, even if the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/body.html">body</a>&nbsp;of the scaffold scrolls.</p>



<p class="wp-block-paragraph">These widgets will be wrapped in an&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/widgets/OverflowBar-class.html">OverflowBar</a>.</p>



<p class="wp-block-paragraph">The&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/persistentFooterButtons.html">persistentFooterButtons</a>&nbsp;are rendered above the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/bottomNavigationBar.html">bottomNavigationBar</a>&nbsp;but below the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/body.html">body</a>.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/persistentFooterButtons.html">persistentFooterButtons property &#8211; Scaffold class</a></cite></blockquote>



<h3 class="wp-block-heading">drawer</h3>



<p class="wp-block-paragraph">アイコンボタン（ハンバーガーメニュー）を配置して、<strong>ボタンを押すと水平にスライドして、ナビゲーションリンクを表示</strong>します。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">A Material Design panel that slides in horizontally from the edge of a&nbsp;<a target="_self" href="https://api.flutter-io.cn/flutter/material/Scaffold-class.html">Scaffold</a>&nbsp;to show navigation links in an application.</p>



<p class="wp-block-paragraph">There is a Material 3 version of this component,&nbsp;<a target="_self" href="https://api.flutter-io.cn/flutter/material/NavigationDrawer-class.html">NavigationDrawer</a>, that&#8217;s preferred for applications that are configured for Material 3 (see&nbsp;<a target="_self" href="https://api.flutter-io.cn/flutter/material/ThemeData/useMaterial3.html">ThemeData.useMaterial3</a>).</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/Drawer-class.html">Drawer class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<p class="wp-block-paragraph">drawerは、画面左にアイコンが配置されます。<br>一方でendDrawerは、画面右にアイコンが配置されます。</p>



<h3 class="wp-block-heading">bottomNavigationBar</h3>



<p class="wp-block-paragraph"><strong>画面の下部（ボトム）にナビゲーションバーを配置</strong>します。<br>アイコンやテキストを表示し、3つ～５つの項目を表示します。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">A material widget that&#8217;s displayed at the bottom of an app for selecting among a small number of views, typically between three and five.</p>



<p class="wp-block-paragraph">There is an updated version of this component,&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/NavigationBar-class.html">NavigationBar</a>, that&#8217;s preferred for new applications and applications that are configured for Material 3 (see&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/ThemeData/useMaterial3.html">ThemeData.useMaterial3</a>).</p>



<p class="wp-block-paragraph">The bottom navigation bar consists of multiple items in the form of text labels, icons, or both, laid out on top of a piece of material. It provides quick navigation between the top-level views of an app. For larger screens, side navigation may be a better fit.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html">BottomNavigationBar class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<h3 class="wp-block-heading">bottomSheet</h3>



<p class="wp-block-paragraph">ユーザーは、ボトムシートを直接的に使うことはなく、<strong>ボタンを押すと、下部からテキストを添えたシートが表示される</strong>ものです。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/BottomSheet-class.html">BottomSheet</a>&nbsp;widget itself is rarely used directly. Instead, prefer to create a persistent bottom sheet with&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/ScaffoldState/showBottomSheet.html">ScaffoldState.showBottomSheet</a>&nbsp;or&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/bottomSheet.html">Scaffold.bottomSheet</a>, and a modal bottom sheet with&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/showModalBottomSheet.html">showModalBottomSheet</a>.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/BottomSheet-class.html">BottomSheet class &#8211; material library &#8211; Dart API</a></cite></blockquote>



<h3 class="wp-block-heading">backgroundColor</h3>



<p class="wp-block-paragraph">ウィジェットの<strong>マテリアルに色</strong>を付けます。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">The color of the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Material-class.html">Material</a>&nbsp;widget that underlies the entire Scaffold.</p>



<p class="wp-block-paragraph">The theme&#8217;s&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/ThemeData/scaffoldBackgroundColor.html">ThemeData.scaffoldBackgroundColor</a>&nbsp;by default.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/backgroundColor.html">backgroundColor property &#8211; Scaffold class &#8211; material library</a></cite></blockquote>



<p class="wp-block-paragraph">現在は、primaryやonprimaryは非推奨となり、代替としてbackgroundColorとなりました。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>this.primary = true,</code></pre></div>



<h3 class="wp-block-heading">extendBody</h3>



<p class="wp-block-paragraph"><strong>bodyの範囲ボトムナビゲーションバーまで拡張するプロパティ</strong>です。<br>同様に、extendBodyBehindAppBarはアプリケーションバーまで拡張するプロパティです。<br>通常では重ねませんが、trueにすることで変更できます。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">If true, and&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/bottomNavigationBar.html">bottomNavigationBar</a>&nbsp;or&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/persistentFooterButtons.html">persistentFooterButtons</a>&nbsp;is specified, then the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/body.html">body</a>&nbsp;extends to the bottom of the Scaffold, instead of only extending to the top of the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/bottomNavigationBar.html">bottomNavigationBar</a>&nbsp;or the&nbsp;<a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/persistentFooterButtons.html">persistentFooterButtons</a>.</p>
<cite><a target="_self" href="https://api.flutter.dev/flutter/material/Scaffold/extendBody.html">extendBody property &#8211; Scaffold class &#8211; material library</a></cite></blockquote>



<h3 class="wp-block-heading">restorationId</h3>



<p class="wp-block-paragraph">Flutterフレームワークにおいて、ウィジェットの状態を保存し、ページで構成された<strong>ルートの状態を保存および復元するための復元ID</strong>。 <br>復元IDが指定されていない場合、ルートはその状態を復元されません。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Restoration ID to save and restore the state of the&nbsp;<a target="_self" href="https://api.flutter-io.cn/flutter/widgets/Route-class.html">Route</a>&nbsp;configured by this page.</p>



<p class="wp-block-paragraph">If no restoration ID is provided, the&nbsp;<a target="_self" href="https://api.flutter-io.cn/flutter/widgets/Route-class.html">Route</a>&nbsp;will not restore its state.</p>
<cite><a target="_self" href="https://api.flutter-io.cn/flutter/widgets/Page/restorationId.html">restorationId property &#8211; Page class &#8211; widgets library &#8211; Dart API</a></cite></blockquote>



<h4 class="wp-block-heading">UdemyでFlutterを学習</h4>



<p class="wp-block-paragraph"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fnzigen-flutter_beginner%2F">Flutterアプリ開発講座(初級編)<br></a>Flutterアプリ開発の初歩から学習できて、<br><strong>Flutter未経験・プログラミング初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-widget%2F">【Flutter】UI開発でよく使うWidget50選</a><br>Flutterで頻出Widgetを紹介している。<br><strong>始めたばかりで機能を覚えたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-bootcamp-with-dart%2F">The Complete Flutter Development Bootcamp with Dart</a><br>GoogleとFlutterチームが共同作成した講座。<br><strong>本格的なFlutterエンジニアになりたい人</strong>におすすめ</li>
</ul>
</div>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">Scaffoldは、アプリケーションの基本的な構造やレイアウトを提供するウィジェットで、Flutterでのアプリ開発では必要不可欠な要素です。</p>



<p class="wp-block-paragraph">主に、プロパティはアプリケーションバー、画面本体、ボトムバーから構成されています。<br>加えて、ボタンやドロワーなどのUI部品をウィジェットがあります。</p>



<p class="wp-block-paragraph">これらを使ってFlutterでは、アプリケーション開発のハードルが低いです。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/scaffold/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】Androidアプリでのビルドエラーの対処法</title>
		<link>https://alicia-ing.com/programming/flutter/build-faild-with-an-exception/</link>
					<comments>https://alicia-ing.com/programming/flutter/build-faild-with-an-exception/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Sun, 12 Nov 2023 07:50:38 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=4395</guid>

					<description><![CDATA[FlutterをAndroidのエミュレータでアプリを動作させようとすると、「Build faild with an exception.」というエラーで実行ができない場合があります。 この時、考えられる原因と対処方法を [&#8230;]]]></description>
										<content:encoded><![CDATA[
<p class="wp-block-paragraph">FlutterをAndroidのエミュレータでアプリを動作させようとすると、「<strong>Build faild with an exception.</strong>」というエラーで実行ができない場合があります。</p>



<p class="wp-block-paragraph">この時、考えられる原因と対処方法を紹介します。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text"><strong>本記事は次の人におすすめ</strong></span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>FlutterでAndroidのエミュレータを動かせない</li>



<li>Build faild with an exception.を解決したい</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Build faild with an exception.</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception.webp" alt="Build faild with an exceptionについて" class="wp-image-4544" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/Build-faild-with-an-exception-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">「Build faild with an exception.」<br>このエラー文は、<strong>Androidのアプリケーション・ゲームを実行またはビルド</strong>した時に問題点があると表示されるものです。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>FlutterでAndroidアプリを作成する方法をまとめています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/android-emulator/" title="【Flutter】VScodeでAndroidエミュレータ起動" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】VScodeでAndroidエミュレータ起動</div><div class="blogcard-snippet internal-blogcard-snippet">AndroidアプリはAndroid Studioのインストール、Amdroid SDKが必要で、Android toolchaiの認識も同時に必須です。エミュレータの違法と聞いたことがあるかもしれませんが、エミュレータ自体は合法です。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<p class="wp-block-paragraph">Flutterの他に、<strong>Unityのビルドが失敗した時にも表示</strong>されます。</p>



<h3 class="wp-block-heading">app_plugin_loaderの保管場所</h3>



<p class="wp-block-paragraph">ほとんどの人は、app_plugin_loaderの保管が適切ではないことが考えられます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000.webp" alt="全角が表示" class="wp-image-4547" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/what-went-wrong_0000-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">警告文に追従して、問題点が挙げられています。<br>要するに、app_plugin_loaderが存在しないと判断されています。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>*What went wrong:
A problem occurred evaluating setting &quot;android&quot;.

&gt;Could not read script &quot;C:\Users(USERNAME)\Desktop\@?????????\flutter\packages
\flutter_tools\gradle\app_plugin_loader.gradle&quot; as it does not exist.</code></pre></div>



<p class="wp-block-paragraph">しかし、表示されたパスには、しっかりとflutterが保管されています。<br>原因は、<strong>パスに全角文字</strong>が含まれることです。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1423" height="113" src="https://alicia-ing.com/wp-content/uploads/2023/11/question.webp" alt="????は全角" class="wp-image-4549" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/question.webp 1423w, https://alicia-ing.com/wp-content/uploads/2023/11/question-300x24.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/question-1024x81.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/question-768x61.webp 768w" sizes="(max-width: 1423px) 100vw, 1423px" /></figure>



<p class="wp-block-paragraph">全角では、その部分は<strong>「?」に置き換えられています。</strong><br>スクリプトを読み取ることができず、認識することができません。</p>



<p class="wp-block-paragraph">flutterで環境構築するとき、配置する場所は全角文字のなくパスが複雑にならない場所に配置するべきです。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Flutterのインストール方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/vscode-setting/" title="【Flutter】VSCodeでWindowsの開発を環境構築" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】VSCodeでWindowsの開発を環境構築</div><div class="blogcard-snippet internal-blogcard-snippet">Windowsを使ってflutterでvscodeの環境構築を解説をしています。アプリの開発はOSごとに使用できる言語が異なりますが、Flutterはどちらも対応していて、企業の参入もしています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.11.05</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">対処法</h3>



<p class="wp-block-paragraph">対処は簡単で、<strong>半角のみのパスを指定</strong>してください。<br>settings.jsonを開いて、「<strong>dart.flutterSdkPath</strong>」の内容を変更します。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before.webp" alt="半角に変更" class="wp-image-4536" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-before-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">settings.jsonは、一般的にFlutterがインストールされたPCのパス「C:\Users\(USERNAME)\AppData\Roaming\Code\User\<strong>settings.json</strong>」から開くことができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1919" height="425" src="https://alicia-ing.com/wp-content/uploads/2023/11/setting-place.webp" alt="settings.jsonの位置" class="wp-image-4537" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/setting-place.webp 1919w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-place-300x66.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-place-1024x227.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-place-768x170.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-place-1536x340.webp 1536w" sizes="(max-width: 1919px) 100vw, 1919px" /></figure>



<p class="wp-block-paragraph">あるいは、<strong>VScodeを再度起動</strong>してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000.webp" alt="VScodeを再度起動" class="wp-image-4538" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json_0000-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>The SDK configured in dart.flutterSdkPath is not a vaild SDK folder.</code></pre></div>



<p class="wp-block-paragraph">SDKフォルダーが有効ではないと警告されています。<br>settings.jsonはここから開くことができます。</p>



<p class="wp-block-paragraph">開いた後、平仮名、漢字などの全角を含むパスの部分を修正してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after.webp" alt="半角に変更" class="wp-image-4539" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/setting-json-after-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<h4 class="wp-block-heading">UdemyでFlutterを学習</h4>



<p class="wp-block-paragraph"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fnzigen-flutter_beginner%2F">Flutterアプリ開発講座(初級編)<br></a>Flutterアプリ開発の初歩から学習できて、<br><strong>Flutter未経験・プログラミング初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-widget%2F">【Flutter】UI開発でよく使うWidget50選</a><br>Flutterで頻出Widgetを紹介している。<br><strong>始めたばかりで機能を覚えたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-bootcamp-with-dart%2F">The Complete Flutter Development Bootcamp with Dart</a><br>GoogleとFlutterチームが共同作成した講座。<br><strong>本格的なFlutterエンジニアになりたい人</strong>におすすめ</li>
</ul>
</div>



<h2 class="wp-block-heading">パッケージ再インストール</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/11/reinstall.webp" alt="再インストールについて" class="wp-image-4545" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/reinstall.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/11/reinstall-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/reinstall-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/reinstall-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/reinstall-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">dart.flutterSdkPathを変更すると、パッケージが変更・破損するので、widgetがエラーを起こします。</p>



<p class="wp-block-paragraph">これを修正しなければいけません。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000.webp" alt="パッケージ破損" class="wp-image-4540" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/widget-error_0000-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>flutter pub cache repair</code></pre></div>



<p class="wp-block-paragraph">flutter pub cache repairは、pubspec.yamlのパッケージすべてをインストールします。<br>ターミナルに入力して、実行してください。</p>



<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box information-box">
<p class="wp-block-paragraph">逆にすべてのパッケージを削除する場合は、「flutter clean」を使用します。</p>
</div>



<p class="wp-block-paragraph">flutter pub cache repairを実行すると、パッケージがインストールされます。<br>その後、「Flutter run」を実行させてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000.webp" alt="Flutter実行" class="wp-image-4541" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/flutter-pub-cache-repair_0000-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph"><br>パッケージすべてをダウンロードするので、少し時間がかかります。</p>



<p class="wp-block-paragraph">完了後、F5、デバックを実行してください。<br>エミュレータで動作できるようになります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000.webp" alt="実装例" class="wp-image-4543" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/Complete_0000-1536x808.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">Androidエミュレータを実行しようとしたときに、Build faild with an exception.が表示されてビルドできなかった場合、dart.flutterSdkPathに全角の文字が含まれることが考えられます。</p>



<p class="wp-block-paragraph">その場合は、settings.jsonからパスを半角に変更することで解決できます。</p>



<p class="wp-block-paragraph">さらに、パッケージが変更・破損してビルドできない場合は、ターミナルでflutter pub cache repairを実行してください。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/build-faild-with-an-exception/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】VScodeでAndroidエミュレータ起動</title>
		<link>https://alicia-ing.com/programming/flutter/android-emulator/</link>
					<comments>https://alicia-ing.com/programming/flutter/android-emulator/#respond</comments>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Fri, 10 Nov 2023 12:38:04 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=4337</guid>

					<description><![CDATA[Flutterの強みは、Android・iOSどちらも同時に開発ができることです。 現在、主流のアプリ開発できるプログラミング言語は、iOSであればSwift。AndroidであればKotlin。 アプリ開発は、ビジネス [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます。</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">Androidエミュレータを使って、アプリケーションを操作する。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1010" src="https://alicia-ing.com/wp-content/uploads/2023/11/complete.gif" alt="" class="wp-image-4501"/></figure>
</div></div>



<p class="wp-block-paragraph">Flutterの強みは、<strong>Android・iOSどちらも同時に開発ができる</strong>ことです。</p>



<p class="wp-block-paragraph">現在、主流のアプリ開発できるプログラミング言語は、<br><strong>iOSであればSwift。AndroidであればKotlin。</strong></p>



<p class="wp-block-paragraph">アプリ開発は、ビジネスの中心でもあるので、<strong>求人も多数存在</strong>します。<br>しかし、Android、iOSどちらも開発をしようとすると<strong>2つの言語をマスター</strong>しなければいけません。</p>



<p class="wp-block-paragraph">Flutterを使えば、<strong>UI・Widgetも豊富</strong>で、<strong>iOS・Androidいずれも開発</strong>できます。</p>



<p class="wp-block-paragraph">本記事では、WindowsでFlutterを使ってAndroidアプリの開発環境を構築し、<br>さらに、エミュレーターを使ってアプリを実行します。</p>



<p class="wp-block-paragraph">また、FlutterのインストールとVScodeの拡張機能のインストールは、<br>完了していることを想定しています。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Flutterの環境構築を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/vscode-setting/" title="【Flutter】VSCodeでWindowsの開発を環境構築" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/10/vscode-setting-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】VSCodeでWindowsの開発を環境構築</div><div class="blogcard-snippet internal-blogcard-snippet">Windowsを使ってflutterでvscodeの環境構築を解説をしています。アプリの開発はOSごとに使用できる言語が異なりますが、Flutterはどちらも対応していて、企業の参入もしています。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2024.11.05</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>Flutterでアプリ開発をしたい。</li>



<li>Android Studioの導入・設定を知りたい。</li>



<li>エミュレーターを起動したい。</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">Android Studio</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/11/android-studio.webp" alt="" class="wp-image-4473" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/android-studio.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">Android Studioは、<strong>Androidアプリを開発するために必要なツール</strong>で、<br>FlutterをVScodeで使用する時も、インストールが必要になるツールです。</p>



<p class="wp-block-paragraph">要するに、<strong>Androidアプリを実行するときは必ず必要になるソフトウェア</strong>です。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Android Studio は Android アプリ開発用の公式の統合開発環境（IDE）です。&nbsp;<a target="_self" href="https://www.jetbrains.com/idea/">IntelliJ IDEA</a>&nbsp;の強力なコードエディタとデベロッパー ツールをベースとした Android Studio には、Android アプリを構築する際の生産性向上に役立つ次のような多くの機能が用意されています。</p>
<cite><a target="_self" href="https://developer.android.com/studio/intro?hl=ja">Android Studio の概要</a></cite></blockquote>



<p class="wp-block-paragraph"><strong>コマンドプロンプト</strong>で使用できるパッケージを確認します。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>flutter doctor</code></pre></div>



<p class="wp-block-paragraph">入力して、実行（Enter）すると、[√]・[×]・[!]があります。</p>



<p class="wp-block-paragraph">この時、<strong>[×]・[!]は、インストールされていない。</strong><br><strong>ライセンスに承諾していない</strong>ことが挙げられます。</p>



<p class="wp-block-paragraph">Androidアプリの開発には、<strong>Android Studioと Android toolchainの２つを[√]に認識させる</strong>必要があります。</p>



<h3 class="wp-block-heading">Android Studioインストール</h3>



<p class="wp-block-paragraph"><a target="_self" href="https://developer.android.com/studio" title="公式サイト">公式サイト</a>からAndroid Studioをダウンロードします。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000.webp" alt="" class="wp-image-4474" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/Android-Studio-Dl_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">「Android Studio Giraffeをダウンロードする」に進み、<strong>ライセンス・規約を読み、承諾してダウンロード</strong>してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000.webp" alt="" class="wp-image-4475" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/read-agree_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">ダウンロードしたインストーラ―をクリックして、<strong>Nextで読み進めてインストールを完了</strong>させてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000.webp" alt="" class="wp-image-4476" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/android-studio-setup_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">インストール後、ライセンスの同意や各種情報を「Accept」で進んでください。<br>このとき、<strong>ダウンロードに時間がかかります。自分は、15分程度</strong>でした。<br><strong>ゲージが全く動く気配がありませんが、突然動く</strong>ので気長に待ってインストールを完了させてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000.webp" alt="" class="wp-image-4477" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/license-agreement_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">Flutter doctorで確認すると、Android Studioの表示は[√]となり、認識されました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1693" height="850" src="https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1.webp" alt="" class="wp-image-4491" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1.webp 1693w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1-300x151.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1-1024x514.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1-768x386.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andstu_0000-1-1536x771.webp 1536w" sizes="(max-width: 1693px) 100vw, 1693px" /></figure>



<h3 class="wp-block-heading">Command-line Toolsをインストール</h3>



<p class="wp-block-paragraph">Android Studioをインストールしても、まだエミュレートすることはできません。</p>



<p class="wp-block-paragraph">flutter doctorでAndroid toolchaiを認識する必要があります。<br>項目「cmdline-tools component is missing」の警告文通り、<strong>Command-line Toolsをインストール</strong>します。</p>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-border-color has-point-color has-blue-border-color has-blue-point-color cocoon-block-timeline"><div class="timeline-title">手順</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">Android Studioを開く</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">Settings</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step3</div><div class="timeline-item-content cf"><div class="timeline-item-title">Appearance &amp; Behavior</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step4</div><div class="timeline-item-content cf"><div class="timeline-item-title">System Settings</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step5</div><div class="timeline-item-content cf"><div class="timeline-item-title">Android SDK</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step6</div><div class="timeline-item-content cf"><div class="timeline-item-title">SDK Tools</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step7</div><div class="timeline-item-content cf"><div class="timeline-item-title">Android SDK Command-line Tools(latest)チェックを入れて、Apply</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000.webp" alt="" class="wp-image-4478" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/androidsdk_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">Applyをクリックすると、インストールが始まります。<br>完了後、finishをクリックしてください。</p>



<p class="wp-block-paragraph">Flutter doctorで確認すると、無事にインストールが完了していることが分かります。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000.webp" alt="" class="wp-image-4480" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-Com_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<h3 class="wp-block-heading">Android license status unknown</h3>



<p class="wp-block-paragraph">最後にライセンスを確認します。</p>



<p class="wp-block-paragraph">Android licenseの取得は、コマンドプロンプトで得ることができます。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>&gt;flutter doctor --android-licenses</code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000.webp" alt="" class="wp-image-4481" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/doctor-android-licenses_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph"><strong>ライセンスに承諾する場合は「y」</strong>、否認する場合は「N」を入力して、<strong>Enterキーを入力</strong>します。<br>Androidアプリを作りたい場合は、ライセンスに承諾する必要がありますので、yを6回入力します。</p>



<p class="wp-block-paragraph">これにて、ライセンスの取得もできたので、最後にflutter doctorで<strong>Android toolchaiも[√]</strong>となり、認識されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1.webp" alt="" class="wp-image-4483" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-andli_0000-1-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">以上でAndroid Studioの各種設定が終了です。</p>



<h2 class="wp-block-heading">エミュレータを設定</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/11/emulator.webp" alt="" class="wp-image-4484" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/emulator.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/11/emulator-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/emulator-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/emulator-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/emulator-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">Android StudioとAndroid toolchaiを認識できたので、flutterのコードを実行した時にどのような処理がされるか確認するために<strong>エミュレータを作成</strong>します。</p>



<p class="wp-block-paragraph">エミュレータは、英語のemulateから分かる通り「まねる、模倣する」という意味になります。<br>要するに、<strong>擬似的に環境を構築するソフトウェアやハードウェア</strong>のことを指します。</p>



<p class="wp-block-paragraph">エミュレータを使うことで、<strong>Windows上でAndroidのアプリを動作させる</strong>ことができます。<br>アプリケーションは本来、PC・AndroidはOSに依存し、開発されたソフトウェアを異なる環境下で動作させることはできません。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-graduation-cap"><span class="label-box-label-text block-box-label-text box-label-text">エミュレータは違法？</span></div><div class="label-box-content block-box-content box-content">
<div class="wp-block-cocoon-blocks-icon-box common-icon-box block-box alert-box">
<p class="wp-block-paragraph">詳細は、法律の専門家による言及を確認してください。</p>
</div>



<p class="wp-block-paragraph">「<strong>エミュレータは違法</strong>」ーこの言葉を耳にしたことがある方もいるでしょう。</p>



<p class="wp-block-paragraph">結論を言うと、<strong>エミュレータは合法</strong>。<br>ただし、<strong>使い方の注意は必要</strong>です。</p>



<p class="wp-block-paragraph">エミュレータの用途として、本記事のようなアプリ開発の他に<strong>ゲームのプレイ</strong>があります。</p>



<p class="wp-block-paragraph">ゲームを自分で購入して遊ぶことは良いですが、ネット上にアップロードされた<strong>違法なものをダウンロード</strong>したり、他者から<strong>データを譲渡</strong>したりすることは法に触れます。<br>さらに、<strong>自分でROMを配布・売却</strong>する。<strong>コピープロテクトを解除</strong>する行為も罪に問われます。</p>
</div></div>



<p class="wp-block-paragraph">Flutterでは、エミュレータを使うことで<strong>コードを書き替えてすぐに変更内容が反映</strong>されます。<br>実機を使うよりも開発に便利です。</p>



<h3 class="wp-block-heading">エミュレータの作成</h3>



<p class="wp-block-paragraph"><strong>エミュレータの作成は、Android Studio</strong>で行います。<br>公式で用意するので、<strong>エミュレータ自体に違法性がない</strong>ことが言えます。</p>



<p class="wp-block-paragraph">Android Studioを起動して、<strong>More ActionsのVirtual Device Mangagerを選択</strong>してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="950" src="https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000.webp" alt="" class="wp-image-4485" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000-300x148.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000-1024x507.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000-768x380.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/virtual-devidemanager_0000-1536x760.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">Create virutal deviceを選択し、<strong>任意のデバイス</strong>を選択してNextに進んでください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1693" height="885" src="https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000.webp" alt="" class="wp-image-4486" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000.webp 1693w, https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000-300x157.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000-1024x535.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000-768x401.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/creat-device_0000-1536x803.webp 1536w" sizes="(max-width: 1693px) 100vw, 1693px" /></figure>



<p class="wp-block-paragraph">system imageですが、<strong>現在選択されているもので良い</strong>です。<br>本記事では、Rで進めていきます。<br>インストールされていない場合は、ダウンロードマークを押して、表示させてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1693" height="890" src="https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000.webp" alt="" class="wp-image-4487" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000.webp 1693w, https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/R-install_0000-1536x807.webp 1536w" sizes="(max-width: 1693px) 100vw, 1693px" /></figure>



<p class="wp-block-paragraph">名前を付けて（AVD Name）、Finishで完了です。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1687" height="888" src="https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000.webp" alt="" class="wp-image-4488" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000.webp 1687w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000-1024x539.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000-768x404.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/11/complete-AVD_0000-1536x809.webp 1536w" sizes="(max-width: 1687px) 100vw, 1687px" /></figure>



<h4 class="wp-block-heading">UdemyでFlutterを学習</h4>



<p class="wp-block-paragraph"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fnzigen-flutter_beginner%2F">Flutterアプリ開発講座(初級編)<br></a>Flutterアプリ開発の初歩から学習できて、<br><strong>Flutter未経験・プログラミング初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-widget%2F">【Flutter】UI開発でよく使うWidget50選</a><br>Flutterで頻出Widgetを紹介している。<br><strong>始めたばかりで機能を覚えたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-bootcamp-with-dart%2F">The Complete Flutter Development Bootcamp with Dart</a><br>GoogleとFlutterチームが共同作成した講座。<br><strong>本格的なFlutterエンジニアになりたい人</strong>におすすめ</li>
</ul>
</div>



<h2 class="wp-block-heading">実演（エミュレータアプリを実行）</h2>



<p class="wp-block-paragraph">エミュレータも作成できたので、いよいよ実行します。</p>



<p class="wp-block-paragraph">VScodeを開いて、<strong>青帯の「No Device」から作成したエミュレータを選択</strong>してください。<br>あるいは、実行とデバック（or F5）で実行しようとすると、デバイス決定を促されます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="807" height="82" src="https://alicia-ing.com/wp-content/uploads/2023/11/nodevice.webp" alt="" class="wp-image-4489" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/nodevice.webp 807w, https://alicia-ing.com/wp-content/uploads/2023/11/nodevice-300x30.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/11/nodevice-768x78.webp 768w" sizes="(max-width: 807px) 100vw, 807px" /></figure>



<p class="wp-block-paragraph">スクリプトとエミュレータの接続が正常に行われると、画面に表示されます。<br>冒頭で紹介したように、画面上でしっかりと動作することも確認できます。</p>



<p class="wp-block-paragraph">本記事の手順でAndroid Studioをインストールして、<br>エミュレータを操作しようとしたけれど、エラー生じる。</p>



<p class="wp-block-paragraph">そのような場合は、<strong>ファイルの名前が不適切な可能性</strong>があります。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>ビルドエラーの対策を解説しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/build-faild-with-an-exception/" title="【Flutter】Androidアプリでのビルドエラーの対処法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】Androidアプリでのビルドエラーの対処法</div><div class="blogcard-snippet internal-blogcard-snippet">AndroidエミュレータでBuild faild with an exceptionでビルドできなかった場合は、settings.jsonからパスを全角から半角に変更することで解決できます。同時にパッケージが破損することがあります。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">Androidアプリを作るには、Android Studioをインストールして、Amdroid SDKを設定する必要があります。</p>



<p class="wp-block-paragraph">また、Android toolchaiを認識するために、Command-line ToolsのインストールとAndroid licenseの取得が必要です。</p>



<p class="wp-block-paragraph">エミュレータを作成すると、無事にVScodeでアンドロイドアプリを動作させることができます。<br>エミュレータの違法という言葉を耳にするかもしれませんが、エミュレータ自体は合法です。<br>エミュレータを使ってROMを違法にダウンロードしたり、譲渡したりする行為が犯罪になります。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://alicia-ing.com/programming/flutter/android-emulator/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【Flutter】VSCodeでWindowsの開発を環境構築</title>
		<link>https://alicia-ing.com/programming/flutter/vscode-setting/</link>
		
		<dc:creator><![CDATA[アリッシア]]></dc:creator>
		<pubDate>Tue, 17 Oct 2023 13:56:47 +0000</pubDate>
				<category><![CDATA[Flutter]]></category>
		<guid isPermaLink="false">https://alicia-ing.com/?p=3835</guid>

					<description><![CDATA[現在は、PCを持っていないけれど、スマホやタブレットを持っている人が多いです。 スマホが登場して早何十年と経過して、大学や大学院で学んだ人や業務で開発をする人ではなくとも、アプリ開発はだれでも簡単に作成することができるよ [&#8230;]]]></description>
										<content:encoded><![CDATA[
<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-flag"><span class="label-box-label-text block-box-label-text box-label-text">本記事を読むと以下の実行ができます</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">FlutterをVScodeからデバックをする。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1008" src="https://alicia-ing.com/wp-content/uploads/2023/10/Complete-chrome.gif" alt="chromeでのFlutter実行" class="wp-image-7309"/></figure>
</div></div>



<p class="wp-block-paragraph">現在は、PCを持っていないけれど、スマホやタブレットを持っている人が多いです。</p>



<p class="wp-block-paragraph">スマホが登場して早何十年と経過して、大学や大学院で学んだ人や業務で開発をする人ではなくとも、<strong>アプリ開発はだれでも簡単に作成することができる</strong>ようになりその敷居は低くなりました。</p>



<p class="wp-block-paragraph"><strong>一般的にアプリはOSによって使うプログラミング言語が異なります。</strong><br>したがって、iOS版を作りたいならiOS向けの言語、<br>Android版を作りたいならAndroid向けの言語を使わなければなりません。</p>



<p class="wp-block-paragraph">しかし、FlutterはiOSとAndroidどちらにも対応した言語です。<br>Flutterならば<strong>OSのことを一切考えず、</strong><br>どちらにも最適なものとして開発を進めることができます。</p>



<p class="wp-block-paragraph">さらに、<strong>FlutterはVisual Stadio Codeのプラグインがある</strong>ので、<br>アプリ開発をしたことがない初心者でも作成することができます。</p>



<p class="wp-block-paragraph">本記事では使用しているPCにFlutterをインストールしてVSCodeで使えるようにします。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-check"><span class="label-box-label-text block-box-label-text box-label-text">本記事は次の人におすすめ</span></div><div class="label-box-content block-box-content box-content">
<ul class="wp-block-list">
<li>アプリ開発をしたい。</li>



<li>Flutterをインストールしたい。</li>



<li>VScodeでFlutterを開発したい。</li>
</ul>
</div></div>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>



<h2 class="wp-block-heading">スマホアプリのプログラミング言語</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/10/application.webp" alt="アプリ開発について" class="wp-image-3912" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/application.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/10/application-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/application-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/application-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/application-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph"><strong>スマホアプリを開発する言語は非常に多くあります。</strong></p>



<p class="wp-block-paragraph">例として８つの言語を列挙し、iOS、Androidで使えるか、<br>難易度は様々な意見を参考にして自分の目安でつけています。</p>



<figure class="wp-block-table aligncenter"><div class="scrollable-table"><table><tbody><tr><td class="has-text-align-center" data-align="center">言語</td><td class="has-text-align-center" data-align="center">iOS</td><td class="has-text-align-center" data-align="center">Android</td><td class="has-text-align-center" data-align="center">使用言語</td><td class="has-text-align-center" data-align="center">目安難易度（最大５）</td></tr><tr><td class="has-text-align-center" data-align="center">Swift</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">×</td><td class="has-text-align-center" data-align="center">Swift</td><td class="has-text-align-center" data-align="center">3</td></tr><tr><td class="has-text-align-center" data-align="center">Java</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">Java</td><td class="has-text-align-center" data-align="center">4</td></tr><tr><td class="has-text-align-center" data-align="center">Kotlin</td><td class="has-text-align-center" data-align="center">△</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">簡単なJava</td><td class="has-text-align-center" data-align="center">3</td></tr><tr><td class="has-text-align-center" data-align="center">Xamarin</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">C#</td><td class="has-text-align-center" data-align="center">3.5~4</td></tr><tr><td class="has-text-align-center" data-align="center">ReactNative</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">JavaScript</td><td class="has-text-align-center" data-align="center">２</td></tr><tr><td class="has-text-align-center" data-align="center"><strong>Flutter</strong></td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center"><strong>Dart</strong></td><td class="has-text-align-center" data-align="center"><strong>2.5</strong></td></tr><tr><td class="has-text-align-center" data-align="center">Unity</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">C#</td><td class="has-text-align-center" data-align="center">3.5</td></tr><tr><td class="has-text-align-center" data-align="center">Unereal Engine</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">〇</td><td class="has-text-align-center" data-align="center">C++</td><td class="has-text-align-center" data-align="center">5</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">一般的にアプリ開発はiOS、Androidどちらでも使えるマルチプラットフォームではなく、<br><strong>Swift</strong>や<strong>Kotlin</strong>のような<strong>ネイティブ言語</strong>の方がよいと言われています。</p>



<p class="wp-block-paragraph">例えば、Xamarinで開発する際にC#の他にもAndroidとiOSのSDK、.NET Framework、Xamarin.Forms（iOS）（Android）の知識が必要になります。</p>



<p class="wp-block-paragraph">実際にXamarinを開発をしたことがあり、個人で使う分には良かったです。<br>しかし、App StoreやGoogle Play Storeに出品できるものが作れるかというと、<br><strong>相当な経験と技術が必要</strong>になると感じました。</p>



<p class="wp-block-paragraph">さらに、<strong>案件ではSwiftとKotlinがほとんど</strong>です。<br>仕事にしやすいことから、iOSならばSwift、AndroidならばKotlinを学ぶべきでしょう。</p>



<div class="wp-block-cocoon-blocks-label-box-1 label-box block-box cocoon-block-label-box"><div class="label-box-label block-box-label box-label fab-graduation-cap"><span class="label-box-label-text block-box-label-text box-label-text">KotlinでiOSアプリ作成</span></div><div class="label-box-content block-box-content box-content">
<p class="wp-block-paragraph">表では、△にしていたところですが、<strong>2023年5月に、KotlinでiOSアプリ作成できるように</strong>なる「Compose Multiplatform for iOS」アルファ版をリリースを発表しました。</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">JetBrains released Compose Multiplatform for iOS as Alpha, meaning it’s ready to be used in experiments and toy projects. Try it out, and help shape the future of shared mobile user interfaces with Kotlin!</p>
<cite><a target="_self" href="https://blog.jetbrains.com/kotlin/2023/05/compose-multiplatform-for-ios-is-in-alpha/" title="Compose Multiplatform for iOS Is in Alpha">Compose Multiplatform for iOS Is in Alpha</a></cite></blockquote>
</div></div>



<h2 class="wp-block-heading">Flutter</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter.webp" alt="Flutterについて" class="wp-image-3913" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph">前述の通りだと<strong>Flutterも学ぶべきではないと危機感</strong>があるかもしれません。<br>Flutterは最近注目を集めている言語で、<strong>今後需要が高まる可能性</strong>があります。</p>



<p class="wp-block-paragraph">Flutterは、2018年に<strong>Googleがリリースしたモバイルフレームワーク</strong>で比較的新しく、<br>クロスプラットフォームで<strong>iOSとAndroidのアプリを開発</strong>できます。</p>



<p class="wp-block-paragraph"><strong>歴史が浅い</strong>ので、Flutterの情報が上記の言語よりも少ないです。<br>また、<strong>Dart</strong>という<strong>非常にマニアックな言語</strong>を使用します。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-green-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#8bc34a"><div class="tab-caption-box-label block-box-label box-label fab-graduation-cap"><span class="tab-caption-box-label-text block-box-label-text box-label-text">Dartの歴史</span></div><div class="tab-caption-box-content block-box-content box-content">
<p class="wp-block-paragraph">Dartは、2011年にGoogle社が<strong>Javascriptの問題を改善するために開発</strong>されましたが、<br>2012年にJavaScriptの拡張としてMicrosoft社が「TypeScript」を開発しました。</p>



<p class="wp-block-paragraph">Google社もTypeScriptを採用したことで、<br><strong>Dartは学ぶ価値のないプログラミング言語</strong>という扱いでした。</p>
</div></div>



<p class="wp-block-paragraph">Dartは、<strong>JavaScriptの改善</strong>した言語で、<br>さらに<strong>JavaとC#の影響を受けた</strong>言語で、文法が酷似しています。</p>



<p class="wp-block-paragraph">Unityでのゲーム開発（C#）や動的なウェブデザイン(JavaScript)をしている人は、<br>Dartの学習コストは低いことでしょう。</p>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-text-color has-background has-border-color has-black-color has-ex-a-background-color has-blue-border-color cocoon-block-tab-caption-box"><div class="tab-caption-box-label block-box-label box-label fab-star"><span class="tab-caption-box-label-text block-box-label-text box-label-text">1から10までの偶数和</span></div><div class="tab-caption-box-content block-box-content box-content">
<ul class="wp-block-list">
<li><strong>JavaScript</strong></li>
</ul>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-js" data-lang="JavaScript"><code>let sum = 0;
for (let i = 1; i &lt;= 10; i++) {
  if (i % 2 === 0) {
    sum += i;
  }
}
console.log(&quot;1から10までの偶数和:&quot; + sum);</code></pre></div>



<ul class="wp-block-list">
<li><strong>Unity</strong></li>
</ul>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-csharp" data-lang="C#"><code>using UnityEngine;

public class EvenSum : MonoBehaviour
{
    void Start()
    {
        int sum = 0;
        for (int i = 1; i &lt;= 10; i++)
        {
            if (i % 2 == 0)
            {
                sum += i;
            }
        }
        Debug.Log(&quot;1から10までの偶数和: &quot; + sum);
    }
}</code></pre></div>



<ul class="wp-block-list">
<li><strong>Dart</strong></li>
</ul>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-dart" data-lang="Dart"><code>void main() {
  int sum = 0;
  for (int i = 1; i &lt;= 10; i++) {
    if (i % 2 == 0) {
      sum += i;
    }
  }
  print(&quot;1から10までの偶数和: $sum&quot;);
}
</code></pre></div>
</div></div>



<p class="wp-block-paragraph">公式ページの「<a target="_self" title="Build apps for any screen" href="https://flutter.dev/">Build apps for any screen</a>」を参照すると、<br><strong>BMWのアプリ</strong>がFlutterで作成されていると紹介されています。</p>



<p class="wp-block-paragraph">また、リクルートが運営する日本の宿・ホテルの予約サイト「<strong>じゃらん</strong>」も<br>Flutterで作成されています。</p>



<p class="wp-block-paragraph">関連：「<a target="_self" title="【Flutter】iOSプロジェクトへのAdd-to-appにおける3つのOptionの比較" href="https://blog.recruit.co.jp/rls/2020-04-17-add-to-app/">【Flutter】iOSプロジェクトへのAdd-to-appにおける3つのOptionの比較</a>」</p>



<p class="wp-block-paragraph">その他にも<strong>トヨタ</strong>や<strong>Google系のアプリ</strong>で採用されています。</p>



<h2 class="wp-block-heading">VScodeでFlutterを使用する</h2>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1980" height="1020" src="https://alicia-ing.com/wp-content/uploads/2023/10/VScode.webp" alt="VScodeについて" class="wp-image-3915" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/VScode.webp 1980w, https://alicia-ing.com/wp-content/uploads/2023/10/VScode-300x155.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/VScode-1024x528.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/VScode-768x396.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/VScode-1536x791.webp 1536w" sizes="(max-width: 1980px) 100vw, 1980px" /></figure>



<p class="wp-block-paragraph"><strong>Flutterを開発する環境は、VScodeがおすすめ</strong>です。</p>



<p class="wp-block-paragraph">VScodeを開いて、<strong>Ctrl + Shift +X</strong>。<br>あるいは<strong>サイドの拡張機能を選択</strong>してください。</p>



<p class="wp-block-paragraph">検索バーに「<strong>Flutter</strong>」 と入力し、インストールします。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="389" height="420" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-vscode.webp" alt="検索バーでFlutterと検索" class="wp-image-3916" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-vscode.webp 389w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-vscode-278x300.webp 278w" sizes="(max-width: 389px) 100vw, 389px" /></figure>



<p class="wp-block-paragraph">今は、プラグインをインストールしただけで、<br><strong>Flutterのパッケージ</strong>をインストールしたわけではありません。</p>



<p class="wp-block-paragraph">Flutterを稼働させるために、<br>上部の検索バーに「<strong>&gt;Flutter:New Project</strong>」と入力して実行すると、次のような警告文が出ます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="332" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project.webp" alt="Flutter:New Projectと検索" class="wp-image-3917" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project-300x52.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project-1024x177.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project-768x133.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-New-Project-1536x266.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">要するに、プログラムやAPI(アプリケーションプログラミングインタフェース)、サンプルコードなどをパッケージにした<strong>SDK（ソフトウェア開発キット）をダウンロードするように指示</strong>されます。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="559" height="145" src="https://alicia-ing.com/wp-content/uploads/2023/10/Download-SDK.webp" alt="エラー文" class="wp-image-3918" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Download-SDK.webp 559w, https://alicia-ing.com/wp-content/uploads/2023/10/Download-SDK-300x78.webp 300w" sizes="(max-width: 559px) 100vw, 559px" /></figure>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Cound not find a Flutter SDK. Please downloaded, or, if already downloaded, click &#8216;Locate SDK&#8217;.</p>
<cite>Visual Studio Code</cite></blockquote>



<p class="wp-block-paragraph">したがって、Flutter SDKをダウンロードします。</p>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-border-color has-point-color has-blue-border-color has-blue-point-color cocoon-block-timeline"><div class="timeline-title">Flutterが使えるようになるまで</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">Flutter SDKのインストール</div><div class="timeline-item-snippet">
<p class="wp-block-paragraph"></p>
</div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">Pathを通す</div><div class="timeline-item-snippet">
<p class="wp-block-paragraph"></p>
</div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step3</div><div class="timeline-item-content cf"><div class="timeline-item-title">開発環境を設定</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>



<h3 class="wp-block-heading">Flutter SDKをインストール</h3>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-border-color has-point-color has-blue-border-color has-blue-point-color cocoon-block-timeline"><div class="timeline-title">Flutter SDKインストール</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">Flutter SDKのインストールページに移動</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">Get the Flutter SDKでzipファイルをダウンロード</div><div class="timeline-item-snippet">
<p class="wp-block-paragraph"></p>
</div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step3</div><div class="timeline-item-content cf"><div class="timeline-item-title">解答したファイルを所定のディレクトリに配置</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>



<p class="wp-block-paragraph">警告文の青枠&#8221;Download SDK&#8221;を選択してください。（<a target="_self" href="https://docs.flutter.dev/get-started/install" title="Flutter SDKインストールページ">Flutter SDKインストールページ</a>）</p>



<p class="wp-block-paragraph">Windows、MacOS、Linux、ChromeOSの内、<br><strong>自分が使用しているPCのOSに該当するものを選択</strong>してください。</p>



<p class="wp-block-paragraph">※投稿者が使うPCのOSにより、Windowsで進行していきます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1080" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install.webp" alt="パッケージのインストール" class="wp-image-3919" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-1024x576.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-1536x864.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-install-320x180.webp 320w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">下にスクロールを進めて、画像に示す「Get the Flutter SDK」の<strong>zipファイル</strong>「flutter_windows_3.13.7-stable.zip」をインストールしてください。</p>



<p class="wp-block-paragraph">zipファイルのバージョンは変わっている場合がありますが、最新版をインストールしてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1080" src="https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK.webp" alt="windowsで取得" class="wp-image-3920" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-300x169.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-1024x576.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-768x432.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-1536x864.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/10/Get-the-Flutter-SDK-320x180.webp 320w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">解凍後、ダウンロードファイルは、<strong>分かりやすいディレクトリに配置</strong>してください。<br><strong>Cドライブ直下</strong>にすることで、間違いが無くなるのでおすすめです。</p>



<p class="wp-block-paragraph">全角文字（ひらがな、カタカナなど）が含むフォルダー内だと、<br><strong>正常にPathが認識しないことがある</strong>ので避けるべきです。</p>



<p class="wp-block-paragraph">プログラミングで全角を使うと、<strong>文字化け</strong>したり<strong>ビルドエラー</strong>になることもあるので、<br>全て半角するようにしてください。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>ビルドエラーの対処法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/build-faild-with-an-exception/" title="【Flutter】Androidアプリでのビルドエラーの対処法" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/11/build-faild-with-an-exception-1-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】Androidアプリでのビルドエラーの対処法</div><div class="blogcard-snippet internal-blogcard-snippet">AndroidエミュレータでBuild faild with an exceptionでビルドできなかった場合は、settings.jsonからパスを全角から半角に変更することで解決できます。同時にパッケージが破損することがあります。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<h3 class="wp-block-heading">Pathを通す</h3>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-border-color has-point-color has-blue-border-color has-blue-point-color cocoon-block-timeline"><div class="timeline-title">Pathを通過</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">設定>システム>バージョン情報>システムの詳細設定を開く</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">ユーザーの環境変数のPathにbinフォルダーを追加</div><div class="timeline-item-snippet">
<p class="wp-block-paragraph"></p>
</div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step3</div><div class="timeline-item-content cf"><div class="timeline-item-title">コマンドプロンプトでインストールできたか確認</div><div class="timeline-item-snippet"></div></div></li>
</ul></div>



<p class="wp-block-paragraph"><strong>Flutterのコマンドが使える様にbinフォルダのPathを通します。</strong></p>



<p class="wp-block-paragraph">設定からシステム、パージョン情報に進んでください。<br>デバイスの仕様で、「<strong>システムの詳細設定</strong>」を開いてください。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="537" src="https://alicia-ing.com/wp-content/uploads/2023/10/system-setting-1024x537.webp" alt="システムの詳細設定" class="wp-image-3921" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/system-setting-1024x537.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/system-setting-300x157.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/system-setting-768x402.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/system-setting-1536x805.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/10/system-setting.webp 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">システムのプロパティ内の詳細設定を選択した後、「<strong>環境変数</strong>」を選択してください。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="662" height="859" src="https://alicia-ing.com/wp-content/uploads/2023/10/environment-variable.webp" alt="システムのプロパティの環境設定" class="wp-image-3922" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/environment-variable.webp 662w, https://alicia-ing.com/wp-content/uploads/2023/10/environment-variable-231x300.webp 231w" sizes="(max-width: 662px) 100vw, 662px" /></figure>



<p class="wp-block-paragraph">Pathは、２つの環境変数ともにあります。<br><strong>ユーザー（上部）の方の環境変数を選択</strong>し、「編集」を開いてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="870" height="960" src="https://alicia-ing.com/wp-content/uploads/2023/10/path-1.webp" alt="path編集" class="wp-image-3925" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/path-1.webp 870w, https://alicia-ing.com/wp-content/uploads/2023/10/path-1-272x300.webp 272w, https://alicia-ing.com/wp-content/uploads/2023/10/path-1-768x847.webp 768w" sizes="(max-width: 870px) 100vw, 870px" /></figure>



<p class="wp-block-paragraph">新規で、<strong>先ほど解凍したファイルのディレクトリーパスを追加</strong>してください。<br>例えば、Cドライブ直下にした場合は、以下のようになります。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>C:\flutter\bin</code></pre></div>



<p class="wp-block-paragraph">OKを選択して、追加できたか確認します。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="743" height="811" src="https://alicia-ing.com/wp-content/uploads/2023/10/bin.webp" alt="追加を確認" class="wp-image-3926" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/bin.webp 743w, https://alicia-ing.com/wp-content/uploads/2023/10/bin-275x300.webp 275w" sizes="(max-width: 743px) 100vw, 743px" /></figure>



<p class="wp-block-paragraph"><strong>コマンドプロンプトを開いて、以下を入力</strong>してください。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>flutter --version</code></pre></div>



<p class="wp-block-paragraph">画像のように、<strong>Flutterの詳細情報が表示されると正常にインストール</strong>できました。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1006" src="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version.webp" alt="コマンドプロンプトで確認" class="wp-image-3927" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version-300x157.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version-1024x537.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version-768x402.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-version-1536x805.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<h3 class="wp-block-heading">開発環境を設定</h3>



<div class="wp-block-cocoon-blocks-timeline timeline-box cf block-box has-border-color has-point-color has-blue-border-color has-blue-point-color cocoon-block-timeline"><div class="timeline-title">開発環境を設定</div><ul class="timeline">
<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step1</div><div class="timeline-item-content cf"><div class="timeline-item-title">コマンドプロンプトで開発環境を調べる</div><div class="timeline-item-snippet"></div></div></li>



<li class="wp-block-cocoon-blocks-timeline-item timeline-item cf"><div class="timeline-item-label">Step2</div><div class="timeline-item-content cf"><div class="timeline-item-title">chromeやXcode、Android Studioをインストールする</div><div class="timeline-item-snippet">
<p class="wp-block-paragraph"></p>
</div></div></li>
</ul></div>



<p class="wp-block-paragraph"><strong>インストールしたものの、アプリとして使用できることとは別の話</strong>です。</p>



<p class="wp-block-paragraph">ここから、開発環境を構築していきます。</p>



<p class="wp-block-paragraph">初めに、<strong>コマンドプロンプトに以下を入力</strong>してください。</p>



<div class="hcb_wrap"><pre class="prism undefined-numbers lang-plain"><code>flutter doctor</code></pre></div>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="924" src="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor.webp" alt="Androidでのerror" class="wp-image-3928" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor-300x144.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor-1024x493.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor-768x370.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-doctor-1536x739.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">表示されるものは次の３つです。</p>



<p class="wp-block-paragraph">画像の場合、Androidの開発が整ってなくて、<br><strong>Visual Studioも不十分</strong>だということです。</p>



<figure class="wp-block-table aligncenter"><div class="scrollable-table"><table><tbody><tr><td class="has-text-align-center" data-align="center">[√]</td><td class="has-text-align-center" data-align="center">OK</td></tr><tr><td class="has-text-align-center" data-align="center">[×]</td><td class="has-text-align-center" data-align="center">NG</td></tr><tr><td class="has-text-align-center" data-align="center">[!]</td><td class="has-text-align-center" data-align="center">NG</td></tr></tbody></table></div></figure>



<p class="wp-block-paragraph">Androidでエミュレートや実機でデバックしたい場合は、<br><strong>Android Studioのインストールが必要</strong>です。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>Androidの端末で動かす方法を紹介しています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/programming/flutter/android-emulator/" title="【Flutter】VScodeでAndroidエミュレータ起動" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2023/11/android-emulator-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Flutter】VScodeでAndroidエミュレータ起動</div><div class="blogcard-snippet internal-blogcard-snippet">AndroidアプリはAndroid Studioのインストール、Amdroid SDKが必要で、Android toolchaiの認識も同時に必須です。エミュレータの違法と聞いたことがあるかもしれませんが、エミュレータ自体は合法です。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.08.11</div></div></div></div></a>
</div>



<div class="wp-block-cocoon-blocks-tab-caption-box-1 tab-caption-box block-box has-border-color has-light-green-border-color not-nested-style cocoon-block-tab-caption-box" style="--cocoon-custom-border-color:#8bc34a"><div class="tab-caption-box-label block-box-label box-label fab-apple"><span class="tab-caption-box-label-text block-box-label-text box-label-text">WindowsでiOS開発するには？</span></div><div class="tab-caption-box-content block-box-content box-content">
<p class="wp-block-paragraph">iOSの開発に必要なXcodeはWindowsで使えず、AppStoreに出品できないです。<br>要するに、<strong>WindowsでiPhoneやiPadのアプリは開発、配布・販売は不可能</strong>です。</p>



<p class="wp-block-paragraph">日本はスマホはiPhone、タブレットはiPad一強なので、<strong>アプリ開発はMacが必要</strong>になります。</p>



<div class="wp-block-cocoon-blocks-micro-text micro-text micro-copy micro-top"><span class="micro-text-content micro-content"><span class="micro-text-icon micro-icon fab-info-circle"></span>クリエイティブなことには、macが必要か書いています。</span></div>



<div class="wp-block-cocoon-blocks-blogcard blogcard-type bct-together">

<a target="_self" href="https://alicia-ing.com/life/compare-windows-mac/" title="【Mac離れ】クリエイターや開発者はMacに満足しないのか？" class="blogcard-wrap internal-blogcard-wrap a-wrap cf"><div class="blogcard internal-blogcard ib-left cf"><div class="blogcard-label internal-blogcard-label"><span class="fa"></span></div><figure class="blogcard-thumbnail internal-blogcard-thumbnail"><img loading="lazy" decoding="async" width="160" height="90" src="https://alicia-ing.com/wp-content/uploads/2022/11/compare-windows-mac-160x90.webp" class="blogcard-thumb-image internal-blogcard-thumb-image wp-post-image" alt="" srcset="https://alicia-ing.com/wp-content/uploads/2022/11/compare-windows-mac-160x90.webp 160w, https://alicia-ing.com/wp-content/uploads/2022/11/compare-windows-mac-120x68.webp 120w, https://alicia-ing.com/wp-content/uploads/2022/11/compare-windows-mac-320x180.webp 320w" sizes="(max-width: 160px) 100vw, 160px" /></figure><div class="blogcard-content internal-blogcard-content"><div class="blogcard-title internal-blogcard-title">【Mac離れ】クリエイターや開発者はMacに満足しないのか？</div><div class="blogcard-snippet internal-blogcard-snippet">クリエイターや開発者はMac離れがささやかれていますが、イラスト（クリスタ）、プログラミング、動画編集などWindows、Macユーザーは等しくいます。PCシェア率はWindowsが優勢ですが、iosアプリはmacでしか作れません。</div></div><div class="blogcard-footer internal-blogcard-footer cf"><div class="blogcard-site internal-blogcard-site"><div class="blogcard-favicon internal-blogcard-favicon"><img loading="lazy" decoding="async" src="https://www.google.com/s2/favicons?domain=https://alicia-ing.com" alt="" class="blogcard-favicon-image internal-blogcard-favicon-image" width="16" height="16" /></div><div class="blogcard-domain internal-blogcard-domain">alicia-ing.com</div></div><div class="blogcard-date internal-blogcard-date"><div class="blogcard-post-date internal-blogcard-post-date">2025.04.09</div></div></div></div></a>
</div>
</div></div>



<h4 class="wp-block-heading">UdemyでFlutterを学習</h4>



<p class="wp-block-paragraph"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2F">Udemy</a>は、オンデマンド式の学習講座です。<br>趣味から実務まで使えるおすすめの講座を紹介します。</p>



<div class="wp-block-cocoon-blocks-tab-box-1 blank-box bb-tab bb-pickup block-box has-border-color has-yellow-border-color">
<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fnzigen-flutter_beginner%2F">Flutterアプリ開発講座(初級編)<br></a>Flutterアプリ開発の初歩から学習できて、<br><strong>Flutter未経験・プログラミング初心者</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-widget%2F">【Flutter】UI開発でよく使うWidget50選</a><br>Flutterで頻出Widgetを紹介している。<br><strong>始めたばかりで機能を覚えたい人</strong>におすすめ</li>
</ul>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<ul class="wp-block-list">
<li><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourse%2Fflutter-bootcamp-with-dart%2F">The Complete Flutter Development Bootcamp with Dart</a><br>GoogleとFlutterチームが共同作成した講座。<br><strong>本格的なFlutterエンジニアになりたい人</strong>におすすめ</li>
</ul>
</div>



<h2 class="wp-block-heading">実演</h2>



<p class="wp-block-paragraph">Flutterの開発環境を整えたので、初めに戻ります。</p>



<p class="wp-block-paragraph">VScodeで「<strong>Ctrl + Shift + P</strong>」とコマンド選択してから、<br>「<strong>&gt;Flutter:New Project</strong>」と入力してください。</p>



<p class="wp-block-paragraph">先ほどは警告文でしたが、<strong>テンプレートが選択できる</strong>ようになっています。</p>



<p class="wp-block-paragraph">アプリを作りたいので、「<strong>Application</strong>」を選択してプロジェクトを作成してください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="513" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application.webp" alt="アプリケーション" class="wp-image-3930" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application-300x80.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application-1024x274.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application-768x205.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-Application-1536x410.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<p class="wp-block-paragraph">作成したプロジェクトの配置場所を選択した後、ファイル名を決めてください。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1919" height="520" src="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1.webp" alt="projectを作る" class="wp-image-3929" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1.webp 1919w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1-300x81.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1-1024x277.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1-768x208.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Flutter-application-1-1536x416.webp 1536w" sizes="(max-width: 1919px) 100vw, 1919px" /></figure>



<p class="wp-block-paragraph">「main.dart」が既に構築されていて、<br><strong>デバックすると冒頭のようなUIボタンで数値が加算される</strong>ようになります。</p>



<p class="wp-block-paragraph">画像のインフォメンションにあるように、<strong>F5を押すとデバック</strong>ができます。</p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1920" height="1008" src="https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5.webp" alt="F5を押す" class="wp-image-3931" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5.webp 1920w, https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5-300x158.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5-1024x538.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5-768x403.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/Press-F5-1536x806.webp 1536w" sizes="(max-width: 1920px) 100vw, 1920px" /></figure>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p class="wp-block-paragraph">Your Flutter project is ready! Press F5 to start running</p>
<cite>Visual Studio Code</cite></blockquote>



<p class="wp-block-paragraph"><strong>F5を押してもデバックすることができない</strong>場合は、<br>どの環境でデバックをするか決めていないからです。</p>



<p class="wp-block-paragraph"><strong>ターミナルで「flutter run」</strong>と入力してください。</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="115" src="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run-1024x115.webp" alt="flutter runを実行" class="wp-image-3932" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run-1024x115.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run-300x34.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run-768x86.webp 768w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run-1536x172.webp 1536w, https://alicia-ing.com/wp-content/uploads/2023/10/flutter-run.webp 1538w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"><br>その後つなげるデバイス一覧が出てきてきます。<br><strong>いずれか１つのコマンドを選択</strong>してください。</p>



<p class="wp-block-paragraph">本記事では「2」を選択しています。</p>



<figure class="wp-block-table aligncenter"><div class="scrollable-table"><table><tbody><tr><td class="has-text-align-center" data-align="center">1</td><td class="has-text-align-center" data-align="center">Windows</td></tr><tr><td class="has-text-align-center" data-align="center"><strong>2</strong></td><td class="has-text-align-center" data-align="center"><strong>Chrome</strong></td></tr><tr><td class="has-text-align-center" data-align="center">3</td><td class="has-text-align-center" data-align="center">Edge</td></tr><tr><td class="has-text-align-center" data-align="center">q</td><td class="has-text-align-center" data-align="center">キャンセル</td></tr></tbody></table></div></figure>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="1532" height="247" src="https://alicia-ing.com/wp-content/uploads/2023/10/choose-one.webp" alt="chromeを立ち上げる" class="wp-image-3933" srcset="https://alicia-ing.com/wp-content/uploads/2023/10/choose-one.webp 1532w, https://alicia-ing.com/wp-content/uploads/2023/10/choose-one-300x48.webp 300w, https://alicia-ing.com/wp-content/uploads/2023/10/choose-one-1024x165.webp 1024w, https://alicia-ing.com/wp-content/uploads/2023/10/choose-one-768x124.webp 768w" sizes="(max-width: 1532px) 100vw, 1532px" /></figure>



<h2 class="wp-block-heading">まとめ</h2>



<p class="wp-block-paragraph">スマホアプリは需要が高く、だれでも簡単に作成することができるようになりました。</p>



<p class="wp-block-paragraph">アプリ開発においてiOSはSwift。<br>AndroidはKotlinが一般的で、案件の多さから２つの言語を学ぶべきとされています。</p>



<p class="wp-block-paragraph">しかし、Flutterを使えば、iPhone向けAndroid向けの両方のOSのアプリを同時に開発できます。</p>



<p class="wp-block-paragraph">さらに、FlutterはVisual Stadio Codeのプラグインがあるので、<br>アプリ開発をしたことがない初心者でも作成することができます。</p>



<p class="wp-block-paragraph">Flutter SDKをインストール、binフォルダをpathに通して、開発環境を設定します。</p>



<p class="wp-block-paragraph">chromeで動かすには、chromeのインストール。<br>Androidで動かすには、Android Studioのインストール。<br>iOSで動かすには、Xcodeのインストール。</p>



<p class="wp-block-paragraph">これらが必要になります。</p>



<div class="wp-block-cocoon-blocks-micro-balloon-2 aligncenter micro-balloon micro-top mc-circle micro-copy"><span class="micro-balloon-content micro-content"><strong>Udemyで学習する</strong></span></div>



<div class="wp-block-cocoon-blocks-button-1 aligncenter button-block"><a target="_self" href="https://click.linksynergy.com/deeplink?id=IyOtUnEMtpw&amp;mid=47984&amp;murl=https%3A%2F%2Fwww.udemy.com%2Fcourses%2Fdevelopment%2F" class="btn btn-m btn-shine has-background has-light-green-background-color">Udemy 公式サイト</a></div>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
