본문 바로가기

개발/코딩오류모음

can't define a const constructor for a class with non-final fields 해결방법

class People extends StatelessWidget {
  const People({Key? key}) : super(key: key);
  var currentUser = FirebaseAuth.instance.currentUser!.uid;

  void callChatScreen(String name, String uid){

  }
class People extends StatelessWidget {
   People({Key? key}) : super(key: key);
  var currentUser = FirebaseAuth.instance.currentUser!.uid;

  void callChatScreen(String name, String uid){

  }

두 번째 줄에 있는 const 제거해보기

 

참고 출처 : https://flutterhq.com/questions-and-answers/1317/cant-define-the-const-constructor-because-the-field-currentuser-is-initialized-with-a-non-constant-value

'개발 > 코딩오류모음' 카테고리의 다른 글

flutter 참고 링크 / boxdecoration, widget, stack  (3) 2022.06.06