The method 'getString' was called on null. Receiver: null Tried calling: getString("name")

I am having a error The method 'getString' was called on null. Receiver: null Tried calling: getString("name") I already instantiated

firebaseFirestore = FirebaseFirestore.instance;
  sharedPreferences = await SharedPreferences.getInstance();
class _HomePageState extends State<HomePage> {
  HomepageBloc _bloc;
  ScrollController _scrollController = ScrollController();
  TextEditingController _userNameSearchController = TextEditingController();
  String userName = sharedPreferences.getString(SharedPreferencesKey.name);
  String userToken = sharedPreferences.getString(SharedPreferencesKey.token);
  @override
  void initState() {
    super.initState();
    _bloc = HomepageBloc(userToken);
  }

  @override
  void dispose() {
    super.dispose();
    _bloc.dispose();
  }

I don't know why I am getting this error, it would be wonderful if this error can be solved



from Recent Questions - Stack Overflow https://ift.tt/38n2IJv
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation