https://git-scm.com/download/win
Most defaults for installation steps are OK. In the installation step "Adjusting your PATH environment", select "Git from the command line and also from 3rd-party software".
2. Install Flutter SDK from https://flutter.dev/docs/get-started/install
Place the files into a folder where u don't need admin permission such as your username folder (example C:\Users\<your_username>\flutter) , but if you're the admin that's fine. Here, we place flutter files into the folder:
C:\Android_dev\flutter
3. Update the flutter path to use flutter from any directory
Start > search "env" > Edit environment variables for your account > User variables > Add on a PATH: ";C:\Android_dev\flutter\bin" (use ";" to separate itself from the earlier existing paths)
4. Run "flutter doctor" to see what else is required to get Flutter up and running.
5. Install Android Studio from https://developer.android.com/studio
5. For Windows users, install Google USB Driver:
Android Studio > Configure > Settings > Sidebar(Android SDK) > "SDK Tools" tab > check "Google USB Driver" > OK
6. Install Platform Tools from https://developer.android.com/studio/releases/platform-tools
Place the files at C:\Android_dev\platform-tools\
Set path of Android SDK
- Android Studio > Settings > Android SDK > copy path of Android SDK Location
- Windows button > search "env" > Edit Environment Variables > User variables > Edit > insert variable "ANDROID_HOME" and value (paste path of Android SDK location here) > OK
7. SETUP YOUR ANDROID DEVICE
- Install your android device's device manager e.g. from the company website
- Go to your device's Settings > About Device > tap on "Build Number" 7-10 times. Enter lockscreen password > Go back to Settings > System & Updates > Developer Options > turn on "Developer Options" and "USB Debugging"
- Connect your device to computer via USB cable
7.1 How to ensure device is detected by Android Studio (in the future)
7.1.1 Ensure Android Studio is ON
7.1.2 Ensure device's software manager (e.g. Hisuite for Huawei) is ON
7.1.3 Plug device into USB cable -> choose Transfer Files (on the phone screen)
7.1.4 Android Studio should detect your device
8. Run "flutter devices". Your device should be connected.
9. Install Flutter plugin
Android Studio > Configure > Plugins > search for "flutter" > Install (both flutter and dart plugins) > Restart IDE
10. Create Android Emulator (to test Flutter apps)
Android Studio > Configure > AVD Manager (android virtual device) > Create virtual device > Category: Phone > Name: Nexus 6 > Next > Release Name: (android) PIE (less issues compared with (android) Q) (hit Download) > Next> Emulated performance: Graphics: Hardware GLES 2.0 (for faster rendering vs software) > Finish
11. There was a recommendation in the "Release Name" section to "enable VT-x in BIOS".
Restart PC > hit ("DEL" button for ASUS motherboard PCs) before Windows logo appears > Security settings > Enable Intel Virtualization Technology > Save & reset PC
12. Start new project:
- Android Studio > Start new Flutter project > Flutter Application
- Change dropdown "no devices" to "Open Android Emulator: Nexus 6 API 28" (if do this the first time, will take several minutes for virtual device to appear and load the homescreen)
- click green play button (or Shift+10) to run "main.dart" on virtual device (first time will take x minutes)
13. Setup dashboard preferences:
- Settings > Appearance & Behavior > Appearance > Theme > Darcula (for dark theme)
- Settings > Appearance & Behavior > Appearance > Use custom font size: 16 (dashboard font)
- Settings > Editor > Font > Size: 16 (code font)
- Settings > Languages & Frameworks > Flutter > Editor > Format code on save > tick
--- RHS click in code window > Reformat code with dartfmt
--- Now whenever we save with Ctrl+S, the code will be reformatted
How to add dependencies / external packages in flutter e.g. "camera"
1. Open "pubspec.yaml"
2. look for "dependencies:" and then indent once and add: "camera:"
3. insert the import statement into "main.dart" i.e. "import 'package:camera/camera.dart';"
4. Run "main.dart" (Shift+F10)
How to add dependencies / external pacakges in Flutter
1. Go to https://pub.dev/ and search for a package
2. Under "Installing" tab, copy the dependency e.g. "location: ^2.3.5", open your "pubspec.yaml" file (in project's root folder), paste the code under the heading "dependencies" (ensure indentation is aligned with other existing dependencies!) then hit "Packages get"
3. There could be more setup steps under "Readme" tab. See header "Getting Started":
3a. Android: copy permissions line e.g. "<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />", then open file "project_root > android > app > src > main > AndroidManifest.xml", and paste permission line within tag "<manifest>" but outside tag "<application>"
3b. iOS: take note of the permissions lines e.g. "NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription" >then open file "project_root > ios > Runner > Info.plist", and insert the permission lines within tag "<dict>" but never between any key-string pairs. Example:
"<key>NSLocationWhenInUseUsageDescription</key>
<string>Need to get your location!</string>"
and
"<key>NSLocationAlwaysUsageDescription</key>
<string>Need to get your location pls!</string>"
Note: if readme says "VALUE" is "YES", this means insert this line "<true/>" instead of "<string>...</string>"
3c. iOS: if asked to insert code into a file that doesnt yet exist, create that file and paste the code inside e.g. create file "project_root > ios > Runner > AppDelegate.m".
4. If necessary, codes may need to be inserted into other files. Their locations below:
project_root > android > gradle.properties
project_root > android > build.gradle
5. Insert the import statement where u wish to use the package in the dart file e.g. "import 'package:camera/camera.dart';"
1. Go to the "Welcome to Android Studio" screen > Configure > AVD Manager
2. The emulator shd have a triangle PlayStore icon in the "Play Store" column.
3. If dont have PlayStore icon, then: Create Virtual Device > select "Pixel 3a" (largest screen with PlayStore ability) > select Release Name (Pie or Android 9.0)(recent release which with most users) > Finish
How to setup Dart's DevTools to view UI details
1. Go to app folder e.g. "C:\Users\<username>\AndroidStudioProjects\ninja_id>" and type "flutter run"
2. You should get a similar line that says "An Observatory debugger and profiler on AOSP on IA Emulator is available at: http://127.0.0.1:54918/9Blrg74QhAc=/"
Note the URL i.e. "http://127.0.0.1:54918/9Blrg74QhAc=/"
3. Android Studio > Help > Open Dart DevTools
4. Paste URL "http://127.0.0.1:54918/9Blrg74QhAc=/"
HOW TO SETUP FIREBASE FOR FLUTTER
Source https://www.youtube.com/watch?v=LzEbpALmRlc
1. Go to console.firebase.google.com > Add a project > Project name e.g. flutterfire (no prob here)
2. AndroidStudio: project_root > android > app > src > AndroidManifest.xml > copy package name e.g. "com.example.firestorebasic" (no prob here)
3. At console.firebase.google.com > Project > Add Firebase to Android app > paste Android package name (i.e. "com.example.firestorebasic") > Register app (no prob here)
4. Download "google-services.json" and paste into folder "project_root > android > app" (no prob here)
5. Insert into file "project_root > android > build.gradle" the following:
dependencies {
...
classpath 'com.google.gms:google-services:4.3.3' (NOTE: yt instructor used 3.2.0) (run errors appear, but successfully built apk)
}
6. Insert as the last line into file "project_root > android > app > build.gradle" the following:
apply plugin: 'com.google.gms.google-services' (run errors appear, but successfully built apk)
7. Insert into file "project_root > pubspec.yaml" the following:
dependencies:
flutter:
sdk: flutter
image_picker: ^0.6.3+1
firebase_ml_vision: ^0.9.3+5
TROUBLESHOOTING
uses-sdk:minsdkversion 16 cannot be smaller than version 21 declared in library
https://stackoverflow.com/questions/52060516/how-to-change-android-minsdkversion-in-flutter-project
Device Not Found (When plug in device to usb cable in android studio)
File > Project structure > select latest ANDROID SDK in Project SDK
https://stackoverflow.com/questions/49045393/flutter-run-no-connected-devices
Install_failed_insufficient_storage
Insert this line into "project_root > android > app > src > main > AndroidManifest.xml" so that the app in forced to be installed on the device's external storage e.g. SD card
<application
...
android:installLocation="preferExternal"
...>
https://stackoverflow.com/questions/4709137/solution-to-install-failed-insufficient-storage-error-on-android?page=2&tab=votes#tab-top
Getting weird build fails?
Example: Execution failed for task ':app:transformClassesWithDexBuilderForDebug'. > Unable to delete directory
- Help > Code Cleanup scope > Whole project
- Help > Flutter Clean
- File -> Invalidate Caches/Restart
- Delete ".gradle" folder from project's root folder
- Open emulator and try running "main.dart" again (Shift+F10) (this recreates ".gradle" folder)
Android Studio compiling too slowly?
1. Settings > Compile independent modules in parallel > check
2. Settings > search "ide max heap size" > select max size allowed for your PC
NoSuchMethodError: The getter 'iterator' was called on null
BEFORE:
pathX.addRect(boundingBox); //"boundingBox" is null
AFTER:
boundingBox == null
? print('test123')
: pathX.addRect(boundingBox);