This article will be updated in the long term. Students who want to learn Flutter can follow this article and put forward their own problems and solutions in the comments section, so that we can learn and grow together.
Please also point out where the explanation or solution is not accurate.
Upgrade Flutter SDK
flutter upgrade
Update the Flutter SDK using the terminal CD to the previously downloaded Flutter path. This command first gets the latest Flutter SDK version available to your Flutter channel. This command then updates each package that your app depends on to the latest compatible version. After the update, run the dart pub cache repair command to clear the Package from the cache and reinstall the Package.
1, Could not build the application for the simulator.
Could not build the application for the simulator.
Error launching application on iPhone Xr.
Copy the code
This was caused by cache problems. I had this problem when I changed the Flutter SDK;
- Solutions:
Clear the Flutter cache on the terminal and run the following command:
flutter clean
flutter run
Copy the code
If the above solution can’t, you can delete the Xcode caching, corresponding path is: ~ / Library/Developer/Xcode/DerivedData
This error is vague and suggested inXcode
orAndroid Studio
Run the project, will report the specific reason, here is usedXcode
Running project error because it was not founddart.html
, this is mainly the library import problem, please check your library, BECAUSE I have more importsdart:html
Cause problems.
2, Avoid using web-only libraries outside Flutter Web plugin packages.
Go to Pubspec. yaml and comment out the dependencies of flutter in Dependencies to avoid using pure Web libraries outside of the Flutter Web plugin package.
Plugins cannot load plugins with Android Studio 4+
Set the location in the HTTP Proxy to plugins.jetbrains.com
Waiting for another flutter command to release the startup lock…
[Fixed] An error occurred while executing the flutter terminal command.
When the project is shut down unexpectedly, or Android Studio forcibly shuts it down with the task manager, the above line will appear on the next startup. At this point, open the < path of flutter Dev >/bin/cache/lockfile, delete the flutter and execute the terminal code again. Or directly with the following command: rm/flutter/bin/cache/lockfile.
5, Relaunch your application with the ‘-profile’ argument
Enable performance debugging errors using Flutter DevTools.
This error occurs because Profile mode is not enabled. You need to use Flutter Run — Profile on the terminal or run Profile mode in a tool.
6, Exception: Profile mode is not supported for iPhone 12 Pro Max.
[Fixed] Error when enabling Profile (flutter run — Profile)
Because Profile mode can only run on a real machine, it cannot run on an emulator because the emulator does not represent a real scenario. In addition to enabling a Profile using a terminal, you can also enable a Profile using other development tools, such AS the Profile of AS.
7, The method ‘*’ was called on null.
Because the * used is empty, there is no initialization result, you can initialize the * object in advance, then use it.
8, Run custom shell script ‘[cp-user] Run Flutter Build bb_ flutter_ module script
Because Native and Flutter are mixed, the library of Flutter is not updated.
If the project is a mix of Native and Flutter, a new library is added and used in the Flutter code, another person updates the code, but does not install or upgrade the Flutter, This will cause the script terminal of the flutter to report this error.
9, A non-null String must be provided to A Text widget
Because the contents of a Text widget cannot be empty, you can assign the value to an empty string when there is no content. “”
RenderFlex children have non-zero flex but incoming height constraints are unbounded.
This is because the parent Widget in Flex does not have a height constraint, and you can set the height for the parent Widget.
11, There are multiple observatory ports available.
An error occurred when using the Flutter Attach synchronization code during the mix of Flutter and Native. This is because there are multiple ports, choose one of them to execute, generally choose one without numbers.
If the problem persists, execute the flutter attach -v to check the error location and rectify the error.
12, The mDNS query for an attached iOS device failed.
You need to Disable mobile hotspots and deselect Disable Unless needed under Mac Settings -> Network -> iPhone USB.
13, The default value of an optional parameter must be constant.
Because the default value of an optional parameter must be a constant, note that some system methods, which may be implemented with underlying functions, cannot be set to the default value.
- The use of const can be simplified into three scenarios:
Const is used to the left of = to define a constant
2, const is used to the right of = to create a constant
Const constructor: creates constants
14, Try launching Xcode and selecting “Product > Run” to fix the problem: open ios/Runner. Xcworkspace
There was an error when debugging the iPhone, because the developer account was not selected. Use Xcode to open Runner. Xcworkspace and select the corresponding developer account.
15, Platform Exception (channel-error, unable to establish connection on channel., null, null)
An error was reported because the Native code plug-in was used and not registered.
- IOS can add the following code after FlutterEngine Run:
[GeneratedPluginRegistrant registerWithRegistry:self.flutterEngine];
Copy the code
Note that flutter. Dev /docs/develo…
- Android can add the following code:
GeneratedPluginRegistrant.registerWith(flutterEngine)
Copy the code
16, There are multiple observatory ports available.
There are multiple observatory ports available. Rerun this command with one of the following passed in as the appId: * * * * * *Copy the code
The error occurred when using the flutter attach command. Because of the port problem, remove the wall of the terminal or computer and try again. If this does not work, unplug and insert the mobile phone and test again.
Incorrect use of ParentDataWidget.
Incorrect use of ParentDataWidget. The ParentDataWidget Positioned(top: 9.0) Wants to apply ParentData of Type StackParentData to a RenderObject, which has been set up to accept ParentData of incompatible type FlexParentData. Usually, this means that the Positioned widget has the wrong ancestor RenderObjectWidget. Typically, Positioned widgets are placed directly inside Stack widgets. The offending Positioned is currently placed inside a Row widget. The ownership chain for the RenderObject that received the incompatible parent data was: Tourist ← Image ← Container ← Visibility ← Row ← ColoredBox ← ConstrainedBox ← Container ← Row ←... When the exception was thrown, this was the stack: The following assertion was thrown while applying parent data.: Incorrect use of ParentDataWidget.Copy the code
The reason for the warning here is the use of the toy assembly inside the non-stack assembly; A similar warning can also appear when Expanded is used in non-row or Column components.