본문 바로가기

전체 글

[Widget] Is there a way to load async data on initState method? 예를 들어 API를 처음 시작할 때 불러온다든가 (물론.. 함수로 빼주면 되긴하지만..) 할 때에 initState 안에서 async, await를 사용하고 싶을 때가 있을 것이다. 하지만 initState에는 async, await를 사용할 수 없기 때문에 다른 방법을 찾아야 하는데 그것이 가능하도록 하는 방법을 이번 주제로 다루려고 한다. 첫 번째 방법! : WidgetsBinding.instance.addPostFrameCallback() + Future 함수 코드로 살펴보자! (위에서도 언급했지만 함수를 따로 만들어서 할 수 있는 방법이 있다!) 아래에서는 setState를 사용하기 때문에 WidgetsBinding.instance.addPostFrameCallback 를 붙여주었다. 왜냐하면 b.. 더보기
[GRAMMAR] VoidCallback(), Function(x), ValueChanged<T> 위와 같은 함수들이 많이 헷갈렸기 때문에 이를 정리하기 위함이다. Function(x) Function의 경우에는 Parmeter를 넘겨줄 수도 있고, 리턴값 또한 받을 수 있다. 만약 부모로 부터 return 값을 받고 싶으면 Function(x)를 사용하면 된다. 예제를 살펴보면 확실하게 알 수 있다. import 'package:flutter/material.dart'; import 'count.dart'; class CounterPage extends StatefulWidget { _CounterPageState createState() => _CounterPageState(); } class _CounterPageState extends State { int count = 0; @override.. 더보기
[GRAMMAR] as, parse, to as TYPE (ex. as Map, as Pizza..) as는 다른 타입으로 바꿔주는 문법인데 클래스를 다운그레이드 시킬 때 많이 사용한다. type.parse(string) parse는 String 변수를 int 또는 double 등의 정수형 타입으로 바꿀 때 자주 사용한다. toInt, toString, toDouble .. to(TYPE)은 형 변환할 때에 가장 많이 사용하고 유용하다. 더보기
[GETX] BottomSheet 높이 변경하는 방법 Getx BottomSheet의 높이 Default는 화면 높이의 절반이라서 더 늘리고 싶다면 1. builder 사용 2. isScrollControlled: true [Link] - 🔗 https://stackoverflow.com/questions/48968176/how-do-you-adjust-the-height-and-borderradius-of-a-bottomsheet-in-flutter How do you adjust the height and borderRadius of a BottomSheet in Flutter? I'm probably missing something obvious here, but my BottomSheet only takes up the bottom half the .. 더보기
[Widget] CheckBox CheckBox Widget 1. Property 정리 shape : CheckBox의 Shape을 지정할 수 있다. shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(3), ), side: CheckBox의 border 지정할 수 있다. side: const BorderSide(color: Colors.black,), Example Checkbox( value: true, onChanged: (_) {}, // Background color of your checkbox if selected activeColor: Colors.deepOrange, // Color of your check mark checkColor: Colors.b.. 더보기
[PAKAGE] SharedPreference로 Login 정보 기억하기! [Link] - 🔗 https://lawrey.medium.com/flutter-local-storage-ac2eaf1194be Flutter: Local Storage Welcome to another part of my Flutter tutorials. As I am on a journey in exploring more about Flutter, I will be penning down useful… lawrey.medium.com - 🔗 https://stackoverflow.com/questions/54377188/how-to-use-shared-preferences-to-keep-user-logged-in-flutter How to use shared preferences to keep use.. 더보기
[PAKAGE] 유용한 PAKAGE 모음집 1. round check box - CheckBox를 custom 해서 사용할 수 있는 Pakage 이다. 🔗 https://pub.dev/packages/roundcheckbox roundcheckbox | Flutter Package Package to make easier the proccess of creating a round circle box. The component created is fully customizable to your needs. pub.dev 더보기
[ERROR] TextField, TextFormField PrefixIcon, SuffixIcon 사이즈 줄이기 해결 방법 Constranints property를 주면 된다!! TextField( decoration: InputDecoration( // choose any icon of your choice here prefixIcon: Icon(Icons.person), // set the prefix icon constraints prefixIconConstraints: BoxConstraints( minWidth: 25, minHeight: 25, ), ), ), [Link] - 🔗 https://stackoverflow.com/questions/61648677/how-to-reduce-padding-on-prefixicon-on-textfield How to reduce padding on prefixIc.. 더보기