Last active
March 21, 2018 05:33
-
-
Save toshimasa-nanaki/8f454c416ae5f0a4fe602e66c79ac298 to your computer and use it in GitHub Desktop.
flutterアプリ作ってみたいstep1-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// 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