Your Flutter app works on the emulator. You install it on your real phone for the FYP demo, hit login, and get Connection refused or a Dio timeout. This fails for almost every student the first time, and the reason is simple: on a physical device, localhost is the phone itself β not your laptop.
Here is the fix that works, step by step.
Why the emulator tricks you
Android emulator: 10.0.2.2 points back to your laptop's localhost.
Physical device: 10.0.2.2 means nothing. 127.0.0.1 / localhost points to the phone.
So the same base URL that worked in the emulator can never work on a real device.
Step 1: Put the phone and laptop on the same Wi-Fi
Both devices must be on the same network. University Wi-Fi often blocks device-to-device traffic (client isolation) β if the steps below fail on campus Wi-Fi, use your phone's hotspot and connect the laptop to it instead.β¦