inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

Flutter로 만드는 LLM 챗봇 (feat. Gemini)

1.2 강의자료 (GitHub 소스코드, Notion 문서, Figma 디자인)

에러가 생겨서

90

cdway

작성한 질문수 23

0

소스대로 했는데

에러가 생기네요
78, 79 번째줄 text 에서 에러입니다.

에러 메세지는

Running Gradle task 'assembleDebug'...
lib/chat_page.dart:78:63: Error: The getter 'text' isn't defined for the class 'Part'.
 - 'Part' is from 'package:flutter_gemini/src/models/part/part.dart' ('/C:/Users/userpc/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_gemini-3.0.0/lib/src/models/part/part.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'.
                    ? HumanMessage(content: chat.parts?.first.text ?? '')
                                                              ^^^^
lib/chat_page.dart:79:60: Error: The getter 'text' isn't defined for the class 'Part'.
 - 'Part' is from 'package:flutter_gemini/src/models/part/part.dart' ('/C:/Users/userpc/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_gemini-3.0.0/lib/src/models/part/part.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'text'.
                    : AIMessage(content: chat.parts?.first.text ?? '');
                                                           ^^^^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 4s
Exception: Gradle task assembleDebug failed with exit code 1

혹시

25, 34 번째줄 Parts 에 안쓴다는 줄 쳐졌는데

관계가 있나요

image.png

 

 

flutter 챗봇 gemini 인공지능(ai)

답변 1

0

제이쓴

안녕하세요! 질문으로 올려주셔서 감사합니다.

디버깅을 해보니 flutter_gemini가 버전업이 되면서, 사용법이 바뀌었고, 와중에 freezed를 활용한 타입선언에는 에러가 있네요. 아래와 같이 변경해서 사용해주시면 됩니다.

// setState해서 UI를 변경하는 부분
      setState(() {
        chatList = [
          ...chatList,
          // Content(role: 'model', parts: [Parts(text: value?.output)]) //기존 2.x 버전
          Content(role: 'model', parts: [Part.text(value?.output ?? '')]) // 3.x 버전
        ];
      });

 

그리고 채팅 내역을 보여주는 부분은 type casting을 해줘야합니다.

itemBuilder: (context, index) {
                final chat = chatList[index];
                Widget messageWidget = chat.role == 'user'
                    ? HumanMessage(content: chat.parts?.first is TextPart ? (chat.parts?.first as TextPart).text : '')
                    : AIMessage(content: chat.parts?.first is TextPart ? (chat.parts?.first as TextPart).text : '');
                return messageWidget;
              },

덕분에 저도 강의자료를 업데이트했는데요, 빠른시일내에 촬영해서 내용을 수정해야 할 것 같습니다

감사합니다!

13. (App 2) 기본기 훈련 에서

0

4

1

유튜브는 4일전에도 영상 올라왔던데, 이 강의는 언제쯤 ㅜㅜ

1

9

1

챌린지 시작일 문의

0

7

0

2. 어떤 도구를 사용하는 것이 가장 유리할까? 강의 중

0

12

1

화면 깜박임 현상

0

12

1

앱키와 씨크릿 복사 붙여넣기

0

9

1

쉬운 내용 스킵

0

7

0

줄바꿈 시 \ 필수인가요?

0

10

2

11차시 Antigravity IDE 설치 후

0

14

1

2605 이후 최신 클로드코드 강의 추가 부탁드립니다.

0

9

2

처음 에이전트 설정을 잘못 했을 경우 수정 하는 방법

0

10

1

5,6,7,8 내용이 없어요

0

13

1

커리큘럼 문서 제공받을 수 있을까요?

0

17

1

[13번 강의] ChatInterface에 PDF 렌더링이 안되는 이슈 공유

0

11

1

systemd 셋팅

0

12

1

에이전트 에러

0

17

1

커스텀 에이전트 생성하기

0

10

1

강의 잘 들었습니다만 부탁이 하나 있어서요..

0

14

2

롱폼 영상 강의도 있으신가요? 도움이 많이 되었습니다.

1

12

1

outputStyle 설정하는데 어디서 문제일까요?

0

19

3

〈클로드 코드와 멀티 에이전트로 내 일상을 모두 자동화하기〉 강의 전자책 관련 문의

0

9

1

또다른 오버플로우

0

85

2

오버플로우

0

103

2

실전강의는 무엇인가요?

1

125

1