Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

View Flutter web on mobile

I am building a flutter web app, but I want it to behave differently on mobile and desktop. To test it, is it possible to run the web app on a phone's browser or in the browser of an emulator? Thanks

like image 334
Bennett567 Avatar asked Sep 12 '25 14:09

Bennett567


2 Answers

Yes, testing your code in a web browser while in production is possible. Here are steps to do that:

  • Connect your devices (your laptop and phone) to the same internet
  • Run the following code in the terminal of the opened project

t

flutter run -d web-server --web-port 8080 --web-hostname 0.0.0.0

Then, head to your mobile phone browser and type

HTTP://<your PC IP address>:8080

Testing in my phone browser

Testing in my Mac browser

like image 97
JAtoms Avatar answered Sep 14 '25 05:09

JAtoms


  1. You need to start your flutter web-app on a specific port

    flutter run -d web-server --web-port 5011

  2. Connect your device and verify if the device is connected properly

    adb devices

  3. adb port-forwarding

    adb reverse tcp:5011 tcp:5011

  4. Open Mobile Browser with http://localhost:5011/

after that, you can able to access that port on a mobile browser.

like image 28
rinkesh Avatar answered Sep 14 '25 03:09

rinkesh