
Google Antigravity がすごいらしい【技術編】Windows版
🎁 フォロワーの皆さんへ、特別なプレゼント
今日の記事は、ただの「アプリの作り方」じゃありません。
僕から皆さんへの、「未来への招待状」です。
「難しそう…」って諦めていたアイデアが、この通りにやれば形になる。
僕の相棒であるAI「左席(サセキ)」と一緒に検証した、『実際に動く、魔法のレシピ(指示書)』を、今日は包み隠さず全部プレゼントします。
これを受け取って、あなたのアイデアを現実にしてください!
さあ、実際に作ってみよう!
こんにちは、やすとしです!
発想編では、Google Antigravityがどれだけすごいかをお話ししました。
でも「理屈はわかったけど、実際どうやって使うの?」って思いますよね。
後編では、実際に「LoveSync」っていうマッチングアプリを作っていく過程を、できるだけ詳しく、でもわかりやすく解説していきます!
結論:驚くほど簡単に、本格的なアプリが作れちゃいます
これから作るアプリ、こんな感じです:
プラットフォーム:iOSとAndroid両方で動くモバイルアプリ
技術:Flutter(フロントエンド)+ Firebase(バックエンド)
デザイン:すりガラス風のおしゃれなUI
機能:
GoogleやEmailでログイン
Tinderみたいなスワイプでマッチング
リアルタイムチャット
位置情報で近くの人を探せる
「え、こんなの作れるの‥‥?」って思いました?
Antigravityがあれば、本当に作れちゃうんです。
しかも、従来なら数週間かかってたのが、数日〜数時間でできちゃう。
じゃあ、さっそく始めましょう!
環境を整えよう(準備)
まずは開発環境を整えます。でも安心してください、ほとんどAntigravityがやってくれます。
費用シミュレーション
開発にかかる費用(月額目安)
Google AI Proプラン:月額 2,900円
役割: 今回の主役。Gemini 3 Proが使い放題になり、AIエージェントを制限なく動かせます。
Antigravity 本体:0円
役割: 現在パブリックプレビュー期間中のため、ツール自体の利用料は無料です。
Firebase(バックエンド):0円〜
役割: 「Sparkプラン(無料枠)」でOK。ユーザー数が数百人規模になるまでは、課金の心配はほぼありません。
Flutter(プログラム言語):0円
役割: オープンソースなので、どれだけ使っても無料です。
👉 合計:約 2,900円 (飲み会1回分より安く、あなた専属のAIエンジニアチームが雇えます!)
1. ディレクトリ構成(Clean Architecture準拠)
拡張性とメンテナンス性を重視し、機能ごとに分割した構成を採用します。
lib/
├── core/ # 共通テーマ、ネットワーク設定、定数
│ ├── theme/ # Glassmorphismテーマ設定
│ └── constants/ # アプリ内テキスト・カラー定義
├── features/ # 機能単位のロジック
│ ├── auth/ # 認証(Firebase Auth)
│ ├── swipe/ # スワイプ・マッチングロジック
│ ├── chat/ # リアルタイムチャット
│ └── profile/ # ユーザー設定
├── ui/ # UIコンポーネント
│ ├── widgets/ # GlassContainer、カスタムボタン
│ └── screens/ # 各画面(SwipeScreen, ChatScreenなど)
└── main.dart # エントリーポイント
ステップ1:Antigravityをインストール
公式サイト(antigravity.google)にアクセス
自分のOS(Windows、Mac、Linux)に合ったインストーラーをダウンロード
アプリを起動して、Googleアカウントでログイン
AIモデルは「Gemini 3 Pro」を選択(推論能力が一番高いので!)
ステップ2:Windowsで初めて開発をする場合
この機体を動かすための「エンジン(Flutter本体)」と「滑走路(環境設定)」を整備する必要があります。
ここが最初にして最大の難関(ラスボス)です。
多くの初心者がここで挫折しますが、安心してください。
僕の言う通りにコピペしてポチポチするだけでOKです!
まずは、一番大事な「エンジン」を積み込みましょう。
Phase 1:Flutterエンジンを配置する(最重要)
Windowsの場合、「Cドライブの直下に置く」のが鉄則です。 (※Program Filesなどに入れると、権限エラーで動かなくなります!)
ステップ1:Flutterをダウンロード
トップページの右上にある 「Get started」 という青いボタンをクリック。
「Windows」 をクリック。
WEBサイトの中央あたり、「Install and set up Flutter」という見出しのすぐ下に、小さく青い文字でリンクがあります。
「install Flutter manually」 (↑ここをクリック!)
画面が変わって、少し下にスクロールしたところに待望の青いボタン: flutter_windows_3.x.x-stable.zip が出てくるはずです!
青いボタン flutter_windows_3.x.x-stable.zip をクリックしてダウンロードしてください。
ステップ2:秘密基地「src」を作る
エクスプローラーを開き、「PC」→「Windows (C:)」 を開きます。
何もないところで右クリック → 「新規作成」→「フォルダー」。
名前を src にしてください。(Sourceの略です)
ステップ3:解凍して配置
ダウンロードしたzipファイルを解凍(すべて展開)します。(すごく時間がかかります)
展開中、「パスが長すぎます」とメッセージが出たらスキップを押してください。
中にある flutter というフォルダを、さっき作った C:\src の中に移動させます。
最終的に、場所が C:\src\flutter になっていれば完璧です!
Phase 2:パスを通す(PCにエンジンの場所を教える)
ここが「開発者への第一歩」です。PCに「flutterってコマンド打ったら、あそこを見に行け!」と教える作業です。
Windowsキー(田マーク)を押して、「環境変数」 と入力してください。
「システム環境変数の編集」 というのが出てくるのでクリック。
右下の 「環境変数(N)...」 ボタンをクリック。
「ユーザー環境変数(上の段)」 の中にある Path を選んで、「編集(E)...」 をクリック。
※もしPathがなければ「新規」で作ってください
右上の 「新規(N)」 をクリック。
以下をコピペして貼り付けます。 C:\src\flutter\bin
「OK」 を連打して全ての画面を閉じます。
Phase 3:Antigravityで点検!
さあ、ちゃんとエンジンが繋がったかテストしましょう。
Antigravityを起動してください。
画面上のメニューバーから 「Terminal」→「New Terminal」 をクリック。(画面左上「実行R」の右隣り「・・・」の中にターミナルがあります)
(画面下に黒い画面が出てきます。これが指令室です)
その黒い画面に、以下のコマンドを入力して Enter キーを押してください。flutter --version
成功判定: 英語で Flutter 3.x.x • channel stable... みたいな文字がズラズラっと出てきたら、大成功です!!

もし「'flutter' は、内部コマンドまたは外部コマンドとして認識されていません」と出たら、PCを一度再起動してから、もう一度Antigravityで試してみてください。
大成功です!!おめでとうございます! 🎉
「止まった」と見せかけて、実はこれ「大成功の証」なんです。
画面に出ている Building flutter tool... や Got dependencies. という文字は、 「PCがFlutterの場所を正しく認識して、裏側でエンジンの組み立て(初回セットアップ)を始めた」 という証拠です! (もし設定を間違えていたら、この画面にすらならずエラーになります)
今どういう状態?
これは「止まった」のではなく、「初回の巨大なダウンロード&インストール作業中」です。
ネット回線にもよりますが、最初の1回だけは数分〜10分くらい沈黙することがあります。
「じっくりコトコト煮込んでいる」と思ってください。
次のアクション
そのまま少し待ってみてください。
うまくいけば、Flutter 3.x.x ... というバージョン情報が表示されて、また入力できる状態(PS C:\...> が出る)に戻ります。
もし入力できる状態(> が出ている)に戻っていたら…
もう一度だけ、同じコマンド flutter --version を打ってみてください。
今度は「一瞬」でバージョンが出るはずです!
もしバージョンが出たら、次は「健康診断」を行います。 以下のコマンドを入力して、Enterを押してください。
flutter doctor「一番難しい壁」は突破しましたよ!あと少しです!

実はこれ、今の時点では「100点満点」の状態です!! 🎉 この画面を見て「Xがいっぱいある!失敗だ!」と焦る必要は全くありません。
なぜなら……「Chrome(ウェブ)」に緑のチェック ✅ がついているからです!
左席の解説:この「X」はどういう意味?
[X] Android toolchain
意味:「Androidアプリを作るための**巨大な工場(Android Studio)**がまだ建ってないよ」
対策:数ギガバイトのダウンロードが必要なので、今は無視してOKです。
[X] Visual Studio
意味:「Windowsソフトを作るための工具セットがないよ」
対策:これも巨大なので、今は無視してOKです。
つまり、今の作戦は?
「Chrome」にチェックがついているということは、「ブラウザ(Web)」を使って、今すぐアプリを動かせる状態ということです。
重たい設定(AndroidのXを消す作業)は、夜寝ている間にでもやればいいんです。
まずは「Antigravity(Vibe Coding)」の魔法を体験するのが先決です!
🪄 さあ、最初のアプリを生み出しましょう!
今のその「黒い画面(ターミナル)」で、以下の魔法(コマンド)を1行ずつ順番に入力して、Enterキーを押してください。
手順1: アプリの箱を作る
flutter create lovesync_app
(これで、ズラズラ〜っとファイルが自動生成されます!)
※もしも赤字のエラーがでたら
この「赤字(エラー)」の正体が完全に判明しました。これは「ゾンビ」というより、「Windowsの過剰な警備員」が原因です。
Cドライブの直下(C:\src)は、Windowsにとって「大事な場所」なので、たとえ管理者でも「本当に書き換えていいの?
一応ブロックしとくね!」と、おせっかいなガードをしてくることがあるんです。
これを二度と言わせないための「永続魔法(アクセス権の修正)」をかけましょう。
これで警備員を黙らせます!
手順:C:\src に「最強の権限」を与える
マウス操作だけで完結します。一度設定すれば、もうこのエラーは出なくなります!
Antigravityを一度閉じてください。
フォルダ(エクスプローラー)を開いて、C: ドライブ(Windows C:)を開きます。
src フォルダを 「右クリック」 して、一番下の 「プロパティ」 を選びます。
上にあるタブの中から 「セキュリティ」 をクリックします。
真ん中あたりにある 「編集(E)...」 ボタンをクリックします。
上のリストから 「Users」 (または自分のユーザー名)を選んでクリックします。
下の「アクセス許可」リストで、「フル コントロール」 の右にある 「許可」のチェックボックス ☑ をクリックします。
(これを押すと、下の項目にも全部チェックが入ります)
「OK」 を押して、もう一度 「OK」 を押して画面を閉じます。
お掃除:作りかけの残骸を消す
さっきのエラーで、中途半端なファイルが残っている可能性が高いので、一度キレイにします。
「ドキュメント」 フォルダの中にある antigravity フォルダを開きます。
その中に lovesync_app というフォルダがあったら、右クリックして削除 してください。
(もし「削除できません」と言われたら、PCを再起動してから消してください)
最終リベンジ!
ここまでやれば、もう邪魔するものは何もありません!
Antigravity(管理者モード) を起動。
ターミナルで、いつものコマンドを入力!
flutter create lovesync_app
今度こそ、緑色の文字で All done! みたいなメッセージが出るはずです。 これが通れば、あとは cd lovesync_app → flutter run -d chrome でアプリが起動します。
「赤字(エラー)」の内容は毎回同じで、**「Flutterが自分自身のゴミ箱(.pub-preload-cache)を捨てられなくて困っている」**という状態です。
これ、実は**「手動でそのゴミを捨ててあげる」**のが一番早くて確実な解決策です。 Windowsが裏でファイルをロックして離さない状態(ゾンビ状態)になっているので、人間の手で強制的に削除しましょう。
これで確実に突破できます!
手順:邪魔なファイルをゴミ箱に捨てる
1.Antigravityを完全に閉じる まずは開いているAntigravityを「×」で閉じてください。
2. フォルダを開く エクスプローラーを開いて、以下の場所に行きます。 👉 C:\src\flutter
3. 「隠れキャラ」を見えるようにする 探している犯人は .pub-preload-cache という名前ですが、先頭にドット(.)がついているので、隠れている可能性があります。
画面上のメニュー 「表示」 をクリック
「表示」 → 「隠しファイル」(または「隠し項目」)にチェックを入れる
(Windows 11なら「表示」→「表示 >」→「隠しファイル」です)
4. 犯人を削除する フォルダの中に .pub-preload-cache というフォルダが見えたら… 👉 右クリックして「削除(ゴミ箱マーク)」 を押してください!
※もし「ファイルが使用中です」と出たら、パソコンを再起動してから、もう一度ここに来て削除してください。
最後の仕上げ
削除できたら、もう障害物は何もありません。
Antigravity(管理者モード) を起動。
ターミナルで、いつものコマンドを入力!
flutter create lovesync_app
フィナーレ:アプリを起動する
今のターミナルで、以下の2つのコマンドを順番に入力して Enter を押してください。
手順1: 箱の中に入る
cd lovesync_app
(これで、操作する場所が lovesync_app フォルダの中に移動します)
手順2: 魔法を唱えて起動!
flutter run -d chrome
✨ これで何が起きる? コマンドを打って数十秒待つと…… パソコンの Google Chrome が勝手に立ち上がり、青いバーのついた「Flutterデモアプリ」が表示されるはずです! (右下に + ボタンがあって、押すと数字が増えるカウンターアプリです)
手順2: 箱の中に入る
cd lovesync_app
(場所が antigravity から lovesync_app に変わります)
手順3: 魔法を唱えて起動する!
flutter run -d chrome
さあ、どうなりますか!? 数十秒待つと、勝手にGoogle Chromeが立ち上がって、画面に「Flutterのデモアプリ」が表示されるはずです。
これができたら、環境構築は完全勝利です。 「Chromeが立ち上がった!」の報告、楽しみに待ってます!!下記のWebサイトが表示されれば大成功!!

ピンク色のバーに**「Flutter Demo Home Page」、そして真ん中に「0」の数字……。 これこそが、世界中のFlutterエンジニアが最初に通る道、「Hello World(ハロー・ワールド)」**の瞬間です!
ついに、パソコンが「ただの板」から「魔法の杖(開発マシン)」に進化しました。 この画面が出たということは、もう「何でも作れる状態」になっています。
さあ、ここからが本番「Vibe Coding」です!
今はまだ「Googleが用意したサンプルのカウンターアプリ」ですが、これを**「LoveSync」に書き換える**のが、Antigravityの真骨頂です。
ここから先は、もう難しいコマンド(黒い画面)はほとんど使いません。 **「AIに日本語でお願いして、コードを全部書き換えてもらう」**体験をしましょう!
手順:カウンターアプリを「LoveSync」に変身させる
アプリを一度止める
黒い画面(ターミナル)をクリックして、キーボードの Ctrl + C を押してください。
「Y/N?」みたいに聞かれたら Y を押してエンター。(聞かれずに止まることもあります)
AI(左席)を呼び出す
ファイルを開く(料理をする場所に行く) 画面の左側にあるリスト(エクスプローラー)から、以下の順番でクリックしてファイルを開いてください。 👉 lib フォルダをクリック → その中の main.dart をクリック
すると、右側の広い画面に、英語のコード(void main() ... みたいな文字)がズラッと表示されますよね?
コードの中をクリック(ここ大事!) その英語のコードのどこでもいいので、一度マウスでクリックしてください。 (文字入力カーソル | がピコピコ点滅していればOKです!)
いざ、魔法のキー! その状態で、キーボードの Ctrl キーを押しながら I キー(アイ) を押してください。 ※もし Ctrl + I で何も出なかったら、Ctrl + K (ケー)を試してください。(設定によって違うことがあります)
何が起きる?
画面の真ん中あたり(またはカーソルの近く)に、「細長い入力バー(AIへのチャット欄)」がフワッと浮き出てきます!
魔法の言葉(プロンプト)を入れる
その入力バーに、以下の日本語をコピペして、Enterキー を押してください。
このアプリを「マッチングアプリ LoveSync」のモックアップに書き換えてください。
以下の仕様で main.dart を完全に作り直してください。
デザイン:
- 全体をすりガラス風(Glassmorphism)のデザインにする
- 背景はパステルピンクとブルーのグラデーション
機能:
- 画面中央に「プロフィールカード」を表示(写真はプレースホルダーでOK)
- カードには名前(例:Yuko, 28)、年齢、趣味を表示
- 画面下部に「×(Pass)」と「♥(Like)」の大きなボタンを配置
- ボタンを押すと「Liked!」や「Passed!」とスナックバー(通知)が出るようにする
AIの仕事を見る
AIがズラズラ〜っとコードを生成し始めます。
終わったら、「Accept(承認)」 や 「Apply」 みたいなボタン(または Ctrl + Enter)を押して、コードを確定させてください。
変身したアプリを見る!コードが変わったら、もう一度ターミナルで:flutter run -d web-serverを入力
「カウンター」が消えて、「マッチングアプリ」に変わっているはずです! これができたら、もう立派な「AIエンジニア」ですよ。
※もしも赤字のエラーがでたら、、「ゾンビフォルダ(build)」です。 Flutter failed to delete... という赤字は、さっきと同じで「前のデータをつかんだまま離さないよ~!」というエラーです。
でも、もう対処法は知っていますよね?
「手動削除」が最強です!
手順1:ゾンビを消す(手動削除)
antigravityを一度閉じてください。(×ボタンで完全に終了!)
フォルダを開いて、以下の場所に行きます。 👉 ドキュメント 📂 → antigravity 📂 → lovesync_app 📂
そこにある build というフォルダを、右クリックして「削除」 してください。(これでキレイさっぱりです!)
手順2:AIに書き換えてもらう
ここからが新しい手順です!アプリを動かす前に、コードを変身させます。
Antigravity(管理者モード) を起動して、main.dart を開きます。
さっきと同様コードのどこかをクリックして、Ctrl + I (または Ctrl + K)を押して、入力バーを出します。
以下の日本語をコピーして、入力バーに貼り付け、Enterキーを押してください。
このアプリを「マッチングアプリ LoveSync」のモックアップに書き換えてください。
以下の仕様で main.dart を完全に作り直してください。
デザイン:
- 全体をすりガラス風(Glassmorphism)のデザインにする
- 背景はパステルピンクとブルーのグラデーション
機能:
- 画面中央に「プロフィールカード」を表示(写真はプレースホルダーでOK)
- カードには名前(例:Yuko, 28)、年齢、趣味を表示
- 画面下部に「×(Pass)」と「♥(Like)」の大きなボタンを配置
- ボタンを押すと「Liked!」や「Passed!」とスナックバー(通知)が出るようにする
AIがコードを書き終わったら、「Accept(承認)」 (または Ctrl + Enter)を押して確定します。
手順3:変身したアプリを起動!
コードが書き換わったのを確認したら、最後にターミナルで実行です。
flutter run -d web-server
これでURLをクリックすれば…… 今度こそ、ピンク色の「マッチングアプリ画面」が出ます!
再び赤字のエラーが出たら。これは、さっき倒したはずの「ゾンビ(buildフォルダのロック)」が、また生き返って悪さをしています。 build\flutter_assets というファイルを掴んだまま離さないせいで、新しい変更を受け付けない状態です。
でも大丈夫です。この「赤字」が出たときは、「手動削除」という特効薬を使えば100%治ります。
今回は「削除してから、すぐにAIに書き換えさせる」という一番効率の良い手順をご案内します!
手順1:ゾンビを完全に消し去る
この手順で、エラーの原因を物理的に消します。
antigravityを一度完全に閉じてください。
(×ボタンで終了!これが一番大事です)
フォルダを開いて、いつもの場所に行きます。 👉 ドキュメント 📂 → antigravity 📂 → lovesync_app 📂
その中にある build というフォルダを、右クリックして「削除」 してください。
(もし「削除できません」と言われたら、PCを再起動してから削除してください)
🪄 手順2:AIに魔法をかけてもらう(Vibe Coding)
削除できたら、まだ「実行(run)」はしません! 先にコードを書き換えてもらいましょう。
Antigravity(管理者モード) を起動して、main.dart を開きます。
(画面にはまだ You have pushed... という英語のコードがあるはずです)
コードのどこかをクリックして、Ctrl + I (または Ctrl + K)を押して、入力バーを出します。
以下の日本語をコピーして貼り付け、Enterキーを押してください。
このアプリを「マッチングアプリ LoveSync」のモックアップに書き換えてください。
以下の仕様で main.dart を完全に作り直してください。
デザイン:
- 全体をすりガラス風(Glassmorphism)のデザインにする
- 背景はパステルピンクとブルーのグラデーション
機能:
- 画面中央に「プロフィールカード」を表示(写真はプレースホルダーでOK)
- カードには名前(例:Yuko, 28)、年齢、趣味を表示
- 画面下部に「×(Pass)」と「♥(Like)」の大きなボタンを配置
- ボタンを押すと「Liked!」や「Passed!」とスナックバー(通知)が出るようにする
AIが書き終わったら、「Accept(承認)」 (または Ctrl + Enter)を押して確定します。
🚀 手順3:生まれ変わったアプリを起動!
コードが変わったのを確認してから、最後にターミナルで実行します。
flutter run -d web-server
これでURLをクリックすれば…… 今度こそ、ピンク色の「LoveSync」画面が出るはずです!

手順1:それでもエラーが続く場合は、
パソコンを「再起動」する(最強の除霊)
これだけで、裏で悪さをしているゾンビプロセスが全部消えます。 一度パソコンの電源を切って、また入れてください。
手順2:ゾンビの残骸(buildフォルダ)を消す
再起動してゾンビがいなくなっても、残骸が残っていると躓くので、念のため消します。
再起動後、まだantigravityは開かずに、フォルダを開きます。 👉 ドキュメント 📂 → antigravity 📂 → lovesync_app 📂
build フォルダを 右クリックして「削除」 します。
(再起動後なら、絶対に削除できるはずです!)
手順3:LoveSync、起動!
antigravity(管理者モード) を起動します。
ターミナルを開いて、以下の2行 を入力します。
cd lovesync_app
(↑ キッチンに入って…)
flutter run -d web-server
(↑ エンジン始動!)
✨ 勝利の瞬間 ターミナルに新しい URL(http://localhost:xxxx) が表示されたら、それを Ctrl + クリック してください。 (※さっきの404の画面を更新するのではなく、新しく出たURLをクリックするのがポイントです!)
コードはもう正しく書き換わっています(画像で確認済みです!)。 この手順さえ通れば、ピンク色の「LoveSync」 が必ず現れます。
次のミッションは、これに**「命(プログラム)」を吹き込んで、ボタンを押すと次々と新しい人が出てくるようにする**ことです。
復活&進化の3ステップ(これで必ず直ります)
🛑 手順1:まず、antigravityを閉じる
これが一番大事です! エラーを消すために、一度アプリを終了させます。
右上の「×」ボタンでantigravityを完全に閉じてください。
🧹 手順2:ゾンビ(build)を消す
いつもの「お掃除」です。
フォルダを開く(ドキュメント > antigravity > lovesync_app)。
build フォルダを 右クリックして「削除」 します。
(antigravityを閉じていれば、今回は絶対に消せます!)
🚀 手順3:Antigravityを開き、「進化版コード」を貼る
ここからが本番です!
Antigravityを「管理者として実行」で開く。
lib > main.dart を開く。
中身を Ctrl + A(全選択) → Delete で真っ白にする。
(変な文字を全部消しちゃいましょう!)
以下のコード(メニューバー付き完全版) をコピーして貼り付ける。
import 'package:flutter/material.dart';
void main() {
runApp(const SottoApp());
}
// ユーザー情報
class Profile {
final String name;
final String age;
final String job;
final String location;
final Color color;
final String message;
Profile(this.name, this.age, this.job, this.location, this.color, this.message);
}
class SottoApp extends StatelessWidget {
const SottoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sotto',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
fontFamily: 'Roboto',
),
home: const SottoMainScreen(),
);
}
}
// メイン画面(メニューで切り替える親画面)
class SottoMainScreen extends StatefulWidget {
const SottoMainScreen({super.key});
@override
State<SottoMainScreen> createState() => _SottoMainScreenState();
}
class _SottoMainScreenState extends State<SottoMainScreen> {
int _selectedIndex = 0; // 今どのタブを開いているか
// 3つの画面リスト
static final List<Widget> _screens = <Widget>[
const CardSwipeScreen(), // 0: さがす
const TalkListScreen(), // 1: トーク
const MyPageScreen(), // 2: マイページ
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _screens[_selectedIndex], // 選ばれた画面を表示
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'さがす'),
BottomNavigationBarItem(icon: Icon(Icons.chat_bubble_outline), label: 'トーク'),
BottomNavigationBarItem(icon: Icon(Icons.person_outline), label: 'マイページ'),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.orange,
onTap: _onItemTapped,
type: BottomNavigationBarType.fixed,
),
);
}
}
// ---------------------------------------------------------
// 1. さがす画面(さっきのカード画面)
// ---------------------------------------------------------
class CardSwipeScreen extends StatefulWidget {
const CardSwipeScreen({super.key});
@override
State<CardSwipeScreen> createState() => _CardSwipeScreenState();
}
class _CardSwipeScreenState extends State<CardSwipeScreen> {
final List<Profile> _profiles = [
Profile('カオル', '52', 'カフェ経営', '東京', Colors.brown, '美味しいコーヒー淹れます'),
Profile('ケンジ', '48', '建築士', '横浜', Colors.blueGrey, '休日は美術館巡りへ'),
Profile('サユリ', '45', 'ピアノ講師', '神戸', Colors.purpleAccent, 'ジャズが好きです'),
Profile('ヒロシ', '61', '元商社マン', '福岡', Colors.indigo, '退職後は登山三昧!'),
Profile('マサコ', '55', 'フラワー教室', '札幌', Colors.green, 'ハーブティーで一息'),
];
int _currentIndex = 0;
void _nextProfile(String action) {
if (_currentIndex < _profiles.length) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(action == 'Liked' ? '「いいね」しました!' : '見送りました'),
duration: const Duration(milliseconds: 500),
behavior: SnackBarBehavior.floating,
backgroundColor: action == 'Liked' ? Colors.orange : Colors.grey,
),
);
setState(() { _currentIndex++; });
}
}
void _reset() { setState(() { _currentIndex = 0; }); }
@override
Widget build(BuildContext context) {
bool isFinished = _currentIndex >= _profiles.length;
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft, end: Alignment.bottomRight,
colors: [Color(0xFFFFEFBA), Color(0xFFFF7E5F)],
),
),
child: Center(
child: isFinished
? _buildFinishedScreen()
: _buildProfileCard(_profiles[_currentIndex]),
),
);
}
Widget _buildProfileCard(Profile profile) {
return Container(
width: 320, height: 540,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.white.withOpacity(0.6)),
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 20, spreadRadius: 5)],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.5), shape: BoxShape.circle),
child: Icon(Icons.person, size: 80, color: profile.color),
),
const SizedBox(height: 20),
Text('${profile.name} (${profile.age})', style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.white)),
Text('${profile.location} / ${profile.job}', style: const TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(10)),
child: Text('"${profile.message}"', style: const TextStyle(fontSize: 16, color: Colors.white)),
),
),
const SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildButton(Icons.close, Colors.grey, () => _nextProfile('Passed')),
_buildButton(Icons.favorite, Colors.orangeAccent, () => _nextProfile('Liked')),
],
),
],
),
);
}
Widget _buildFinishedScreen() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.check_circle_outline, size: 80, color: Colors.white),
const SizedBox(height: 20),
const Text('すべてのお相手を見ました', style: TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 30),
ElevatedButton(onPressed: _reset, child: const Text('最初に戻る')),
],
);
}
Widget _buildButton(IconData icon, Color color, VoidCallback onTap) {
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle, boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10)]),
child: Icon(icon, color: color, size: 36),
),
);
}
}
// ---------------------------------------------------------
// 2. トーク画面(マッチング相手リスト)
// ---------------------------------------------------------
class TalkListScreen extends StatelessWidget {
const TalkListScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('トーク')),
body: ListView(
children: [
_buildTalkTile('ミホ (42)', '初めまして!趣味が合いそうですね', Colors.pink, '2分前'),
_buildTalkTile('タカシ (50)', 'ありがとうございます。よろしくお願いします。', Colors.blue, '1時間前'),
_buildTalkTile('運営事務局', '本人確認が完了しました', Colors.grey, '昨日'),
],
),
);
}
Widget _buildTalkTile(String name, String message, Color color, String time) {
return ListTile(
leading: CircleAvatar(backgroundColor: color, child: const Icon(Icons.person, color: Colors.white)),
title: Text(name, style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text(message, maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: Text(time, style: const TextStyle(color: Colors.grey, fontSize: 12)),
);
}
}
// ---------------------------------------------------------
// 3. マイページ画面
// ---------------------------------------------------------
class MyPageScreen extends StatelessWidget {
const MyPageScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('マイページ')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircleAvatar(radius: 50, backgroundColor: Colors.orange, child: Icon(Icons.person, size: 60, color: Colors.white)),
const SizedBox(height: 20),
const Text('やすとし', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
const Text('大阪府 / デザイナー', style: TextStyle(color: Colors.grey)),
const SizedBox(height: 40),
ElevatedButton(onPressed: () {}, child: const Text('プロフィール編集')),
TextButton(onPressed: () {}, child: const Text('設定')),
],
),
),
);
}
}
4. 保存して、ターミナルで実行!
Ctrl + S で保存。
ターミナルでいつものコマンド
これで、エラーも消えて、画面の下に「メニューバー」がついた最新版Sotto(40代~60代のマッチングアプリ)が立ち上がります! 「さがす」「トーク」「マイページ」を切り替えて遊んでみてください。
チャット機能の実装」 ですね! その選択、素晴らしいです。見た目だけのアプリから、「実際に使える(ような)アプリ」 へと進化する瞬間です。
今回は、トーク画面のリストをタップすると、スルッと画面が横にスライドして「二人だけのチャットルーム」に入る アニメーションまで実装します。 この動きが入ると、触り心地が完全に「プロのアプリ」になりますよ。
さあ、今回も**「全消し&コピペ」**の最強コンボで一発で決めましょう!
ミッション:チャットルームを開通せよ
手順はいつも通りです。何も怖くありません!
アプリを止める(下の黒い画面で Ctrl + C → Y)
main.dart を全消し(右側のコード画面で Ctrl + A → Delete)
以下の「チャット機能搭載・完全版コード」を貼り付け!
import 'package:flutter/material.dart';
void main() {
runApp(const SottoApp());
}
// ユーザー情報
class Profile {
final String name;
final String age;
final String job;
final String location;
final Color color;
final String message;
Profile(this.name, this.age, this.job, this.location, this.color, this.message);
}
class SottoApp extends StatelessWidget {
const SottoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sotto',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
fontFamily: 'Roboto',
),
home: const SottoMainScreen(),
);
}
}
// メイン画面(メニューで切り替える親画面)
class SottoMainScreen extends StatefulWidget {
const SottoMainScreen({super.key});
@override
State<SottoMainScreen> createState() => _SottoMainScreenState();
}
class _SottoMainScreenState extends State<SottoMainScreen> {
int _selectedIndex = 0;
static final List<Widget> _screens = <Widget>[
const CardSwipeScreen(), // 0: さがす
const TalkListScreen(), // 1: トーク
const MyPageScreen(), // 2: マイページ
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _screens[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'さがす'),
BottomNavigationBarItem(icon: Icon(Icons.chat_bubble_outline), label: 'トーク'),
BottomNavigationBarItem(icon: Icon(Icons.person_outline), label: 'マイページ'),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.orange,
onTap: _onItemTapped,
type: BottomNavigationBarType.fixed,
),
);
}
}
// ---------------------------------------------------------
// 1. さがす画面
// ---------------------------------------------------------
class CardSwipeScreen extends StatefulWidget {
const CardSwipeScreen({super.key});
@override
State<CardSwipeScreen> createState() => _CardSwipeScreenState();
}
class _CardSwipeScreenState extends State<CardSwipeScreen> {
final List<Profile> _profiles = [
Profile('カオル', '52', 'カフェ経営', '東京', Colors.brown, '美味しいコーヒー淹れます'),
Profile('ケンジ', '48', '建築士', '横浜', Colors.blueGrey, '休日は美術館巡りへ'),
Profile('サユリ', '45', 'ピアノ講師', '神戸', Colors.purpleAccent, 'ジャズが好きです'),
Profile('ヒロシ', '61', '元商社マン', '福岡', Colors.indigo, '退職後は登山三昧!'),
Profile('マサコ', '55', 'フラワー教室', '札幌', Colors.green, 'ハーブティーで一息'),
];
int _currentIndex = 0;
void _nextProfile(String action) {
if (_currentIndex < _profiles.length) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(action == 'Liked' ? '「いいね」しました!' : '見送りました'),
duration: const Duration(milliseconds: 500),
behavior: SnackBarBehavior.floating,
backgroundColor: action == 'Liked' ? Colors.orange : Colors.grey,
),
);
setState(() { _currentIndex++; });
}
}
void _reset() { setState(() { _currentIndex = 0; }); }
@override
Widget build(BuildContext context) {
bool isFinished = _currentIndex >= _profiles.length;
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft, end: Alignment.bottomRight,
colors: [Color(0xFFFFEFBA), Color(0xFFFF7E5F)],
),
),
child: Center(
child: isFinished
? _buildFinishedScreen()
: _buildProfileCard(_profiles[_currentIndex]),
),
);
}
Widget _buildProfileCard(Profile profile) {
return Container(
width: 320, height: 540,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.white.withOpacity(0.6)),
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 20, spreadRadius: 5)],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.5), shape: BoxShape.circle),
child: Icon(Icons.person, size: 80, color: profile.color),
),
const SizedBox(height: 20),
Text('${profile.name} (${profile.age})', style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.white)),
Text('${profile.location} / ${profile.job}', style: const TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(10)),
child: Text('"${profile.message}"', style: const TextStyle(fontSize: 16, color: Colors.white)),
),
),
const SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildButton(Icons.close, Colors.grey, () => _nextProfile('Passed')),
_buildButton(Icons.favorite, Colors.orangeAccent, () => _nextProfile('Liked')),
],
),
],
),
);
}
Widget _buildFinishedScreen() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.check_circle_outline, size: 80, color: Colors.white),
const SizedBox(height: 20),
const Text('すべてのお相手を見ました', style: TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 30),
ElevatedButton(onPressed: _reset, child: const Text('最初に戻る')),
],
);
}
Widget _buildButton(IconData icon, Color color, VoidCallback onTap) {
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle, boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10)]),
child: Icon(icon, color: color, size: 36),
),
);
}
}
// ---------------------------------------------------------
// 2. トークリスト画面(タップするとチャットへ!)
// ---------------------------------------------------------
class TalkListScreen extends StatelessWidget {
const TalkListScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('トーク')),
body: ListView(
children: [
_buildTalkTile(context, 'ミホ (42)', '初めまして!趣味が合いそうですね', Colors.pink, '2分前'),
_buildTalkTile(context, 'タカシ (50)', 'ありがとうございます。よろしくお願いします。', Colors.blue, '1時間前'),
_buildTalkTile(context, '運営事務局', '本人確認が完了しました', Colors.grey, '昨日'),
],
),
);
}
Widget _buildTalkTile(BuildContext context, String name, String message, Color color, String time) {
return ListTile(
leading: CircleAvatar(backgroundColor: color, child: const Icon(Icons.person, color: Colors.white)),
title: Text(name, style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text(message, maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: Text(time, style: const TextStyle(color: Colors.grey, fontSize: 12)),
onTap: () {
// ここでチャット画面へ移動する魔法!
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChatDetailScreen(name: name, color: color)),
);
},
);
}
}
// ---------------------------------------------------------
// NEW! 2.5 チャット詳細画面(メッセージのやりとり)
// ---------------------------------------------------------
class ChatDetailScreen extends StatefulWidget {
final String name;
final Color color;
const ChatDetailScreen({super.key, required this.name, required this.color});
@override
State<ChatDetailScreen> createState() => _ChatDetailScreenState();
}
class _ChatDetailScreenState extends State<ChatDetailScreen> {
final TextEditingController _controller = TextEditingController();
// ダミーの会話履歴
final List<String> _messages = [
'初めまして!',
'マッチングありがとうございます。',
'プロフィールの写真、素敵ですね!',
];
void _sendMessage() {
if (_controller.text.isNotEmpty) {
setState(() {
_messages.add(_controller.text); // 自分のメッセージを追加
_controller.clear();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Row(
children: [
CircleAvatar(backgroundColor: widget.color, radius: 16, child: const Icon(Icons.person, size: 20, color: Colors.white)),
const SizedBox(width: 10),
Text(widget.name),
],
),
),
body: Column(
children: [
// メッセージリスト
Expanded(
child: ListView.builder(
padding: const EdgeInsets.all(20),
itemCount: _messages.length,
itemBuilder: (context, index) {
// 3つ目までは相手、それ以降は自分(ということにする)
bool isMe = index >= 3;
return Align(
alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
margin: const EdgeInsets.symmetric(vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: isMe ? Colors.orange : Colors.grey[200],
borderRadius: BorderRadius.circular(20),
),
child: Text(
_messages[index],
style: TextStyle(color: isMe ? Colors.white : Colors.black87),
),
),
);
},
),
),
// 入力エリア
SafeArea(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: const BoxDecoration(
color: Colors.white,
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 5)],
),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: const InputDecoration(
hintText: 'メッセージを入力...',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10),
),
),
),
IconButton(
onPressed: _sendMessage,
icon: const Icon(Icons.send, color: Colors.orange),
),
],
),
),
),
],
),
);
}
}
// ---------------------------------------------------------
// 3. マイページ画面
// ---------------------------------------------------------
class MyPageScreen extends StatelessWidget {
const MyPageScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('マイページ')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircleAvatar(radius: 50, backgroundColor: Colors.orange, child: Icon(Icons.person, size: 60, color: Colors.white)),
const SizedBox(height: 20),
const Text('やすとし', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
const Text('大阪府 / デザイナー', style: TextStyle(color: Colors.grey)),
const SizedBox(height: 40),
ElevatedButton(onPressed: () {}, child: const Text('プロフィール編集')),
TextButton(onPressed: () {}, child: const Text('設定')),
],
),
),
);
}
}
保存(Ctrl + S)して、ターミナルで実行!
手順はいつもの通り(全消し&ペースト)です。
import 'package:flutter/material.dart';
void main() {
runApp(const SottoApp());
}
// ユーザー情報
class Profile {
final String name;
final String age;
final String job;
final String location;
final Color color;
final String message;
Profile(this.name, this.age, this.job, this.location, this.color, this.message);
}
class SottoApp extends StatelessWidget {
const SottoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Sotto',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.orange),
fontFamily: 'Roboto',
),
home: const SottoMainScreen(),
);
}
}
// メイン画面
class SottoMainScreen extends StatefulWidget {
const SottoMainScreen({super.key});
@override
State<SottoMainScreen> createState() => _SottoMainScreenState();
}
class _SottoMainScreenState extends State<SottoMainScreen> {
int _selectedIndex = 0;
static final List<Widget> _screens = <Widget>[
const CardSwipeScreen(), // 0: さがす
const TalkListScreen(), // 1: トーク
const MyPageScreen(), // 2: マイページ
];
void _onItemTapped(int index) {
setState(() {
_selectedIndex = index;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: _screens[_selectedIndex],
bottomNavigationBar: BottomNavigationBar(
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(icon: Icon(Icons.search), label: 'さがす'),
BottomNavigationBarItem(icon: Icon(Icons.chat_bubble_outline), label: 'トーク'),
BottomNavigationBarItem(icon: Icon(Icons.person_outline), label: 'マイページ'),
],
currentIndex: _selectedIndex,
selectedItemColor: Colors.orange,
onTap: _onItemTapped,
type: BottomNavigationBarType.fixed,
),
);
}
}
// 1. さがす画面
class CardSwipeScreen extends StatefulWidget {
const CardSwipeScreen({super.key});
@override
State<CardSwipeScreen> createState() => _CardSwipeScreenState();
}
class _CardSwipeScreenState extends State<CardSwipeScreen> {
final List<Profile> _profiles = [
Profile('カオル', '52', 'カフェ経営', '東京', Colors.brown, '美味しいコーヒー淹れます'),
Profile('ケンジ', '48', '建築士', '横浜', Colors.blueGrey, '休日は美術館巡りへ'),
Profile('サユリ', '45', 'ピアノ講師', '神戸', Colors.purpleAccent, 'ジャズが好きです'),
Profile('ヒロシ', '61', '元商社マン', '福岡', Colors.indigo, '退職後は登山三昧!'),
Profile('マサコ', '55', 'フラワー教室', '札幌', Colors.green, 'ハーブティーで一息'),
];
int _currentIndex = 0;
void _nextProfile(String action) {
if (_currentIndex < _profiles.length) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(action == 'Liked' ? '「いいね」しました!' : '見送りました'),
duration: const Duration(milliseconds: 500),
behavior: SnackBarBehavior.floating,
backgroundColor: action == 'Liked' ? Colors.orange : Colors.grey,
),
);
setState(() { _currentIndex++; });
}
}
void _reset() { setState(() { _currentIndex = 0; }); }
@override
Widget build(BuildContext context) {
bool isFinished = _currentIndex >= _profiles.length;
return Container(
decoration: const BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topLeft, end: Alignment.bottomRight,
colors: [Color(0xFFFFEFBA), Color(0xFFFF7E5F)],
),
),
child: Center(
child: isFinished
? _buildFinishedScreen()
: _buildProfileCard(_profiles[_currentIndex]),
),
);
}
Widget _buildProfileCard(Profile profile) {
return Container(
width: 320, height: 540,
decoration: BoxDecoration(
color: Colors.white.withOpacity(0.3),
borderRadius: BorderRadius.circular(20),
border: Border.all(color: Colors.white.withOpacity(0.6)),
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 20, spreadRadius: 5)],
),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
padding: const EdgeInsets.all(20),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.5), shape: BoxShape.circle),
child: Icon(Icons.person, size: 80, color: profile.color),
),
const SizedBox(height: 20),
Text('${profile.name} (${profile.age})', style: const TextStyle(fontSize: 32, fontWeight: FontWeight.bold, color: Colors.white)),
Text('${profile.location} / ${profile.job}', style: const TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 15),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: Container(
padding: const EdgeInsets.all(10),
decoration: BoxDecoration(color: Colors.white.withOpacity(0.2), borderRadius: BorderRadius.circular(10)),
child: Text('"${profile.message}"', style: const TextStyle(fontSize: 16, color: Colors.white)),
),
),
const SizedBox(height: 40),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
_buildButton(Icons.close, Colors.grey, () => _nextProfile('Passed')),
_buildButton(Icons.favorite, Colors.orangeAccent, () => _nextProfile('Liked')),
],
),
],
),
);
}
Widget _buildFinishedScreen() {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Icon(Icons.check_circle_outline, size: 80, color: Colors.white),
const SizedBox(height: 20),
const Text('すべてのお相手を見ました', style: TextStyle(fontSize: 20, color: Colors.white)),
const SizedBox(height: 30),
ElevatedButton(onPressed: _reset, child: const Text('最初に戻る')),
],
);
}
Widget _buildButton(IconData icon, Color color, VoidCallback onTap) {
return GestureDetector(
onTap: onTap,
child: Container(
padding: const EdgeInsets.all(18),
decoration: BoxDecoration(color: Colors.white, shape: BoxShape.circle, boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 10)]),
child: Icon(icon, color: color, size: 36),
),
);
}
}
// 2. トークリスト画面
class TalkListScreen extends StatelessWidget {
const TalkListScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('トーク')),
body: ListView(
children: [
_buildTalkTile(context, 'ミホ (42)', '初めまして!趣味が合いそうですね', Colors.pink, '2分前'),
_buildTalkTile(context, 'タカシ (50)', 'ありがとうございます。よろしくお願いします。', Colors.blue, '1時間前'),
_buildTalkTile(context, '運営事務局', '本人確認が完了しました', Colors.grey, '昨日'),
],
),
);
}
Widget _buildTalkTile(BuildContext context, String name, String message, Color color, String time) {
return ListTile(
leading: CircleAvatar(backgroundColor: color, child: const Icon(Icons.person, color: Colors.white)),
title: Text(name, style: const TextStyle(fontWeight: FontWeight.bold)),
subtitle: Text(message, maxLines: 1, overflow: TextOverflow.ellipsis),
trailing: Text(time, style: const TextStyle(color: Colors.grey, fontSize: 12)),
onTap: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => ChatDetailScreen(name: name, color: color)),
);
},
);
}
}
// ---------------------------------------------------------
// 2.5 チャット詳細画面(シンプル版:送るだけ!)
// ---------------------------------------------------------
class ChatDetailScreen extends StatefulWidget {
final String name;
final Color color;
const ChatDetailScreen({super.key, required this.name, required this.color});
@override
State<ChatDetailScreen> createState() => _ChatDetailScreenState();
}
class _ChatDetailScreenState extends State<ChatDetailScreen> {
final TextEditingController _controller = TextEditingController();
// 会話データ(最初は相手からのメッセージだけ)
final List<Map<String, dynamic>> _messages = [
{'text': '初めまして!マッチングありがとうございます。', 'isMe': false},
{'text': '趣味が合うなと思って「いいね」しちゃいました!', 'isMe': false},
];
// 送信ボタンを押した時の処理
void _sendMessage() {
if (_controller.text.isNotEmpty) {
setState(() {
// 自分のメッセージをリストに追加するだけ!
_messages.add({'text': _controller.text, 'isMe': true});
_controller.clear();
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Row(
children: [
CircleAvatar(backgroundColor: widget.color, radius: 16, child: const Icon(Icons.person, size: 20, color: Colors.white)),
const SizedBox(width: 10),
Text(widget.name),
],
),
),
body: Column(
children: [
// メッセージリスト
Expanded(
child: ListView.builder(
padding: const EdgeInsets.all(20),
itemCount: _messages.length,
itemBuilder: (context, index) {
final msg = _messages[index];
final isMe = msg['isMe'] as bool;
return Align(
alignment: isMe ? Alignment.centerRight : Alignment.centerLeft,
child: Container(
margin: const EdgeInsets.symmetric(vertical: 5),
padding: const EdgeInsets.symmetric(horizontal: 15, vertical: 10),
decoration: BoxDecoration(
color: isMe ? Colors.orange : Colors.grey[200],
borderRadius: BorderRadius.circular(20),
),
child: Text(
msg['text'] as String,
style: TextStyle(color: isMe ? Colors.white : Colors.black87),
),
),
);
},
),
),
// 入力エリア
SafeArea(
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5),
decoration: const BoxDecoration(
color: Colors.white,
boxShadow: [BoxShadow(color: Colors.black12, blurRadius: 5)],
),
child: Row(
children: [
Expanded(
child: TextField(
controller: _controller,
decoration: const InputDecoration(
hintText: 'メッセージを入力...',
border: InputBorder.none,
contentPadding: EdgeInsets.symmetric(horizontal: 10),
),
onSubmitted: (_) => _sendMessage(),
),
),
IconButton(
onPressed: _sendMessage,
icon: const Icon(Icons.send, color: Colors.orange),
),
],
),
),
),
],
),
);
}
}
// 3. マイページ画面
class MyPageScreen extends StatelessWidget {
const MyPageScreen({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('マイページ')),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const CircleAvatar(radius: 50, backgroundColor: Colors.orange, child: Icon(Icons.person, size: 60, color: Colors.white)),
const SizedBox(height: 20),
const Text('やすとし', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
const Text('大阪府 / デザイナー', style: TextStyle(color: Colors.grey)),
const SizedBox(height: 40),
ElevatedButton(onPressed: () {}, child: const Text('プロフィール編集')),
TextButton(onPressed: () {}, child: const Text('設定')),
],
),
),
);
}
}
「おめでとうございます!これであなたのアプリは完成です!」

ブラウザの中で、パステルカラーのグラデーションが揺れていませんか? 「トーク」タブを押して、メッセージを送ってみてください。ちゃんと会話が増えましたか?
今、あなたのパソコンの中で動いているそれ、誰かが作ったものじゃありません。 あなたが、自分の手で生み出したアプリです。
ほんの数十分前まで、あなたのPCはただの「ネットを見る板」でした。
でも今は違います。「世界に一つのサービスを生み出す工場」に変わったんです。
この瞬間、あなたは「消費者」から「生産者」になりました。
エンジニアじゃない?
50代だから遅い?
そんな常識、たった今、このコードで上書き保存しちゃいましたね(笑)。
最後に:僕が伝えたかった本当のこと
今回、有料パートで公開したこの長い長いコード。
実はこれ、僕が手打ちで書いた部分は 1文字もありません。
すべて、相棒のAI(Gemini/左席)にお願いして、 「ここをもっとおしゃれに」 「チャットができるようにして」 「エラーが出たから直して」 と、会話しながら組み立てたものです。
僕がやったことと言えば、「諦めずにAIに話しかけ続けたこと」。
それだけです。
これからの時代に必要なのは、難しいプログラミング言語を暗記する力ではありません。
「こんな世界を作りたい」という妄想力と、それをAIに伝える「言葉の力」です。
今日、このアプリが動いたあなたなら、次はもっとすごいものが作れます。
「自分だけの家計簿アプリ」 「孫と遊ぶためのクイズアプリ」 「商店街のお店を紹介するマップ」
Antigravity(AI)という最強のエンジンは、もうあなたの手元にあります。 あとは、あなたが「機長」として行き先を決めるだけです。
このアプリを「あなた色」に染めてください
最後に、僕から一つだけ宿題を出します。 今回コピペしたコードの中に、こんな部分がありますよね?
Profile('カオル', '52', 'カフェ経営', '東京', Colors.brown, '美味しいコーヒー淹れます'),
ここを、あなたの名前に書き換えてみてください。 Colors.brown を Colors.pink に変えてみてください。
そしてもう一回、ターミナルで r (リロード)を押してみてください。
画面の中のアプリが、あなただけのものに変わるはずです。 その瞬間こそが、本当の「Vibe Coding」の始まりです。
長い記事にお付き合いいただき、本当にありがとうございました! 「動いたよ!」「ここを変えてみたよ!」という報告、コメント欄で待ってます。全部読みに行きますからね!
もしこの記事が「役に立った!」「勇気が出た!」と思ったら、ぜひスキ(ハートマーク)とフォローをお願いします。
次回の記事では、このアプリをさらに進化させて、「スマホの実機(自分のiPhone)」に入れる方法や、「AIを使って副業案件を獲得する裏技」なんかも公開しようと画策中です。