.NET 開発基盤部会 Wiki」は、「Open棟梁Project」,「OSSコンソーシアム .NET開発基盤部会」によって運営されています。

目次

概要

Flutter の step by step(其の一)。

手順1

コチラを参考にして実施

インストール

ダウンロード

https://flutter.dev/docs/get-started/install/windows

解凍&パス指定

flutter_windows_x.x.x-stable.zip

チェック(1)

以下のCommandを実行し、TODOを確認する。

>flutter doctor

Android Studioのインストール

※ 前述のPowerShell?だと、%USERPROFILE%が展開されねぇんだけど...。

プラグインのインストール

「File」メニュー -> 「Settings..」 -> 「Plugins」

チェック(2)

以下のCommandを実行し、問題が無いことを確認する。

>flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 
10.0.19041.867], locale ja-JP)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code, 64-bit edition (version 1.47.2)
[√] Connected device (2 available)

• No issues found!

>

余談:SDKのパス変更

SDKのパスを変更する場合、以下の手順に従って変更する。

サンプルの生成と実行

新規作成プロジェクト

Android Studioで、新規作成プロジェクトする。

プロジェクトタイプ概要
Flutter Applicationアプリケーション用
Flutter Plugin AndroidネイティブAPI用ライブラリ用
Flutter Package画面部品用
Flutter ModuleDartライブラリ用

デバッグ実行

プロジェクトの開発

手順2で説明する。

デバッグ実行

Android Studioで1GB、エミュレータで6GB程、メモリを消費するので、
開発機のメモリが16GB程度では少々、スペック不足、故に実機でのデバッグを行うことになる。

エミュレータを登録して実行

実機でデバッグ実行する場合

Flutter Devtoolsを利用する。

FlutterInspector

その他のツールを利用する。

を併用すると、RAD風に開発できる。

手順2

イベントを実装する。

ボタンのWidget

RaisedButton?

RaisedButton(
  child: const Text('Button'),
  color: Colors.orange,
  textColor: Colors.white,
  onPressed: () {},
),

ElevatedButton?

onPressedに、任意のメソッドを書く。

ElevatedButton(
  child: const Text('Button'),
  style: ElevatedButton.styleFrom(
    primary: Colors.orange,
    onPrimary: Colors.white,
  ),
  onPressed: () {},
),

FlatButton?

FlatButton(
  child: const Text('Button'),
  textColor: Colors.black,
  onPressed: () {},
),

TextButton?

onPressedに、任意のメソッドを書く。

TextButton(
  child: const Text('Button'),
  style: TextButton.styleFrom(
    primary: Colors.black,
  ),
  onPressed: () {},
),

OutlineButton?

OutlineButton(
  child: const Text('Button'),
  onPressed: () {},
),

OutlinedButton?

onPressedに、任意のメソッドを書く。

OutlinedButton(
  child: const Text('Button'),
  style: OutlinedButton.styleFrom(
    primary: Colors.black,
  ),
  onPressed: () {},
),

IconButton?

ButtonBar?

FloatingActionButton?

PopupMenuButton?

DropdownButton?

任意のWidget

ボタンでない、任意のWidgetに、イベントを実装できる。

InkWell?

簡単に、Ripple エフェクトを付ける事が出来る。

Material(                  // 親にMaterialが必須
 color: Colors.blue,       // Material自体は青を指定
 child: Center(            //
   child: Ink(             // ここをContainerにするとsplashが効かないので、Inkに変える
     color: Colors.yellow, // 背景色はここで指定
     width: 200.0,
     height: 100.0,
     child: InkWell(
         onTap: () {},
         child: Center(child: Text('YELLOW'))
     ),
   ),
 ),
)

GestureDetector?

InkWellのRipple エフェクトは無いが、
他のイベント(ジェスチャー)にも反応する。

GestureDetector(
  // タッチ検出対象のWidget
  child: Text(
    'How to use GestureDetector',
    textAlign: TextAlign.center,
    overflow: TextOverflow.ellipsis,
    style: TextStyle(fontWeight: FontWeight.bold),
  ),
  // ダブルタップ
  onDoubleTap: _incrementCounter
)

参考

Qiita

手順3

API

push

pushNamed

メニュー

AppBar?

Drawer

TabBar?

BottomNavigationBar?

SliverAppBar?

これは、画面遷移ではないし、SliverAppBar?のUX自体に、誰得感がある。

参考

Qiita

手順4

パッケージの追加と利用

パッケージの追加

english_wordsをパッケージの追加・利用する。

パッケージの利用

参考

参考


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS