How to validate email address in Android with Kotlin?

With the below code we can validate email address in android.

import android.os.Bundle
import android.view.View
import android.widget.EditText
import android.widget.Toast
class MainActivity : AppCompatActivity() {
   private lateinit var editText: EditText
   private lateinit var email: String
   private val emailPattern = "[a-zA-Z0-9._-]+@[a-z]+\\.+[a-z]+"
   override fun onCreate(savedInstanceState: Bundle?) {
      title = "KotlinApp"
      editText = findViewById(
      email = editText.text.toString().trim()
   fun validateEmail(view: View?) {
      if (email.matches(emailPattern.toRegex())) {
         Toast.makeText(applicationContext, "Valid email address",
      } else {
         Toast.makeText(applicationContext, "Invalid email address",