I'm studying, flutter http request, and have followed the instructions at https://pub.dev/packages/http#-installing-tab- but after I import, this notification appears:
{
"resource": "/C:/appfluter/lat_api_htpp/lib/post_result_model.dart",
"owner": "dart",
"code": "unused_import",
"severity": 2,
"message": "Unused import: 'package: http / http.dart'. \ nTry removing the import directive.",
"source": "dart",
"startLineNumber": 1,
"startColumn": 8,
"endLineNumber": 1,
"endColumn": 32,
"tags": [1]
}
Even though I already installed the plugin, can anyone help?
Just add/include this package Name in your Class
import 'package:http/http.dart' as http;
Related
I am following the tutorial here: https://resocoder.com/2020/08/04/flutter-bloc-cubit-tutorial/.
When I reached the "Building with Cubit" part and in the main.dart, I have the following issue:
The errors I have:
[{
"resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
"owner": "_generated_diagnostic_collection_name_#1",
"code": {
"value": "type_argument_not_matching_bounds",
"target": {
"$mid": 1,
"external": "https://dart.dev/diagnostics/type_argument_not_matching_bounds",
"path": "/diagnostics/type_argument_not_matching_bounds",
"scheme": "https",
"authority": "dart.dev"
}
},
"severity": 8,
"message": "'dynamic' doesn't conform to the bound 'StateStreamableSource<Object?>' of the type parameter 'T'.\nTry using a type that is or is a subclass of 'StateStreamableSource<Object?>'.",
"source": "dart",
"startLineNumber": 13,
"startColumn": 13,
"endLineNumber": 13,
"endColumn": 25,
"relatedInformation": [
{
"startLineNumber": 13,
"startColumn": 13,
"endLineNumber": 13,
"endColumn": 25,
"message": "The raw type was instantiated as 'BlocProvider<dynamic>', and is not regular-bounded.",
"resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart"
}
]
}]
[{
"resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
"owner": "_generated_diagnostic_collection_name_#1",
"code": "could_not_infer",
"severity": 8,
"message": "Couldn't infer type parameter 'T'.\n\nTried to infer 'dynamic' for 'T' which doesn't work:\n Type parameter 'T' is declared to extend 'StateStreamableSource<Object?>' producing 'StateStreamableSource<Object?>'.\nThe type 'dynamic' was inferred from:\n Parameter 'create' declared as 'T Function(BuildContext)'\n but argument is 'dynamic Function(BuildContext)'.\n\nConsider passing explicit type argument(s) to the generic.\n\n",
"source": "dart",
"startLineNumber": 13,
"startColumn": 13,
"endLineNumber": 13,
"endColumn": 25
}]
[{
"resource": "/d:/My Programs/learn_dart/weather_bloc/lib/main.dart",
"owner": "_generated_diagnostic_collection_name_#1",
"code": {
"value": "undefined_method",
"target": {
"$mid": 1,
"external": "https://dart.dev/diagnostics/undefined_method",
"path": "/diagnostics/undefined_method",
"scheme": "https",
"authority": "dart.dev"
}
},
"severity": 8,
"message": "The method 'WeatherCubit' isn't defined for the type 'MyApp'.\nTry correcting the name to the name of an existing method, or defining a method named 'WeatherCubit'.",
"source": "dart",
"startLineNumber": 14,
"startColumn": 30,
"endLineNumber": 14,
"endColumn": 42
}]
Can give me some hints on this?
From the log you provided
The method 'WeatherCubit' isn't defined for the type 'MyApp'.\nTry correcting the name to the name of an existing method, or defining a method named 'WeatherCubit'.
You forgot to import file with WeatherCubit definition.
My project, with name in lowercase, compiles and creates the apk, but in VStudio it indicates a problem that I have not been able to solve, Property progress is not allowed:
code in angular.json:
"ci": {
"progress": false
}
[{
"resource": "/C:/ionic/prueba/angular.json",
"owner": "_generated_diagnostic_collection_name_#0",
"severity": 4,
"message": "Property progress is not allowed.",
"startLineNumber": 86,
"startColumn": 15,
"endLineNumber": 86,
"endColumn": 25
}]
I send additional information, thank you very much !!!
Ionic:
Ionic CLI : 6.19.0 (C:\Users\Guille\AppData\Roaming\npm\node_modules\#ionic\cli)
Ionic Framework : #ionic/angular 6.0.14
Cordova:
Cordova CLI : 11.0.0
Cordova Platforms : android 10.1.1
OS : Windows 10
I want to create dev mode and prod mode for my app. In Flutter's documentation about flavors, they refer to two packages on pub.dev and a bunch of articles. The flutter_flavor package seemed the easiest to implement so I installed it and I followed the steps mentioned in their documentation. However, I don't know how to actually run the different flavors? It is not mentioned in the package's documentation. They mention adding some configurations to launch.json but I'm not sure what that does and how am I supposed to use it when running the app? Is there a command to run the flavors from the vscode terminal?
The steps I did:
create two main files; main_prod.dart and main_dev.dart
inside main_dev.dart:
import 'package:flutter/material.dart';
import 'package:flutter_flavor/flutter_flavor.dart';
import 'main.dart';
void main() {
FlavorConfig(
name: "DEV",
color: Colors.red,
location: BannerLocation.topStart,
variables: {
"baseUrl": "https://www.example2.com",
"appTitle": "app1-dev",
},
);
return runApp(MyApp());
}
inside main_prod.dart:
import 'package:flutter/material.dart';
import 'package:flutter_flavor/flutter_flavor.dart';
import 'main.dart';
void main() {
FlavorConfig(
color: Colors.red,
location: BannerLocation.topStart,
variables: {
"baseUrl": "https://www.example2.com",
"appTitle": "app1-dev",
},
);
return runApp(MyApp());
}
my launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "skinhealthapp",
"request": "launch",
"type": "dart"
},
{
"name": "PROD-Flavor",
"program": "[project-folder]/lib/main_prod.dart",
"request": "launch",
"type": "dart"
},
{
"name": "DEV-Flavor",
"program": "[project-folder]/lib/main_dev.dart",
"request": "launch",
"type": "dart"
}
]
}
Then what?
All of a sudden I'm receiving ambiguous import errors on classes that absolutely don't exist in the locations stated in the error message. As an example the name of the class is something like BusinessEntityResponse (ie GetUserNameResponse) and Flutter/dart is reporting it as ambiguous in the framework. Any ideas on how to address this (tried flutter clean) or why it is occurring or how to troubleshoot it?
{
"resource": "/c:/projects/git/curbside/my_app/lib/data/settings/settings.dart",
"owner": "dart",
"code": {
"value": "ambiguous_import",
"target": {
"$mid": 1,
"external": "https://dart.dev/tools/diagnostic-messages#ambiguous_import",
"path": "/tools/diagnostic-messages",
"scheme": "https",
"authority": "dart.dev",
"fragment": "ambiguous_import"
}
},
"severity": 8,
"message": "The name 'MyAppClassResponse' is defined in the libraries 'package:my_app/api/dto.dart' and 'package:flutter/src/widgets/framework.dart'.\nTry using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.",
"source": "dart",
"startLineNumber": 81,
"startColumn": 10,
"endLineNumber": 81,
"endColumn": 36,
"tags": []
}
This seems to be indicative of a larger problem as the following lines are also throwing compilation errors all of a sudden:
class AppEntryWeb extends StatelessWidget --> Classes can only extend other classes.
{
"resource": "/c:/projects/git/curbside/my_app/lib/ui/launch-web.dart",
"owner": "dart",
"code": {
"value": "extends_non_class",
"target": {
"$mid": 1,
"external": "https://dart.dev/tools/diagnostic-messages#extends_non_class",
"path": "/tools/diagnostic-messages",
"scheme": "https",
"authority": "dart.dev",
"fragment": "extends_non_class"
}
},
"severity": 8,
"message": "Classes can only extend other classes.\nTry specifying a different superclass, or removing the extends clause.",
"source": "dart",
"startLineNumber": 12,
"startColumn": 27,
"endLineNumber": 12,
"endColumn": 42,
"tags": []
}
For what it is worth, the errors seemed to have occurred when the visual studio code flutter extension updated to 3.15.0. I uninstalled the flutter/dart extensions, shut down vs code, reopened and reinstalled them which seemed to have fixed the issue.
Further information, the visual studio code analyzer problem window was reporting different information from running flutter analyze. Not sure why.
I have a bunch of custom build tasks in VS Code and I want a custom problem matcher for the C++ ones.
So I decided to take the default problem matcher example in VS Code docs (https://code.visualstudio.com/Docs/editor/tasks#_defining-a-problem-matcher) and modified it slightly.
"problemMatcher": {
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(\\.\\.\\/+)(.*):(\\d+):(\\d+):\\s+(.*):\\s+(.*)$",
"file": 2,
"line": 3,
"column": 4,
"severity": 5,
"message": 6
}
My error messages have the following structure:
../../../module/src/module/specific/File.cpp:155:31: error: errorMessage
The three directory-up instructions (../../../) bring me back to ${workspaceFolder}. So the idea was to use the second capture group as a relative path from my workspace folder to follow up to the file.
Unfortunately, the file path does not highlight and it doesn't tell me to Ctrl+click to follow the message. I double checked the regex on https://regexr.com/ and it seems to be correct. I tried using the the default problem matcher too, without any luck.
This is the full build task:
{
"label": "build_c++",
"type": "shell",
"command": "${workspaceFolder}/build_command",
"problemMatcher": [ {
"fileLocation": ["relative", "${workspaceFolder}"],
"pattern": {
"regexp": "^(\\.\\.\\/+)(.*):(\\d+):(\\d+):\\s+(.*):\\s+(.*)$",
"file": 2,
"line": 3,
"column": 4,
"severity": 5,
"message": 6
}
}],
"group": {
"kind": "build",
"isDefault": true
}
},
Any ideas?