Questions tagged [lateinit]
12 questions
21
votes
5 answers
How to know whether late init has been initialized in dart(flutter)?
I am fetching data from url in Flutter. I have a late init Map called tables. I am fetching data inside initState() function. When I first launch the app, I am getting LateInizialization error on the red screen. I want to detect whether late init is…

Sardorek Aminjonov
- 724
- 2
- 7
- 16
9
votes
5 answers
C# non-nullable field: Lateinit?
I am wondering how to use late-initialized class fields in C# with nullable reference types.
Imagine the following class:
public class PdfCreator {
private PdfDoc doc;
public void Create(FileInfo outputFile) {
doc = new…

Andi
- 3,234
- 4
- 32
- 37
2
votes
2 answers
When should we choose lateinit for an object ? Is it bad practice to make the binding as non-optional and lateinit?
I was declared a binding object in a fragment as lateinit var binding: EditInsuranceDialogBinding but a colleague said "This is a bad practice and Binding object should be Optional . "
So in the declaration will be instead like this: var binding:…

Imene Noomene
- 3,035
- 5
- 18
- 34
1
vote
1 answer
Late initialization of a Theme in Flutter
I'm trying to implement dark and light themes in my Flutter app. To do this, I'm using a ViewModel approach to notify the whole application when the theme changes. When a user changes the theme, I'm saving it using shared_preferences. When the…

vtomic85
- 590
- 1
- 11
- 32
1
vote
1 answer
Kotlin Autowired problems - lateinit (obv)
I'm relatively new to kotlin and I can't get my head around spring autowiring
kotlin.UninitializedPropertyAccessException: lateinit property applicationContext has not been initialized
I got the above error while running…

HellishHeat
- 2,280
- 4
- 31
- 37
0
votes
2 answers
Why is it not possible to use lateinit with Boolean in Kotlin?
Why is it not possible to use lateinit with Boolean in Kotlin? I tried it with the other primitive data types and it works fine!
Here is the code that I want to use:
object BankAccount {
lateinit var accountName: String
lateinit var…
user22210486
0
votes
1 answer
kotlin.UninitializedPropertyAccessException: lateinit property binding has not been initialized
my application is giving the below error that you mentioned above and it says there is an error on line 69, but you have tried all the solutions and could not fix it. You are new to programming and trying to learn, so you are asking for help from…

aybey
- 3
- 3
0
votes
1 answer
lateinit property mAdapter has not been initialized. How to solve this problem?
MainActivity.kt
class MainActivity : AppCompatActivity(), NewsItemclicked {
private lateinit var mAdapter: NewsListAdapter
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
…

Soudeep Ghosh
- 3
- 2
0
votes
1 answer
Why is the no lateinit block in Kotlin?
The following code is valid Kotlin code:
abstract class A {
protected lateinit var v: X
abstract fun f(): X
class SubA : A() {
override fun f(): X {
return SubX()
}
init {
v = f()
…

SMMH
- 310
- 1
- 13
0
votes
2 answers
lateinit property mClickListener has not been initialized Adapter kotlin
i make adaper onclick listener but somehow theres error message lateinit property mClickListener has not been initialized Adapter kotlin
variable on click
lateinit var mClickListener: ItemClickListener
base view holder
inner class…

Agam
- 23
- 9
0
votes
1 answer
"Lateinit property has not been initialized" error on a variable initialized in onCreateView
The app I'm developing has three classes. MainActivity (not important here), MyFragment and MyClass.
I have a lateinit List inside MyFragment - it is lateinit because it will be used by some methods. (I'm using kotlin synthetics by the way)
class…

relative_lay0ut
- 19
- 6
-1
votes
1 answer
Newbie Kotlin on Android MutableMap initialisation question
Stripped down to the bare essence, my problem is:
class MainActivity : AppCompatActivity() {
lateinit var testArray: Array
lateinit var testMap: MutableMap>>
override fun onCreate(savedInstanceState:…

Taqras
- 173
- 1
- 10