Skip to content

Instantly share code, notes, and snippets.

@toshimasa-nanaki
Last active March 21, 2018 05:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toshimasa-nanaki/8f454c416ae5f0a4fe602e66c79ac298 to your computer and use it in GitHub Desktop.
Save toshimasa-nanaki/8f454c416ae5f0a4fe602e66c79ac298 to your computer and use it in GitHub Desktop.
flutterアプリ作ってみたいstep1-1
/// Materialデザインとするので、Flutterが提供しているMaterialウィジェットを使用
import 'package:flutter/material.dart';
/// mainメソッド。fat arrow表記法(=>)で指定。(1行で書けるので便利)
void main() => runApp(new MyApp());
/// StatelessWidgetクラスを継承。これによりアプリがウィジェットになる。
/// Flutterでは、ほとんどすべてのものがウィジェットである。
class MyApp extends StatelessWidget {
/// buildメソッドのオーバーライド(これがウィジェットの主な仕事)
/// 下位のウィジェットから見たウィジェットの表示方法を記載する。
@override
Widget build(BuildContext context) {
/// Scaffoldウィジェットは、デフォルトのアプリケーションバーや
/// ホームスクリーン用のウィジェットツリーを保持するbodyプロパティを提供する。
/// この例では、
/// appBarのタイトルに「Flutterへようこそ」を表示し、
/// bodyにはCenterウィジェットの子としてTextウィジェットを追加して、
/// 真ん中寄せの「こんにちは世界!!」を表示している。
return new MaterialApp(
title: 'Flutterへようこそ',
home: new Scaffold(
appBar: new AppBar(
title: new Text('Flutterへようこそ'),
),
body: new Center(
child: new Text('こんにちは世界!!'),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment