강의

멘토링

커뮤니티

Inflearn Community Q&A

jhscoup3968's profile image
jhscoup3968

asked

[Code Factory] [Intermediate] Flutter Real Practice! State Management, Cache Management, Code Generation, GoRouter, Authentication Logic, etc. Essential Skills to Become an Intermediate!

Introduction to the course

결제오류 입니다.

Written on

·

348

·

Edited

0

코드는 전혀 문제가 없는 것 같은데, 결제창으로 넘어가지를 않습니다.

코드를 보면 만약 resp 일때 OrderDoneScreen으로 넘어가도록 되어있는데, 그 resp 는 await ref.read(orderProvider.notifier).postOrder(); 이라고 했습니다.

그렇다면 이 resp가 이 상태가 아니라는 건데, 이걸 어떻게 확인을 하면 좋을까요?

에러의 이유로는 'type 'Null' is not a subtype of type 'String' in type cast' 라고 나옵니다.

저번에는 재설치 하면 넘어갔었는데, 이번에는 아무리 모든 코드를 검사해봐도 이유를 모르겠습니다 ㅠ

SizedBox(
  width: double.infinity,
  child: ElevatedButton(
    onPressed: () async {
      final resp =
          await ref.read(orderProvider.notifier).postOrder();

      if (resp) {
        context.goNamed(OrderDoneScreen.routeName);
      } else {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text(
              '결제 실패!',
            ),
          ),
        );
      }

 

flutter하이브리드-앱

Answer 2

0

jhscoup3968님의 프로필 이미지
jhscoup3968
Questioner

아 주의해서 다시 해보겠습니다.

0

codefactory님의 프로필 이미지
codefactory
Instructor

안녕하세요!

오류 메세지는 명확합니다.

String이 입력돼야하는 부분에서 null이 입력 됐다는데 에러 메세지를 잘 보시면 어디에서 에러가 나는지 확인 할 수 있습니다. 내가 작업한 파일중에 찾아보세요!

상당한 경우는 JsonSerializable등 데이터를 클래스 인스턴스로 변환하는 과정에서 특정 프로퍼티의 스펠링이 틀린 경우입니다.

감사합니다!

jhscoup3968's profile image
jhscoup3968

asked

Ask a question