플러터7 [Flutter] Unexpected character (at character) 에러 메시지 Unexpected character (at character) Error in Flutter class TestVo { String? name; String? startHr; String? endHr; double? amt; TestVo.fromJson(json) { name = json['name']; startHr = json['start_hr']; endHr = json['end_hr']; amt = json['amt']; } @override String toString() { return { 'name': name, 'startHr': startHr, 'endHr': endHr, 'amt': amt }.toString(); } } void main() { TestVo vo = Te.. 2022. 3. 15. [Flutter] The method ‘+’ can’t be unconditionally invoked bacause the receiver can be ‘null’ 에러 메시지 에러 원인 null-satefy를 적용한 dart 문법에서 연산자 += 등 연산자를 줄인 형식이 허용되지 않아 발생됨 해결 방법 /// BASAL 총 값 if(basalList!.length > 0) { basalList!.forEach((e) { double value = e.basalAmt as double; this.totBasalValue = this.totBasalValue !+ value; }); } 값을 받을 변수를 초기화한 후 필요한 연산자를 이용해 값을 대입 아래와 같이 적용 후 사용하기 double num1 = 10; double num2 = 20; double? tot; tot += num1; // 사용 X tot += num2 // 사용 X tot = tot !+ num.. 2022. 3. 8. [Flutter] The return type ‘num’ isn’t a ‘T’, as required by the closure’s context. 에러 해당 코드 /// 공통 피커의 아이템 값 목록 생성 List generatePickerValues( {required T start, required T end, num interval = 1, int decimalPoint = 2}) { assert(start != end); assert(interval > 0); correctionValue(num value) => floatingPointErrorCorrectionValue(value, decimalPoint: decimalPoint); final range = correctionValue(end - start); final step = range.abs() ~/ interval; return List.generate(step + 1, (i) .. 2022. 2. 23. [Flutter] The expression has a type of ‘void’ so its value can’t be used. 에러 이유 VoidCallback 함수에 async / await 사용하려고 해서 에러가 남. dart 버전 2.0.4 버전에서는 VoidCallback 메소드를 사용해도 정상적으로 사용이 됐지만 dart 2.12 버전부터는 AsyncCallback 메소드를 이용해야 한다. 에러 해결 AsyncCallback 함수를 이용해 async / await가 필요한 메소드에 사용해준다. class OneButtonWidget extends StatefulWidget { final String text; final AsyncCallback onPressed; final EdgeInsets margin; final Color fillColor; final Color highlightColor; const OneBut.. 2022. 2. 16. 이전 1 2 다음