Displaying toast()

We love displaying toast! For displaying validation messages to the user, flashing an error message, and sometimes for debugging too.

And we know how many times we have missed using .show() methods. Every time we pass context setting up a duration. How about having a simple function that takes care of all of this. Yes! With Kotlin this is also true. Anko commons has functions displaying toast in an easy way.

With Anko you can display toast, for example:

    import org.jetbrains.anko.toast    toast(exception.message.toString())

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.