본문 바로가기

코딩/플러터

(4)
Flutter - 현재 위젯 캡쳐(캡처) 현재 위젯을 캡쳐하는 방법을 알아보자. 안드로이드였다면 onDraw를 썼을테지만.. 플러터엔 그런거 없다..! 다만, renderObject를 활용하면 된다. 전체 소스 코드는 https://github.com/5seunghoon/Flutter_Capture_Example 여기에 있다. 1. 먼저 import부터. import 'dart:io'; import 'dart:async'; import 'dart:ui' as ui; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'pac..
플러터 - Status bar만 남기고 App bar는 지우기 Appbar를 지우려고 return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( appBar: new AppBar(), body: Center( child: Text("Hi"), )), ); 이런 코드에서 appbar만 지우면 쓸대없게도 status bar도 같이 사라진다. 이럴땐, primary: true, appBar: EmptyAppBar(), body: Center( child: Text("Hi"), )); 이런식으로 EmptyAppBar를 넣어주고, class EmptyAppBar extends StatelessWidget implements PreferredS..
간단한 플러터 앱 - 2초마다 한번씩 랜덤한 이름 만들기 플러터를 처음 공부하게 되면 하게 되는 튜토리얼의 앱인 "랜덤 이름 제네레이터" 구글 코드 랩에 나와있는 이 앱을 간단하게 개선해보면서 Stream의 사용법을 익혀봅시다. https://codelabs.developers.google.com/codelabs/first-flutter-app-pt2/#8 이 링크를 통해 "랜덤 이름 제네레이터"를 만들어 보았다는 가정 하에 글을 써보겠습니다. 자 그럼, 우리는 이 앱을 기반으로 기능 하나를 추가해 보도록 합시다. 추가해볼 기능은 바로, 제목에도 나와있듯이, 랜덤한 이름을 2초마다 한번씩 제네레이팅하는 기능입니다. 일단, Dart의 Stream에 대해 알아보기 전에, https://software-creator.tistory.com/13?category=681..
플러터의 위젯 (1) - Container, Child, Children 플러터의 모든 것은, 그 앱 자체를 포함해서, 위젯이다. 이러한 모양의 위젯은, 이러한 트리로 구성된다. Container의 하위로 위젯을 넣으려면 child이나 children에 넣어주면 된다. 이름에서 알수 있듯이, 하나만 넣으려면 child, 여러개면 children이다. A child property if they take a single child – for example, Center or Container A children property if they take a list of widgets – for example, Row, Column, ListView, or Stack. (https://flutter.dev/docs/development/ui/layout 에서 발췌) 여기서 알 수 ..