Swap Function in Kotlin

Posted by Andre Scott | Updated on | Kotlin


Swap Function in Kotlin. No need a swap function in Kotlin at all. you can use the existing also function, for example:

Static initialisation block in Kotlin

Posted by Andre Scott | Updated on | Kotlin


Static initialisation block in Kotlin. From some point of view, companion objects in Kotlin are equivalent to static parts of Java classes. Particularly, they are initialized before class’ first usage, and this lets you use …

How to access Activity.this in Kotlin?

Posted by Andre Scott | Updated on | Kotlin


Want to access Activity.this in Kotlin? You can get a reference to your MainActivity object in Kotlin by using a qualified this. e.g.:

How to define multiple variable let in Kotlin?

Posted by Andre Scott | Updated on | Kotlin


Want to define multiple variable let in Kotlin? If interested here are two of my functions for solving this. Usage:

Static extension methods in Kotlin

Posted by Andre Scott | Updated on | Kotlin


Static extension methods in Kotlin. To achieve Uber.doMagic(context), you can write an extension to the companion object of Uber (the companion object declaration is required):

How to implement Builder pattern in Kotlin?

Posted by Andre Scott | Updated on | Kotlin


In you want to implement Builder pattern in Kotlin? I have seen many examples that declare extra funs as builders. I personally like this approach. Save effort to write builders. I have not yet found …

How to call a method after a delay in Android?

Posted by Andre Scott | Updated on | Android Kotlin


Want to call a method after a delay in Android? Use the below example code using Java and Kotlin. Kotlin example: Java example:

How to validate dropdown in flutter?

Posted by Andre Scott | Updated on | Flutter


Want to validate dropdown in flutter? Try using DropdownButtonFormField wrapping inside Form

How to rotate something 15 degrees in Flutter?

Posted by Andre Scott | Updated on | Flutter


If you want to rotate something 15 degrees in Flutter? In mobile apps, I think it’s kind of rare to have things start out rotated 15 degrees and just stay there forever. So that may …

How to set the height of the AppBar in Flutter?

Posted by Andre Scott | Updated on | Flutter


Want to set the height of the AppBar in Flutter? You can use PreferredSize class PreferredSize class: This widget does not impose any constraints on its child, and it doesn’t affect the child’s layout in …

How to change Android minSdkVersion in flutter project?

Posted by Andre Scott | Updated on | Flutter


Want to change Android minSdkVersion in flutter project? It is indeed possible to increase minSdkVersion, but it took me way too much time to find it out because google searches mostly yields as result discussions …