본문 바로가기

Flutter

[Flutter] FutureBuilder 사용법 - 비동기 처리결과를 UI에 적용하기 위해 사용하는 위젯으로 FutureBuilder는 'Future' 객체를 사용해  데이터를 비동기적으로 가져오고, 가져온 데이터를 기반으로 화면에 UI를 표시 FutureBuilder 위젯 추가하기FutureBuilder는 필요한 두 가지 파라미터인 future와 builder를 작성해야 함.future는 데이터를 가져오는 Future 객체를, builder는 UI를 구성하는 함수를 입력 import 'package:flutter/material.dart';import 'package:http/http.dart' as http;import 'dart:convert';void main() => runApp(MyApp());class MyApp extends Statel.. 더보기
[Flutter] 외부 위젯 가져와서 사용하기(video_player) flutter pub get1. 해당 위젯을 pub.dev  에서 검색하여 문서를 확인 2. 제목 우측에 복사 버튼으로 해당 패키지 명(+버전) 복사  3. 복사한 패키지이름을 패키지를 관리하는 pubspec.yaml 파일에 추가video_player: ^2.8.6 dependencies: flutter: sdk: flutter # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.6 video_player: ^2.8.6  단! flutter의 pubspec.y.. 더보기
[Flutter] Dart 문법 - 04. 연산자 4. 연산자 1. 3항 연산자 String? strValue; //if문 if(strValue != null){ strValue = 'init value'; } //3항 연산자 가능 strValue = strValue==null ? 'init value' : strValue; strValue = strValue ?? 'init value'; strValue ??= 'init value'; 2. 케스케이드 연산자(Cascade notation) //같은 widget(객체)의 속성을 연속으로 변경할 경우 사용함 var user1 = User(); user1.name = 'kim'; user1.age = 30; user1.sex = 'male'; user1.id = 'sai'; var user2 = User(.. 더보기
[Flutter] Dart 문법 - 02. 조건문과 03. 반복문 2. 조건문 1. if or 삼항연산자 int intValue = 10; if(intValue > 20){ print('20 이상'); } else if( i == 20){ print('20'); }else{ print('20보다 작음'); } if(intValue == 20) print('20');//1줄로 사용 가능 int intValueUser = intValue 7){ break; } print(i); } //34567 2. while, do while int intValue = 1; while (intValue 1); 더보기
[Flutter] Dart 문법 - 01. 데이터 타입 1. 데이터 타입 int double String(시작이 대문자이니 클래스 겠지?) bool num(int, double이 상속받음) int num1 = 10; double num2 = 3.0; String strValue = 'name'; bool isTrue = true; 해당 변수의 타입 확인 is runtimeType //is로 현재 변수가 int가 맞는지 확인 print(num1 is int); //true print(num2 is int); //flase print(num1.runtimeType); //int print(strValue.runtimeType); //String 타입 추론 추론을 통해 이후 사용된 값을 기준으로 타입을 정함 var (컴파일시 코드로 타입이 결정됨) dynamic .. 더보기