본문 바로가기

분류 전체보기980

Flutter (Dart)에서 속성 값에 따라 객체 목록을 정렬합니다., Sort a list of objects in Flutter (Dart) by property value 질문 How to sort a list of objects by the alphabetical order of one of its properties (Not the name but the actual value the property holds)? 객체 목록을 그 속성의 알파벳 순서에 따라 정렬하는 방법(이름이 아니라 속성이 실제로 보유한 값)은 무엇인가요? 답변 List.sort에 비교 함수를 전달할 수 있습니다. (자세히 보기) someObjects.sort((a, b) => a.someProperty.compareTo(b.someProperty)); 2023. 5. 10.
Flutter 플러터에서 어떻게 프로그래밍 방식으로 앱을 종료하는지 알려주세요., Flutter how to programmatically exit the app 질문 Flutter 애플리케이션을 프로그래밍 방식으로 어떻게 닫을 수 있나요? 하나의 화면만 팝하려고 시도했지만 검은 화면이 나옵니다. 답변 아래는 Android와 iOS에서 모두 완벽하게 작동했습니다. dart:io에서 exit(0)을 사용했습니다. import 'dart:io'; @override Widget build(BuildContext context) { return new Scaffold( appBar: new AppBar( title: new Text(widget.title), ), body: new ... (...), floatingActionButton: new FloatingActionButton( onPressed: ()=> exit(0), tooltip: '앱 종료', child:.. 2023. 5. 10.
Flutter 플러터 모든 라우트 제거하기, Flutter remove all routes 질문 로그인 경로로 이동하고 Navigator에서 다른 모든 경로를 제거하는 로그아웃 버튼을 개발하고 싶습니다. 문서에는 RoutePredicate를 만드는 방법이나 모든 경로를 제거하는 함수가 없는 것 같습니다. 답변 저는 다음 코드를 사용하여이를 수행 할 수있었습니다 : Navigator.of(context) .pushNamedAndRemoveUntil('/login', (Route route) => false); 이곳의 비밀은 항상 false를 반환하는 RoutePredicate를 사용하는 것입니다. (Route route) => false. 이 상황에서는 새로운 /login 경로를 제외한 모든 경로를 제거합니다. 2023. 5. 10.
Flutter 버튼 너비를 부모와 일치시키는 방법은 무엇인가요?, How to make button width match parent? 질문 나는 match parent 레이아웃 너비에 너비를 설정하는 방법을 알고 싶습니다. new Container( width: 200.0, padding: const EdgeInsets.only(top: 16.0), child: new RaisedButton( child: new Text( "Submit", style: new TextStyle( color: Colors.white, ) ), colorBrightness: Brightness.dark, onPressed: () { _loginAttempt(context); }, color: Colors.blue, ), ), 나는 Expanded 위젯에 대해 약간 알고 있지만, Expanded는 양방향으로 뷰를 확장시키기 때문에 어떻게 해야할지 모릅니다... 2023. 5. 10.