본문 바로가기

: IT/Flutter

(10)
[Flutter/Dart] Stateless Widget 1. main.dart import 'package:flutter/material.dart'; import 'package:toonflix/widgets/Button.dart'; import 'package:toonflix/widgets/currency-card.dart'; void main() { runApp(App()); } class App extends StatelessWidget { @override Widget build(BuildContext context) { // return CupertinoApp // ios return MaterialApp( home: Scaffold( backgroundColor: const Color(0xFF181818), body: SingleChildScrol..
Visual Studio - develop for Windows (the doctor check crashed) 해결법: C:\Program Files (x86)\Microsoft Visual Studio\Installer 폴더에 vswhere 파일을 덮어쓰기 다운로드 위치: https://github.com/microsoft/vswhere/releases
Final & Const 변수 void main() { int age; // mutable한 속성을 가지고 있음 age = 20; age = 50; } Final variable can be set only once. Final 변수는 값을 한번 설정할 수 있다. 런타임 시에 상수화 된다. final 변수는 rebuild 될 수 있음 a const variable is complie-time constant. const 변수는 컴파일 시에 상수가 된다. 선언과 동시에 초기화를 해야한다 Compile-time constant = Run-time constant void main() { final int myFinal = 30; const int myConst = 70; } // final, const는 제어자. 변수에 제한을 검 // ..
Focus Focus FocusNode: 포커스를 받는 특정 위젯을 식별할 때 사용. FocusScope: 어떤 위젯들까지 포커스를 받는지 범위를 나타낼 때 사용. FocusScope.of(context) 메소드: 현재 포커스된 포커스노드를 가르킴 FocusScope.of(context).unfocus() 메소드: 포커스를 해제함 플러터토스트 라이브러리 https://pub.dev/packages/fluttertoast fluttertoast | Flutter Package Toast Library for Flutter, Easily create toast messages in single line of code pub.dev 1. pubspec.yaml 파일에 라이브러리 추가 2. 토스트 보여주는 함수 추가 후 ..
플러터 2.0 버튼 import 'package:flutter/material.dart'; void main() { runApp(App()); } class App extends StatelessWidget { const App({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData(primarySwatch: Colors.blue), home: Page()); } } class Page extends StatelessWidget { const Page({Key? key}) : super(key: key); @override Widget build(BuildContext con..
Collection and Generic String Interpolation String name = "jisu"; print("Hi, $name!"); Collection : 데이터들을 모아서 가지고 있는 자료 구조 Generic : Collection이 가지고 있는 데이터들의 데이터 타입을 지정. 코드의 재사용성을 높임 List는 2가지 종류 fixed-length list : 길이가 고정인 리스트 ex) var number = new List(5); growable list : 가변 길이 리스트 ex) var number = new List(5); 1. 스낵바와 ScaffoldMessenger import 'package:flutter/material.dart'; void main() { runApp(App()); } class App ..
Navigator.pushNamed와 routes로 페이지 이동 1. main.dart import 'package:flutter/material.dart'; import 'ScreenA.dart'; import 'ScreenB.dart'; import 'ScreenC.dart'; void main() => runApp(App()); class App extends StatelessWidget { const App({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( initialRoute: '/', routes: { '/': (context)=>ScreenA(), '/b': (context)=>ScreenB(), '/c': (context)=>S..
Widget - Flutter의 모든 것은 위젯으로 되어있다 - Stateless widget : 정적인 위젯. 변화가 없음 - Stateful widget : 위젯의 모양이나 상태가 변함 - 위젯은 트리구조로 구성되어 있다 부모와 자식 구조로 되어있으며, 부모는 여러개의 자식을 가질 수 있다.