Home > front end >  How to initialize GetX that is using a class
How to initialize GetX that is using a class

Time:09-23

I have a Question class.

class Question {
  String questionCatNum;
  int questionNumber;
  Question({
    required this.questionCatNum,
    required this.questionNumber,
  });

  factory Question.fromFirestore(
      DocumentSnapshot<Map<String, dynamic>> snapshot) {
    Map data = snapshot.data()!;

    return Question(
      questionCatNum: data['questionCatNum'],
      questionNumber: data['questionNumber'],
    );
  }
}

How can I initialize it using Getx. I tried below but it is error.

RxList<Question> questionsList = [].obs;

CodePudding user response:

Use this

RxList<Question> questionsList = RxList<Question>([]);

CodePudding user response:

Use it as

RxList<Question> questionsList = <Question>[].obs;

  • Related