• 카테고리

    질문 & 답변
  • 세부 분야

    모바일 앱 개발

  • 해결 여부

    미해결

(랜덤숫자) backgroundColor: PRIMARY_COLOR 오류

23.11.12 17:30 작성 23.11.12 19:15 수정 조회수 282

0

 

color.dart에

import 'package:flutter/material.dart';

const Color PRIMARY_COLOR = Color(0xFF2D2D33);
const Color RED_COLOR = Color(0xFFEA4955);
const Color BLUE_COLOR = Color(0xFF549FBF);

한 뒤에

return Scaffold(
  backgroundColor: PRIMARY_COLOR,
  body: SafeArea(

라고 backgroundColor: PRIMARY_COLOR,

넣자마자 오류가 납니다..

자동완성도 당연히 안되고요.

아무리 봐도 똑같이 했는데 이유를 모르겠어서요ㅜ

 

Performing hot restart...
Syncing files to device SM G991N...
lib/screen/home_screen.dart:14:24: Error: The getter 'PRIMARY_COLOR' isn't defined for the class '_HomeScreenState'.
 - '_HomeScreenState' is from 'package:random_number/screen/home_screen.dart' ('lib/screen/home_screen.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'PRIMARY_COLOR'.
      backgroundColor: PRIMARY_COLOR,
                       ^^^^^^^^^^^^^
Restarted application in 561ms.

답변 2

·

답변을 작성해보세요.

0

박정인님의 프로필

박정인

질문자

2023.11.12

해결되었습니다 감사합니다

0

안녕하세요!

PRIMARY_COLOR isn't defined -> PRIMARY_COLOR는 정의되지 않았다.

불러오기를 잊으신 것 같습니다.

import '색상 정의한 파일 경로';

위 코드를 추가해서 PRIMARY_COLOR 변수를 불러오기 해주세요.

감사합니다!