Search code examples
flutterflutter-getx

The member 'value' can only be used within instance members of subclasses of 'package:get/get_rx/src/rx_types/rx_iterables/rx_list.dart'


I'm using GetX for my project.

I have a little warning with RxList in GetX.

How do I fix this warning?

warning

This is my code:

var questionListItems = RxList<QuestionLookupResponse>();
// ....
Future<void> onInit() async {
  if (questionListItems.value.isNotEmpty) { // <--- Warning
    questionListItems.value.clear(); // <--- Warning
  }
}

Solution

  • Remove .value. It work. Because Rxlist can be accesses without .value. So... You can use Rxlist directly like list