Errors I encountered as a Flutter beginner

Image source: thedroidsonroids

Introduction

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.

Error 1: flutter command not found

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

Error 2: Compiler cannot run without a compiler context

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

Internal problem: Compiler cannot run without a compiler context.Tip: Are calls to the compiler wrapped in CompilerContext.runInContext?#0      CompilerContext.current(package:front_end/src/fasta/compiler_context.dart:111:7)#1      internalProblem (package:front_end/src/fasta/problems.dart:45:25)#2      StackListener.checkEmpty(package:front_end/src/fasta/source/stack_listener.dart:184:7)<asynchronous suspension>
.
.
.
(dart:isolate/runtime/libisolate_patch.dart:172:5)Application finished.
import './home_page.dart';; //right here, double semicolon!!

Error 3: No Directionality widget found.

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.

import 'package:flutter/material.dart';void main() => runApp(MyApp());class MyApp extends StatelessWidget {  @override
Widget build(BuildContext context) {
return Container(
child: Center(child: Text('my first app'))
);
}
}
flutter: ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
flutter: The following assertion was thrown building Text("my first app", dependencies: [DefaultTextStyle]):
flutter: No Directionality widget found.
flutter: RichText widgets require a Directionality widget ancestor.
flutter: The specific widget that could not find a Directionality ancestor was:
flutter: RichText(softWrap: wrapping at box width, maxLines: unlimited, text: "my first app")
Text('my first app', textDirection: TextDirection.ltr)

Tech enthusiast, Frontend Developer, Accessibility Advocate, MDE @Cloudinary. Creator of explore-a11y.netlify.app/ My motto — ‘Choose RIGHT over easy, always!’