即使我控制了它,也会出现 null 或空错误

Getting null or empty error even though i controlled it

虽然我用 if 语句控制它,但我收到“'Given string empty or null'”错误并且我的应用正在关闭。

fun kayitOl ( view : View) {


    val email =findViewById<EditText>(R.id.emailText).text
    val password  = findViewById<EditText>(R.id.passwordText).text

        if (email != null && password != null ) {
            auth.createUserWithEmailAndPassword(email.toString(), password.toString())
                .addOnCompleteListener(this) { task ->
                    if (task.isSuccessful) {
                        val intent = Intent(this, haber_akisi::class.java)
                        startActivity(intent)
                        finish()

                    }
                }.addOnFailureListener { exception ->
                    Toast.makeText(this, exception.localizedMessage, Toast.LENGTH_LONG).show()
                }

        }else {
            Toast.makeText(this,"Lütfen E-mail ve Password alanlarını doldurunuz",Toast.LENGTH_LONG).show()
        }



}

您只检查 null,但不检查空字符串 ""

您可以使用 email.isEmpty() 或更好的 email.isBlank() 更改您的检查以检查 " "

等字符串