I am getting error “cmdline-tools component is missing” after installing Flutter and Android Studio… I added the Android SDK. How can I solve them?

The solution for me was opening Android Studio and going to SDK Manager, switch to the SDK Tools tab and check Android SDK Command-line Tools (latest). Don’t forget to add to your PATH the tools and platform-tools folder that are inside your SDK.

What is the difference between functions and classes to create reusable widgets?

Edit: The Flutter team has now taken an official stance on the matter and stated that classes are preferable. See https://www.youtube.com/watch?v=IOyq-eTRhvo TL;DR: Prefer using classes over functions to make reusable widget-tree. EDIT: To make up for some misunderstanding: This is not about functions causing problems, but classes solving some. Flutter wouldn’t have StatelessWidget if a … Read more

Flutter: how to prevent device orientation changes and force portrait?

Import package:flutter/services.dart, then Put the SystemChrome.setPreferredOrientations inside the Widget build() method. Example: class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setPreferredOrientations([ DeviceOrientation.portraitUp, DeviceOrientation.portraitDown, ]); return new MaterialApp(…); } } Update This solution mightn’t work for some IOS devices as mentioned in the updated flutter documentation on Oct 2019. They Advise to fixed the … Read more

How to use conditional statement within child attribute of a Flutter Widget (Center Widget)

Actually you can use if/else and switch and any other statement inline in dart / flutter. Use an immediate anonymous function class StatmentExample extends StatelessWidget { Widget build(BuildContext context) { return Text((() { if(true){ return “tis true”;} return “anything but true”; })()); } } ie wrap your statements in a function (() { // your … Read more

Sizing elements to percentage of screen width/height

This is a supplemental answer showing the implementation of a couple of the solutions mentioned. FractionallySizedBox If you have a single widget you can use a FractionallySizedBox widget to specify a percentage of the available space to fill. Here the green Container is set to fill 70% of the available width and 30% of the … Read more

Dart SDK is not configured

I had the same problem after importing a flutter project from git. These are the steps to solve the problem. File->Settings->Language & Framework->Flutter Choose flutter SDK path: the first time we install flutter, we choose the location where the flutter should be installed. Choose this location. Click OK and the android studio will refresh. Carry … Read more

flutter doctor –android-licenses gives a java error

Installing Android SDK Command-line tools from Android SDK Manager did the job for me. Open Tools > SDK Manager From the left choose, Appearance & Behavior > System Settings > Android SDK Select SDK Tools from the top menu Check Android SDK Command-line tools and click ‘apply’. Alternative to step #1: WINDOWS: File > Settings … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)