Late variable problem & instance member 'user' can't be accessed in an initializer

301 views
Skip to first unread message

Alvaro Gonzalez Rico

unread,
May 20, 2021, 11:01:00 AM5/20/21
to Flutter Development (flutter-dev)
Hello! I have been trying to answer a message on the discussion called "Instance member 'user' can't be accessed in an initializer", but my response keeps getting deleted. Do you know why that happens?

Regarding the problem, when I use the example from the website you gave me, I get an error message for late that says "Unexpected text 'late'. Try removing the text." I do not understand why I cannot use (it gives me errors) the late variable in my code or in this mock example. 

Jack Sun

unread,
May 20, 2021, 12:09:13 PM5/20/21
to Alvaro Gonzalez Rico, Flutter Development (flutter-dev)
try 
'''
environment: 
    sdk: ">=2.12.0 <3.0.0"
'''

in your pubspec.yaml

On Thu, May 20, 2021 at 11:01 AM Alvaro Gonzalez Rico <ajgonza...@gmail.com> wrote:
Hello! I have been trying to answer a message on the discussion called "Instance member 'user' can't be accessed in an initializer", but my response keeps getting deleted. Do you know why that happens?

Regarding the problem, when I use the example from the website you gave me, I get an error message for late that says "Unexpected text 'late'. Try removing the text." I do not understand why I cannot use (it gives me errors) the late variable in my code or in this mock example. 

--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/196a0586-8841-47c5-b036-371a234cabb6n%40googlegroups.com.

Alvaro Gonzalez Rico

unread,
May 20, 2021, 12:43:57 PM5/20/21
to Flutter Development (flutter-dev)
Hello! Thanks. I currenly have "environment: sdk: ">=2.7.0 <3.0.0"" . How would changing to that environment solve the issue?

Jack Sun

unread,
May 20, 2021, 1:03:25 PM5/20/21
to Alvaro Gonzalez Rico, Flutter Development (flutter-dev)

Alvaro Gonzalez Rico

unread,
May 20, 2021, 2:37:25 PM5/20/21
to Flutter Development (flutter-dev)
Hello! So just to double check: in order for me to use late I have to migrate my whole code to null safety? If so, is there another way to solve my issue by using something that is not late? Also, do you think it is worthwhile to migrate to null safety? Thanks
Reply all
Reply to author
Forward
0 new messages