0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

メモ:Flutter関係の情報

Last updated at Posted at 2022-05-20

Flutterの基本

iOSTOAndroidで別々のコードを書きたく無いが、ゲームでは無いのでUnityよりも軽量なアプリケーションを作りたい

という場合の選択肢として調査。
モバイル向けは大昔にAndroid用アプリを趣味でJavaで作ったのと、iOSアプリをSwiftで作ってもらったのを少し維持してたくらい。

ライセンス的にも問題なし。

インストール

公式サイトからDLもできるが、

macならHomebrewでインストールできそう。

https://flutter-master.com/flutter-start/build-environment-homebrew/

brew install flutter

flutter doctor

Upgradeを勧められたらしておいても良い。
AndroidStudioと、Xcodeが必要になる。

brew install android-studio
# 実際にStudioを開いて設定をしておく
flutter doctor --android-licenses

1.png

AndroidStudioはコマンドラインツールを入れておく必要がありそう

Xcodeを入れていない場合は時間がかかる。

アプリケーションを作ってみる

flutter create hello_world

これで雛形が作られる。

cd hello_world
flutter run
# 2のchromeを選択

サンプルは動いた。

dart

少しjavaに似てはいるが、dart言語で書く必要があるので少し理解しておく必要がある。

コンストラクタについては、とりあずは

class Person {
  int age;

  Person(this.age);
}

の書き方と、サンプルの

const MyHomePage({Key? key, required this.title}) : super(key: key);

の書き方(requiredは必須の意味)あたりは知っておく必要がありそう。
こことかこことか。

コロンはassertで警告出したり、スーパーコンストラクタ呼んだり、フィールド初期化したりするのに使えるらしい。

メソッドは

void main(){
   print('Hello, world!');
}

と普通に書けるし、次のように1行でも書けるらしい。
省略するのがいいらしいけど、個人的には省略せずに書き方を統一してる方が好き・・・

main() => print('Hello, world!');

画面遷移の考え方なんかも理解しておくと良さそう。

あとは単体テストはMockitoが使えるらしい。

https://zuma-lab.com/posts/flutter-mockito-null-safety-unit-testとか
https://aakira.app/blog/2022/01/dart-mockito-multiple-times/

色々方法

電話アプリとかブラウザの起動

https://dev-yakuza.posstree.com/flutter/url_launcher/とか
https://qiita.com/toda-axiaworks/items/fbd01c46d60b094c557c

ローカルファイルの読み書き

https://zenn.dev/pressedkonbu/articles/flutter-file-io
https://qiita.com/kurararara/items/968b2bc562a609a12f1e

PDF表示なんかはこれ

https://zenn.dev/mukkun69n/articles/dc45ab6169a0fa

テキストやファイルのシェア

https://qiita.com/hmatsu47/items/f0d2e0ca4854862e1357

多言語対応

https://qiita.com/kazutxt/items/936ebe7a21ede7e1ab20とか
https://zenn.dev/reinf0rce/articles/618938598fc4dd

httpを呼ぶ

https://dev-yakuza.posstree.com/flutter/http/

Push通知

https://future-architect.github.io/articles/20220323a/

XDからの出力

https://note.com/himonopolice/n/n8bda4d141c20

全体
https://tech.pepabo.com/2020/05/27/flutter-hands-on/

シミュレータで動かないとき
ちなみにAndroidで動かない、と思ったら初回は結構時間かかるだけだった

Running Gradle task 'assembleDebug'...                            359.2s

https://zenn.dev/masayakitani/scraps/c0498f03b2f007

実際に作る場合

XDでレイアウトとかを作成して出力、ウィジェットを書き換え、というのが単純なアプリの場合は早い、かも?

とりあえず一旦調査まで。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?