I have been trying to write about Flutter for a few weeks. During this time, I have encountered many problems. Some of them need to be filled in by the authorities, while others need to be solved by myself.

1. The editor strongly recommends using Android Studio

VS Code is my personal favorite Code editor. Beautiful, simple, fast. VS Code’s Flutter plugin is already quite powerful, but Android Studio’s Flutter plugin is much more powerful and has a lot more features. Most importantly, the current Flutter is not stable enough (especially for thermal loading).

When VS Code hot loading fails, you have to recompile and run, which includes POD updates and Xcode recompile, which is pretty slow. But with Android Studio, you can “cold load” by clicking the green arrow. Without Xcode compilation, the app doesn’t even restart, and your project is back on track!

Note that if you install and reference a new third-party library, you still need to recompile your application. Without restarting the application at this point, it will run, but it will have all sorts of problems.

2. Permanently update the PATH variable

This thing should be done very early, especially for the sake of the domestic network is not good, more need to use the mirror site for the first time. The.bash_profile website is not very detailed, so I’ll take the Mac as an example.

cd~ // Go to the current user directory touch.bash_profile // create a.bash_profile file (if it doesn't exist) open-e.bash_profile // Open the.bash_profile file with notepadsource.bash_profile // Updates the newly configured environment variableCopy the code

First go to the user’s home directory, create a.bash_profile file, open it, and add three sentences

export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
export PATH=PATH_TO_FLUTTER_GIT_DIRECTORY/flutter/bin:$PATH
Copy the code

Add the PATH variable PATH_TO_FLUTTER_GIT_DIRECTORY to the local PATH of Flutter, such as my own:

/Users/jihongbo/development/flutter/bin:$PATH

Teach everyone a good method, right click on the directory popup menu, at this time hold down option key, will appear “copy XXX as path name”, then you can paste directly.

Note: do not add any symbols after it, such as // comments, etc. = No Spaces before or after it.

Just update the configuration at the end. The editor should also be restarted to update the terminal configuration.

3. Resource management Pubspec.yaml

Much like iOS podfile or Node.js package.json, pubspec.yaml is designed to manage third-party libraries. But he is also responsible for managing resources (images, fonts). Those of you who have seen the tutorial know that all you need to do to add an image font is add something like this to your file.

fonts:
- family: flyou
  fonts:
    - asset: fonts/fa-solid-900.ttf
Copy the code

Note, however, that their indentation relationship must be correct, otherwise the compilation will fail. Pubspec.yaml organizes font information by name and indentation, but this is not nearly as intuitive as JSON.

4. Not being friendly to iOS development

The easiest way to pick up Flutter is to develop Android for the simple reason that Flutter is the product of one father. From the default Material Design style to controls with the same name, you don’t even have to look at the API to guess the desired control name with your eyes closed. The second is front-end development. Because the core of Flutter is very similar to React and Vue, it is easy to understand. Dart and ES6 have very similar syntax. For iOS development, there is the NEED to read API documentation, the need to understand the concept of one-way data transmission, the need to understand the asynchronous features swift has not yet released…

On the other hand, all of the new features mentioned above are the latest and hottest technologies, and if you don’t learn them now, you’ll definitely need them in the future. The iOS development environment is far too comfortable for the front-end and even Android, and the frequency of technology explosions is far too low. But we can’t get stuck with existing technology.

So let’s go!