MOTOSHARE šŸš—šŸļø
Turning Idle Vehicles into Shared Rides & Earnings

From Idle to Income. From Parked to Purpose.
Earn by Sharing, Ride by Renting.
Where Owners Earn, Riders Move.
Owners Earn. Riders Move. Motoshare Connects.

With Motoshare, every parked vehicle finds a purpose. Owners earn. Renters ride.
šŸš€ Everyone wins.

Start Your Journey with Motoshare

Migrate your Flutter App to Flutter Web

If you find yourself intrigued by the possibilities of harnessing Flutter’s web app capabilities to launch your impressive Flutter application on the web, you’ve come to the perfect spot! Here at Nuclei, we’re boldly expanding our horizons and enhancing our fintech products by embracing the online

In prior iterations of Flutter, it was essential to import an external package called “flutter_web” to enable web functionality. This often resulted in a multitude of challenges. However, in the latest iterations of Flutter, the Flutter web project has been seamlessly integrated into the core Flutter project. Consequently, the impressive Flutter features you’ve harnessed to develop your exceptional app now seamlessly extend to the web with only minor adjustments needed. This article is dedicated to assisting you in the process of adapting your Flutter application to ensure its optimal performance on the web, while also providing guidance on configuring the appropriate port and hostname for your web application

  • First , we gotta make sure that we are either on the flutter `beta` channel or the master channel.
  • Lets open a terminal and switch to the beta channel 
flutter channel beta
flutter upgrade

Then we enable the support for web by adding into flutter’s configuration :

flutter config --enable-web
  • To get a list of all the available config options , just enter
    flutter config -h command.

If the web support was successful , you should see 2 devices listed when you runĀ flutter devicesĀ one is theĀ ChromeĀ device and another isĀ Web ServerĀ device.

flutter devices
2 connected device:
Chrome • chrome • web-javascript • Google Chrome 78.0.3904.108
Web Server • web-server • web-javascript • Flutter Tools

You can run your app directly on chrome by selecting the chrome device in your IDE before you run the app or use the following command

flutter run -d chrome
If you want to run it from some external web browser client or something else , it makes sense to just run the web server in which case you would do :
flutter run -d web-server

Well , if you get errors when building your app which complains that it’s not a web app, you just need to run the flutter create command on your project folder. Open the root of your project folder in a terminal and run :





flutter create .

[ There might also be a need to run it with theĀ --orgĀ option sometimes :Ā flutter create . --org com.exampleappĀ . Also make sure that your project folder name is made of only lower case letters and underscore]

Specify custom port and hostname :

Your app by default runs on localhost ( 127.0.0.1 ) which means you can’t access it from any other device on your network. If also uses a random port every time you run your app which is not what you want most of the time.
So , let’s fix this.

  • Set the port using the --web-port option and set a globally accessible hostname ( 0.0.0.0 ) using the --web-hostname option like so when you run your app :
flutter run -d chrome --web-port 55555 --web-hostname 0.0.0.0

Now you can access your web app by opening any web browser in any of your devices in your local network by entering the following address :

http://<your-ip-address>:55555
http://192.168.0.100:55555

If you are running the web app from your IDE (Android studio or VScode) , you can specify the port and hostname by specifying theĀ additional argumentsĀ option on Android Studio like so inside theĀ Run Configurations

If you are using VSCode šŸŽŠ , then you can set it in theĀ launch.jsonĀ options.

{
	"name": "Flutter",
	"request": "launch",
	"type": "dart",
	"args": ["--web-port", "55555" , "--web-hostname","0.0.0.0"]
}

Build and DEPLOY ! ! !

Now that you have converted your app into a web app , its time to build it and deploy it on free static web hosting services likeĀ netlify.comĀ orĀ surge.shĀ . To build your web app , run the following command in your project.

 flutter build web

This will create theĀ build/webĀ folder which you can deploy later.

Related Posts

Master GitLab for DevOps Excellence in the Netherlands

The Netherlands is rapidly becoming a European leader in digital innovation, with organizations across major cities integrating GitLab into their development workflows. From Amsterdam’s financial technology centers…

Master Git for Career Growth: Expert Program in Pune

In Pune’s rapidly evolving technology sector, Git has become an indispensable tool for developers, DevOps engineers, and IT professionals. The city’s expanding tech corridors—from established IT parks…

Master Git for Career Growth: Professional Version Control Training in Mumbai

In Mumbai’s dynamic technology sector, Git proficiency has become non-negotiable for developers, DevOps engineers, and IT professionals. As companies accelerate their digital transformation journeys, the ability to…

Mastering Git: Navigating Version Control in Kolkata’s Tech Hub

In Kolkata’s dynamic technology sector, Git proficiency has become the cornerstone of modern software development. As West Bengal’s capital continues to drive digital innovation, expertise in version…

Mastering Version Control: Your Guide to Git Excellence in Hyderabad

In Hyderabad’s thriving technology ecosystem, Git proficiency has become the essential skill that separates exceptional developers from the rest. As India’s emerging IT capital continues to establish…

Mastering Git: Navigating Version Control in Chennai’s Tech Hub In Chennai’s dynamic technology sector, Git proficiency has become the cornerstone of modern software development. As India’s southern…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x