일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- sensor
- Contour
- mfc
- Encapusulation
- Binary
- digitalRead
- aduino
- Barcode
- Overloading
- UNO
- public
- memory
- SERIAL
- wpf
- Android
- parameter
- Read
- inheritance
- length
- atmega328
- Pointer
- java
- compare
- Class
- stream
- file access
- Unity
- flutter
- preprocessing
- APP
- Today
- Total
폴크(FOLC)
Flutter - Dart 문법 1 본문
# New Flutter Project 하면 아래와 같이 기본 코드가 자동 생성된다.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
# material 패키지를 연결시켜서 Dart 문법의 사용하는 기본 함수들이 이용한다.
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
// This is the theme of your application.
//
// Try running your application with "flutter run". You'll see the
// application has a blue toolbar. Then, without quitting the app, try
// changing the primarySwatch below to Colors.green and then invoke
// "hot reload" (press "r" in the console where you ran "flutter run",
// or simply save your changes to "hot reload" in a Flutter IDE).
// Notice that the counter didn't reset back to zero; the application
// is not restarted.
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
# 데이터의 변화가 없고 고정적으로 사용되는 Widget
# 단 한번만 Build 되고 화면은 계속 유지된다.
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
// This widget is the home page of your application. It is stateful, meaning
// that it has a State object (defined below) that contains fields that affect
// how it looks.
// This class is the configuration for the state. It holds the values (in this
// case the title) provided by the parent (in this case the App widget) and
// used by the build method of the State. Fields in a Widget subclass are
// always marked "final".
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
# 데이터의 변화가 있고 유동적으로 사용되는 Widget
# setState가 발생할때마다 Build과정이 일어난다. ( state를 포함 )
'Flutter, Android > Flutter - Dart 문법' 카테고리의 다른 글
Flutter - Dart 문법 2 (0) | 2021.07.06 |
---|