dart30 Flutter 다트 다중 생성자, Dart Multiple Constructors 질문 다트에서 클래스에 여러 생성자를 만들 수 없는 것이 사실인가요? 내 Player 클래스에서 이 생성자가 있다면 Player(String name, int color) { this._color = color; this._name = name; } 그런 다음이 생성자를 추가하려고하면: Player(Player another) { this._color = another.getColor(); this._name = another.getName(); } 다음 오류가 발생합니다. 기본 생성자가 이미 정의되어 있습니다. 나는 필수가 아닌 인수를 가진 하나의 생성자를 만들어 우회하는 해결책을 찾고 있지 않습니다. 이를 해결하는 좋은 방법이 있나요? 답변 하나의 이름 없는 생성자만 가질 수 있지만, 추가 이름 있는.. 2023. 5. 28. Flutter 널 안전성 이후에는 'Function' 인수 유형이 'void Function()?' 매개 변수 유형에 할당될 수 없습니다., The argument type 'Function' can't be assigned to the parameter type 'void Function()?' after null safety 질문 저는 서랍에 다른 항목들을 만들고 싶어서, DrawerItems를 위한 별도의 파일을 만들고 생성자를 통해 데이터를 메인 파일로 전달하려고 합니다. 그러나 onPressed 함수에서 다음과 같은 오류가 발생합니다: "The argument type 'Function' can't be assigned to the parameter type 'void Function()'" class DrawerItem extends StatelessWidget { final String text; final Function onPressed; const DrawerItem({Key key, this.text, this.onPressed}) : super(key: key); @override Widget build(B.. 2023. 5. 26. Flutter 타임스탬프 변환하기, Converting timestamp 질문 나는 이 문제에 대한 해결책을 찾을 수 없었다. 나는 파이어베이스에서 데이터를 가져오고 그 중 하나의 필드는 다음과 같은 타임스탬프이다. -> 1522129071. 어떻게 날짜로 변환할 수 있을까? Swift 예제(작동함) : func readTimestamp(timestamp: Int) { let now = Date() let dateFormatter = DateFormatter() let date = Date(timeIntervalSince1970: Double(timestamp)) let components = Set([.second, .minute, .hour, .day, .weekOfMonth]) let diff = Calendar.current.dateComponents(component.. 2023. 5. 18. Flutter 플러터에서 입력이 이메일 주소인지 확인하는 방법은 어떻게 해야 하나요? [중복], How should I check if the input is an email address in Flutter? [duplicate] 질문 RegExp 문서에 따르면, 이메일을 확인하기 위해 Dart에서 어떤 메소드를 사용해야 하는지 알고 싶습니다. JavaScript (Perl 5) 정규식을 사용해야 합니다. : ECMA 명세. 답변 그에 대해 간단한 정규식이 꽤 잘 작동합니다. const String email = "tony@starkindustries.com" final bool emailValid = RegExp(r"^[a-zA-Z0-9.a-zA-Z0-9.!#$%&'*+-/=?^_`{|}~]+@[a-zA-Z0-9]+\.[a-zA-Z]+") .hasMatch(email); 2023. 5. 18. 이전 1 2 3 4 5 6 7 8 다음