inflearn logo
강의

Khóa học

Chia sẻ kiến thức

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

1. 2 Tài liệu bài giảng (Mã nguồn GitHub, tài liệu Notion, thiết kế Figma)

에러가 생겨서

102

cdway

23 câu hỏi đã được viết

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)

Câu trả lời 1

0

jasonkang

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

디버깅을 해보니 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;
              },

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

감사합니다!

설치의 필요성

0

9

1

실습 자료는 어디에 있나요?

0

9

0

MAGMA와 함께 개인 서비스도 같이 구축할때는 어떻게 세팅하는게 효율적인가요?

0

16

1

hermes dashboard : Failed to restart gateway

0

17

1

getOrCreate / Unique? 멱등 처리 질문

0

20

1

시작하기전에 질문 드립니다.

0

36

2

소리

0

22

1

수강인증 수료배지 링크가 만료되었습니다.

0

31

1

hermes slack 설정 문제?

0

41

1

"폴더를 찾을 수 없습니다." 라는 응답만 계속 나옵니다.

0

40

1

hermes memory setup

0

65

3

강의자료

1

39

2

output style이 안나와요

0

41

2

강의제목에 10/15일 삭제라고 나와있는데,

0

43

1

unit3.8 ready 입력 시 오류

0

46

4

강의 자료 질문

0

49

2

URL을 어디서 찾을수잇을까요?

0

45

2

교제 노션 복제 방법 문의

0

44

2

cowork파일을 다운로드 하려고 하는데, 더 많은 작업의 확장 프로그램에서 window가 없습니다.

0

41

3

output style은 뭘선택하나요?

0

39

1

agent team vs shrimp task manager

0

49

2

또다른 오버플로우

0

96

2

오버플로우

0

124

2

실전강의는 무엇인가요?

1

142

1