SocketException: OS Error: Connection refused, errno = 111

I got this weird error when developing flutter app in windows. I have set my local apache as my API server. When I tested my API in Postman, everything is okay. Error appears when I tested API on my app with emulator.

Turn out, the problem is from emulator. Android emulator can’t communicate with 127.0.0.01 or localhost. The solution is just change localhost to 10.0.2.2. This IP is special alias to your host loopback interface.

You can read more about this in this docs. –> https://developer.android.com/studio/run/emulator-networking

Login page template in Flutter

One of the most common thing I made in mobile development is login page. This project is boilerplate, template, or whatever you called, of basic login page. Made with Flutter.

It has standard 2 fields, username and password with toggle which can be clicked to show/hide password.

One of the problem I got as a flutter beginner is bottom overflowed by xx pixels. This problem would appear when virtual keyboard needs to be showed. Keyboard take half of our screen, if you done your layout wrong (like page that take more than half of screen), you will got bottom overflowed error.

The solution is use SingleChildScrollView in the top widget. So, when you got this error, you can scroll through our overflowed part of the page.

This project is on github –> https://github.com/rifai/flutter-login-page

Using ADB through WIFI for Android Development

Most of the time, I use emulator for android development. But, using emulator can eat my memory and slowing down my development. Doesn’t help that the fact that Android Studio also take most of my desktop resource.

Real device deployment is way to go. But, sometimes dealing with USB cable is not pleasant experience. So, the solution is using WiFi to connect with my device.

Continue reading Using ADB through WIFI for Android Development