Rx<User>() missing argument – Flutter / GetX

While using a GetxController on a class, and using Rx to get a FirebaseUser, I'm being shown an error, that I'm missing a positional argument

class AuthController extends GetxController {
  FirebaseAuth _auth = FirebaseAuth.instance;
  Rx<User> _firebaseUser = Rx<User>();
  User get user => _firebaseUser.value;

Here on this Rx<User>() which is from package:firebase_auth/firebase_auth.dart, I get the error :

1 positional argument(s) expected, but 0 found. Try adding the missing arguments.dartnot_enough_positional_arguments

After launching the emulator, I get this more detailed error :

lib/core/controllers/auth_controller.dart:9:36: Error: Too few positional arguments: 1 required, 0 given. Rx _firebaseUser = Rx();

../../../snap/flutter/common/flutter/.pub-cache/hosted/pub.dartlang.org/get-4.1.3/lib/get_rx/src/rx_types/rx_core/rx_impl.dart:324:3: Context: Found this candidate, but the arguments don't match. Rx(T initial) : super(initial);

I can't find what I'm supposed to add here, and every tutorial I saw, didn't specify any argument here. Anyone knows the problem ?



Read more here: https://stackoverflow.com/questions/67006885/rxuser-missing-argument-flutter-getx

Content Attribution

This content was originally published by SnowYou at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: