본문 바로가기

분류 전체보기241

[Flutter] BottomSheet 확장하기 showModalBottomSheet( isScrollControlled: true, context: context, builder: (BuildContext bc) { return Wrap( children: [...] ) } ) isScrollControlled가 중요하다. 해당 속성을 주지 않으면 마진이 먹지 않는 경우가 있음. 2022. 4. 8.
[Flutter] Navigator.push() in Dialog 예를 들어 버튼을 하나 가진 Dialog가 있을 때 OK버튼을 누르면 다른 화면으로 이동하도록 처리를 해야 한다. 이런 상황에서 보통 람다함수를 받을 수 있도록 Dialog를 설계하여 버튼을 누르는 상황에서 함수를 실행할 것이다. 비슷한 처리를 하던 다른 부분에서 왜 동작이 정상적으로 이루어 졌는지 확인을 해보니 Delayed 처리가 되어 있었다. Future.delayed(const Duration(milliseconds: 1500, ), () { Navigator.of(context, rootNavigator: true).pop('dialog'); ... 중략 Navigator.push(context, MaterialPageRoute(builder: (context) => const newScreen.. 2022. 4. 7.
[Flutter] TextFormField 정리 final GlobalKey _formKey = GlobalKey(); FormKey를 선언하여 사용 영역 widget에 Form을 감싸고 key 속성으로 추가를 해둔다. 이러한 처리를 하는 이유는 나중에 전체 텍스트 필드에 대하여 error가 있는지 판단하기 위함이다. formKey쪽에서 이를 인식해서 쉽게 이용할 수 있다. 입력할 때 커서 색상, HighLight 색상을 바꾸려면 MaterialApp의 테마에서 해당 속성을 처리하면 된다. textSelectionTheme: const TextSelectionThemeData( cursorColor: Color.fromARGB(255, 255, 0, 255), selectionColor: Color.fromARGB(255, 185, 185, 185),.. 2022. 4. 6.
[Flutter] 스크린 하단에 Widget 배치 찾아보면 Column 안에 넣어서 정렬을 해가지고 .. 밑에 배치를 시키는 그런 방법이 많이 나오는데 내가 발견한 쉬운 방법은 Expanded 위젯을 사용하는 방법이다. Column( children: [ const Expanded( child: Center(child: null), ), // 위젯 자리 const Padding(padding: EdgeInsets.only(bottom: 32),), ], ) Column의 children에 하나씩 배치를 하는데 가장 하단까지 margin을 주기에는 무리가 있다. (기기마다 스크린 크기가 달라서 하드코딩으로는 문제가 생길 것이다.) 방법을 찾아보니 Expanded를 이용하여 자리를 차지하도록 하고 맨 밑에 원하는 만큼의 Padding을 주는 방법이 있어서 .. 2022. 4. 3.
[Flutter] 둥근 버튼 만들기 SizedBox( width: 80, height: 80, child: Container( decoration: BoxDecoration( border: Border.all( color: Colors.grey, width: 4), shape: BoxShape.circle, ), child: MaterialButton( onPressed: () { }, color: Colors.grey, child: Text("토익", style: const TextStyle(color: Colors.black, fontSize: 18), ), padding: const EdgeInsets.all(8), shape: const CircleBorder(), ) )​ Border 효과를 주고 싶다면 Container를 사용하.. 2022. 4. 3.
[Flutter] List<TextSpan> in ChangeNotifier ChangeNotifier 내부에서 데이터를 로드하고 List에 데이터를 채우는 형태를 가지고 있었는데 해당 데이터를 채우고 NotifyListeners()를 호출해줘도 갱신이 안 되었다. 값은 이미 바뀌어 있는 상태 RichText( text: TextSpan( style: const TextStyle( color: Colors.white, fontSize: 18, ), children: notifier.descDataList, // not working ), ) children: notifier.isQuizNotCorrect() ? notifier.descDataList : null, 이렇게 바꿔주니까 인식이 되기 시작한다. LiveData 개념에서도 특정 Observable 상태인 데이터가 바뀌어야.. 2022. 4. 2.
[Flutter] RichText 안드로이드에서 여러 텍스트들 사이에서 원하는 Style을 적용하고 싶은 경우에 Span을 사용한다. Flutter에서 이러한 처리를 하기 위해 RichText 위젯을 사용하는데 사용법은 이렇다. RichText( text: TextSpan( style: const TextStyle( color: Colors.white, fontSize: 18, ), children: [ const TextSpan(text: "정답은 "), TextSpan( text: "사과", style: const TextStyle( color: Colors.yellow, fontWeight: FontWeight.bold)), const TextSpan(text: "에요."), ], ); RichText로 감싸고 TextSpan을 넣.. 2022. 4. 2.
[Java] 학생 관리 프로그램 학교에서 자바 프로젝트를 만들어 제출하는 수행평가가 있어서 제출했던 것을 올린다. 실제 제출했던 파일 그대로 이고, C++ 스타일을 최대한 살려서 만들었다. 자바로 만든 학생 관리 프로그램 코드를 참고하고 싶다면 마음껏 이용해도 좋다. ​ 보고서나 ppt는 코드 이해를 위한 용도로만 써주시길 바랍니다. (사실 별거 없음) 2022. 4. 1.
[Java] for-each class Exam { public static void main(String[] args) { int a[] = new int[] {100, 200, 300}; char c[] = new char[] {'a', 'b', 'c', 'd'}; String str[] = new String[] {"hansei", "cyber", "security"}; int sum = 0; for(int k : a) sum += k; System.out.println(sum); for(char k : c) System.out.print(k + " "); for(String k : str) System.out.print(k + " "); } } 600 a b c d hansei cyber security 2022. 4. 1.
[Java] label class Exam { public static void main(String[] args) { label: for(int i = 0; i 2022. 4. 1.