Errors I encountered as a Flutter beginner

Image source: thedroidsonroids


Hi everyone, today I will share some of the errors which I encountered while getting started with Flutter and how can we solve them. If you are already working with Flutter for sometime now, you might find the errors very naive and simple. But as a beginner in this new technology, with almost negligible prior experience in mobile development, it took time for me to research and fix these errors.

So it occurred to me, to create a list of the issues, to help anyone out there.

Versions used: Flutter 1.2.1 and Dart 2.1.2

Let’s get started…

I followed the flutter setup for mac OS from the official website here.

The first issue that hit me was while adding path for Flutter in the bash profile. You can find the guidelines for this here. I followed the steps as mentioned, but still got the error ‘flutter command not found’ in the terminal while running command flutter doctor

This was due to missing out the leading ‘/’ while setting the path in bash profile. So, if you are someone who is getting this error, please go and cross-check the path first before looking out for more advanced troubleshooting.

PFB sample path:
export PATH=”$PATH:/Users/anuradha.kumari/Documents/flutter/bin”

So, after fixing the first issue, I was all set to code my way through the first flutter app. I had two .dart files, main.dart and home_page.dart

And all I wanted was to set the home of my widget in main.dart file to be pointing to the widget as built from home_page.dart. So, I imported the home_page.dart file into the main.dart file and tried to hot reload the app. But alas! Only if life were that easy. Got the lengthy error in the terminal instead. Have a look:

To my good luck, I found the answer in the very first link of google search results. You can see it here

And the reason behind this seemingly long and complicated error message was use of double semicolons while importing my home_page.dart.

So, next time you run into such an issue, please double check for all your semi-colon usages. This is a compile time error and hence it also gets underlined in red, but when we are too busy finding issue in our code, we rarely look at the import statements (at least I did this mistake).

I was trying to work with widgets and I wanted to display a simple text in the center of the screen. But I did not want to use the MaterialApp widget for this. That’s it. Sounds simple, isn’t it.

To achieve that, I wrote below code:

I restarted the app, and got below error in the terminal:

This error is a good one I must admit, since it gives me a hint to a probable fix. I searched for error and got good answers with explanation here on stackoverflow.

The main reason here is that if we are not creating a MaterialApp widget (which provided the text direction as LTR by default), we need to specify explicitly the direction for Text widgets. Or alternatively, wrap them into the Directionality widget. In both cases, we will need to specify the textDirection property. My choice for fixing this issue was to specify the textDirection for Text widget itself. It solved the issue right away.

These were the list of some issues which I hit into and felt like sharing with the broader audience so that it could help in easier debugging and troubleshooting.

As I continue to explore Flutter, let’s see what the future holds!

What issues did you face while learning Flutter? Do drop a comment if you feel like sharing.

Till then, happy learning, have a great day…

Tech enthusiast, Development Specialist @teammediaocean. Creator of My motto — ‘Choose RIGHT over easy, always!’

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store