일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- Cow
- file
- pintos
- scaffold
- Copy-on-write
- System call
- icon button
- stack growth
- Flutter
- flutter
- vm
- create
- BFS
- materialapp
- algorithm
- widget
- Today
- Total
목록Flutter (11)
JunHyeok

Null safety 의 필요성. 제일 처음 코딩할 때 들었던 생각이 "왜 변수 선언 하나하나에 타입을 따져가며 에러가 발생하는걸까? 당장은 Null 이여도, 언젠가 초기화를 해줄텐데!" Non-nullable인 String 타입의 name은 초기화 되어야 한다고 에러가 나고있습니다. 만약 에러가 나지 않는다면, 수백만줄이 되는 코드베이스에서 어디서 어떤 변수가 Null이 되어 에러가 나는지 찾기란 쉽지 않습니다. 또한 모든 변수에 대해 Null 처리를 하는 것도 쓸대없이 코드가 길어지는 상황만 야기합니다. 따라서 Swift의 Optional 처럼, Flutter도 2.0 버전에서부터는 Null safety를 통해 안전한 앱 개발이 가능합니다! Null Safety 추가 하지만 name이 아직 N..

간단한 Future 예제void main() { print('Before Future'); Future(() { print('running the future'); }).then((_) { print('future is complete'); }); print('after future');} 결괏값Before Futureafter futurerunning the futurefuture is complete 위처럼, Future는 순차적으로 진행되지 않으며, Event Queue 에서 선입 선출로 실행됩니다. Async method메서드를 통해서 나오는 결과들은 future 가 됩니다.await 키워드를 만날때까지 synchronous 방식으로 동작합니다.await 키워드를 만나면, ..

전체 코드 import 'dart:io'; void main() { showData(); } void showData() async { startTask(); String account = await accessData(); fetchData(account); }void startTask() { String info1 = "요청 수행 시작"; print(info1);}Future accessData() async { String account = "3000원"; Duration time = Duration(seconds: 3); if(time.inSeconds > 2) { await Future.delayed(time, (){ account = "700..

로그인 페이지 위와 같이 간단한 로그인 페이지를 만든다고 가정합시다. 해당 버튼을 모두 하나씩 만든다면 유지보수가 어렵겠죠? 따라서, 위와 같이 MyButton 클래스를 만들어 줍니다. _ 언더바를 사용한다는 것 Flutter에서 위와 같이 언더바를 넣는다면, private 하게 선언하는 것 과 같습니다. 즉 해당 파일 내에서만 사용 가능합니다. MyButton class MyButton extends StatelessWidget { const MyButton({super.key, required this.image, required this.text, required this.color, required this.radius, required this.onPressed}); ..

플러터에서 final과 const 키워드의 차이점final과 const 키워드는 모두 변수의 값을 변경할 수 없도록 하는 데 사용됩니다.1. 값 초기화 시점final: ** 변수 선언 시점에 **초기값을 반드시 지정해야 합니다. 예시: final String name = 'Flutter';const: 변수 선언 시점에 초기값을 지정해야 하고, 컴파일 타임에 값이 결정됩니다. 예시: const String message = 'Hello, Dart!';2. 메모리 할당final: 런타임에 메모리 할당const: 컴파일 타임에 메모리 할당. 불변 객체로 저장되어 프로그램 실행 속도 향상3. 객체 생성final: 새로운 객체 생성 가능예시: final List numbers = ['one', 'two', 'th..

MaterialApp의 initialRoute 와 routes 속성에 주목해보자.class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( // title: 'Multiple Screen', // theme: ThemeData(primarySwatch: Colors.red), initialRoute: "/", routes: { '/' : (_) => screenA(), '/b' : (_) => screenB(), '/c' : (_) => screen..

App bar icon buttonleading : 아이콘 버튼이나 간단한 위젯을 왼쪽에 배치할 때 사용되는 속성!actions : 복수의 아이콘 버튼 등을 오른쪽에 배치할 때onPressed : 함수의 형태로 일반 버튼이나 아이콘 버튼을 터치했을 때 일어나는 이벤트를 정의함. (즉, 함수다!)

MyApp (MaterialApp)class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( debugShowCheckedModeBanner: false, title: "BBRANTO", home: Grade(), ); }} MaterialApp 1. 앱의 진입점:앱 실행의 시작점 역할을 합니다.runApp() 함수를 통해 앱의 루트 위젯으로 설정됩니다.2. 앱 설정:앱 제목 (title) 설정기본 테마 (theme) 설정 (색상, 글꼴 등)앱의 루트 페이지 (home) 설..

body: Padding(...) Body에 Padding을 주고, padding 속성에 EdgeInsets.fromLTRB(0.0,0.0,0.0,0.0) 을 넣으면 위와 같이 UI가 배치됩니다! Column의 mainAxisAlignment 속성을 : MainAxisAlignment.center 로 설정하면 위와 같이 중앙에 위치하며, padding 값을 조절하여 추가적인 UI 변경을 할 수 있습니다. Center body의 속성을 Center로 설정하고 mainAxisAlignment 속성을 주지 않으면 위와 같이 Center로 정렬 됩니다. body의 속성을 Center로 설정하고 MainAxisAlignment.center 로 설정하면 위와 같이 가로 및 세로가 중앙으로 정렬 됩..

플러터 시작하기. 가장 중요한 main.dart! 새로운 Flutter 프로젝트를 생성하면, 기본적으로 버튼을 클릭하면 Counting을 올려주는 앱 코드가 작성되어 있다. 이 것을 모두 삭제하고 차근차근 나아가보자! import 'package:flutter/material.dart';void main() => runApp(MyApp());class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: "Hello World", theme: ThemeData( primary..