Flutter Bloc & Cubit - flutter

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.

Related

onButtonPressed: (ButtonType type, bool? status, Function()? updateStatus) bool function can't be assigned to the parameter type 'FutureOr<bool>

I am modifying a flutter app, so I get this error in my code, i don't know how it appears. after giving onButtonPressed a function
the error is :
[{
"resource": "../lib/Helper/ProductDescription.dart",
"owner": "_generated_diagnostic_collection_name_#2",
"code": {
"value": "argument_type_not_assignable",
"target": {
"$mid": 1,
"external": "https://dart.dev/diagnostics/argument_type_not_assignable",
"path": "/diagnostics/argument_type_not_assignable",
"scheme": "https",
"authority": "dart.dev"
}
},
"severity": 8,
"message": "The argument type 'bool Function(ButtonType, bool?, dynamic Function()?)' can't be assigned to the parameter type 'FutureOr<bool> Function(ButtonType, bool?, Function?)?'.",
"source": "dart",
"startLineNumber": 120,
"startColumn": 42,
"endLineNumber": 123,
"endColumn": 26
}]
the code :
onButtonPressed: (ButtonType type, bool? status,
Function()? updateStatus) {
return true;
I tried to modify the type of status but it didn't work

Remove empty space from Streamlit Echarts

I am rendering a gauge component in the following way, within my Streamlit app:
option = {
"series": [
{
"type": "gauge",
"startAngle": 180,
"endAngle": 0,
"min": min_range_val,
"max": max_range_val,
"center": ["40%", "40%"],
"splitNumber": 5,
"axisLine": {
"lineStyle": {
"width": 6,
"color": [
[0.25, "#FF403F"],
[0.5, "#ffa500"],
[0.75, "#FDDD60"],
[1, "#64C88A"],
],
}
},
"pointer": {
"icon": "path://M12.8,0.7l12,40.1H0.7L12.8,0.7z",
"length": "12%",
"width": 30,
"offsetCenter": [0, "-60%"],
"itemStyle": {"color": "auto"},
},
"axisTick": {"length": 10, "lineStyle": {"color": "auto", "width": 2}},
"splitLine": {"length": 15, "lineStyle": {"color": "auto", "width": 5}},
"axisLabel": {
"color": "#464646",
"fontSize": 12,
"distance": -60,
},
"title": {"offsetCenter": [0, "-20%"], "fontSize": 20},
"detail": {
"fontSize": 30,
"offsetCenter": [0, "0%"],
"valueAnimation": True,
"color": "auto",
"formatter": "{value}%",
},
"data": [{"value": value, "name": caption}],
}
]
}
st_echarts(option, width="450px", height="350px", key="gauge")
However, it seems like an additional empty extra white space is added at the bottom of the component (as from the following image).
How can I effectively remove that and keep only a tiny margin all around the gauge?
The following parameters must be added:
radius: '120%',
center: ['50%', '80%']
The latter one should be adjusted according to specific use cases.

Flutter ambiguous import on a class that does not exist in the framework

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.

How to solve the problem of unused import on Flutter?

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;

Can't create a Ruta Annotation after upgrade to Ruta 2.8.0

I have some Ruta script for recognizing peaces of html. See:
DECLARE SkipRegion;
DECLARE EnhancedMarkup(STRING markupName, STRING markupType);
ADDRETAINTYPE(MARKUP);
// replacement of attributes and '/', '<' and '>' symbols is done to get the tag name
MARKUP{-> CREATE(EnhancedMarkup, "markupName" = replaceAll(replaceAll(MARKUP.ct, "\\s[^=]+=[\"'][^\"']+[\"']", ""), "[\\/<>]", ""), "markupType" = "unknown")};
FOREACH(markup) EnhancedMarkup{} {
markup{startsWith(markup.ct, "<") -> SETFEATURE("markupType", "start")};
markup{startsWith(markup.ct, "</") -> SETFEATURE("markupType", "end")};
markup{endsWith(markup.ct, "/>") -> SETFEATURE("markupType", "empty")};
}
// mark the regions not to be looked through
// So whe have a SkipRegion Annotation like '<sub>Zie ook art. 1 van de Werkloosheidswet</sub>'
(start:EnhancedMarkup{start.markupType == "start"} # end:EnhancedMarkup{end.markupType == "end"}) {
start.markupName == end.markupName -> MARK(SkipRegion)
};
SkipRegion{-> UNMARK(MARKUP)};
REMOVERETAINTYPE(MARKUP);
ADDFILTERTYPE(SkipRegion);
When I put the next text into Ruta <sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>
I expected that i have the next Annotations:
[
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "<sub>",
"startPosition": 0,
"endPosition": 5,
"source": "RUTA_ANNOTATION"
},
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<nadruk opmaak=\"cursief\">art. 1</nadruk>",
"startPosition": 13,
"endPosition": 53,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "<nadruk opmaak=\"cursief\">",
"startPosition": 13,
"endPosition": 38,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "</nadruk>",
"startPosition": 44,
"endPosition": 53,
"source": "RUTA_ANNOTATION"
},
{
"name": "enhancedMarkup",
"type": "Commons.EnhancedMarkup",
"value": "</sub>",
"startPosition": 77,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
},
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>",
"startPosition": 0,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
}
]
This was working in Ruta v2.7, but it's not working anymore in Ruta v2.8. Then all the Annotation above mentioned are present except the next Annotation is missing:
{
"name": "skipRegion",
"type": "Commons.SkipRegion",
"value": "<sub>Zie ook <nadruk opmaak="cursief">art. 1</nadruk> van de Werkloosheidswet</sub>",
"startPosition": 0,
"endPosition": 83,
"source": "RUTA_ANNOTATION"
}