LoginSignup
0

posted at

updated at

【Flutter】超初心者向け基本のテンプレート

Flutterのどこに何が書いてあるかがわかりやすいので備忘録として残します。
このテンプレートは使いまわせるんじゃないかと!

【Flutter】超初心者向け基本のテンプレート

main.dart
import 'package:flutter/material.dart';

void main() => runApp(MyApp()); // 引数のWidgetが全画面表示される

// 最初に表示するWidgetのクラス
class MyApp extends StatelessWidget {  // StatelessWidgetを継承
  @override
  Widget build(BuildContext context) {  //buildメソッドでUIを作成
    return MaterialApp(  // マテリアルデザインのアプリ
      title: "My Simple App",  // アプリのタイトル
      home: Scaffold(  // マテリアルデザインの土台
        appBar: AppBar(  // ヘッダーに表示するアプリケーションバー
          title: Text("好きなタイトル"),  // タイトルを表示
        ),
        body: Center(  // 中央に配置
          child: Text("文字入力してください"),  // 文字列を配置
        ),  // Center
      ),  // Scaffold
    );  // MaterialApp
  }  // Widget build(BuildContext context)
}  // class MyApp

このコードだとヘッダーに「好きなタイトル」というタイトルが現れ、真ん中に「文字を入力してください」と表示されます。

あとは中を作っていくだけですね。

機会があればまた更新します。

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
What you can do with signing up
0