Login button is not working on mobile wherease it's working properly on emulator, flutter

380

10.0.2.2 is ip address which will work only for your emulator, it's like 127.0.0.1 on computer.

When you want to access localhost from your phone, you have to find your pc's local ip address. You can read how to do it in this article: https://dev.to/tusharsadhwani/connecting-android-apps-to-localhost-simplified-57lm

Share:
380
TimeToCode
Author by

TimeToCode

Updated on December 22, 2022

Comments

  • TimeToCode
    TimeToCode over 1 year

    I have created an app which is working properly on emulator, successfully logged in, api's are working perfectly too. but when i run the app on mobile , my login button is not working.

    i have used 8000 port on backend and on api and 127.0.0.1 ip address.

    my login api looks like http://127.0.0.1:8000/login

    here are the logs when i enter username and password and click on login button .

    SocketException: OS Error: Connection refused, errno = 111, address = 127.0.0.1, port = 45304
    
    

    please help how can i fix it.

    • Faiizii Awan
      Faiizii Awan almost 3 years
      I don't think the problem with the text fields. please confirm, are you able to access your machine in your device?
  • TimeToCode
    TimeToCode almost 3 years
    hi, it's not working, when i do debugging it works, like when i click on login button it should go to dahsboard screen so when i run my project on debugging control goes to dashboard file after click on login button, but my phone is still on login screen