This is the 7th day of my participation in the August Text Challenge.More challenges in August
CanLaunch will return false (Android)
Starting from API 30 Android requires package visibility configuration in your AndroidManifest.xml otherwise canLaunch will return false. A element must be added to your manifest as a child of the root element.
Check < project directory > / android/app/SRC/main/AndroidManifest. Add the permissions in XML:
<queries> <! -- If your app opens https URLs --> <intent> <action android:name="android.intent.action.VIEW" /> <data android:scheme="https" /> </intent> <! -- If your app makes calls --> <intent> <action android:name="android.intent.action.DIAL" /> <data android:scheme="tel" /> </intent> <! -- If your app emails --> <intent> <action android:name="android.intent.action.SEND" /> <data android:mimeType="*/*" /> </intent> </queries>Copy the code
Question 2
Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:
Copy the code
The solution
If you are using Vscode
- Step 1 File => Preferences => Settings
- Step 2 Search for “Flutter run additional args”
- Step 3 Then click Add Item
Now type –no-sound-null-safety Click OK
Cannot run with sound null safety because dependencies don’t support null safety
Question 3
Non-nullable instance field 'repoName' must be initialized.
Try adding an initializer expression, or add a field initializer in this constructor, or mark it 'late'.dartnot_initialized_non_nullable_instance_field
Copy the code
Workaround: since flutter2.0 added the Sound null safety air safety declaration, the goal is to increase the robustness of the Dart language by explicitly declaring variables that may be null.
Dart language variables can store NULL or specific values. Therefore, in daily development, a variable may be called NULL due to forgotten or delayed assignment, causing the program to throw an exception. When this feature is rolled out, errors caused by null exceptions can be resolved at the source level. The simple operation is to add? To indicate that the variable can be null.
class GitEvent {
String? id;
String? userName;
String? avatarUrl;
String? repoName;
GitEvent(json) {
this.id = json['id'];
this.userName = json['actor'] ['login'];
this.avatarUrl = json['actor'] ['avatar_url'];
this.repoName = json['repo'] ['name']; }}Copy the code
Question 3
The argument type 'String' can't be assigned to the parameter type 'Uri'
Copy the code
Solutions:
import 'package:http/http.dart' as http;
var url = Uri.parse('https://example.com/whatsit/create');
var response = await http.post(url, body: {'name': 'doodle'.'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
print(await http.read('https://example.com/foobar.txt'));
Copy the code
Question 4
[dismissible] flutter pub get
Error detected in pubspec.yaml:
Error on line 31, column 10: Mapping values are not allowed here. Did you miss a colon earlier?
╷
31 │ http: ^0.13.3
│ ^
╵
Please correct the pubspec.yaml file at C:\Users\Administrator\Desktop\flutter_example\dismissible\pubspec.yaml
Copy the code
Yaml file has strict indentation, if not indentation is not strictly in accordance with the specification, the error will be reported, so need to correct alignment.