How to fix this error in the following codes? - dart

Could someone tell me how to fix this please?
This is in the main.dart error line.
https://i.stack.imgur.com/tFlDp.png
Another file's code, I think this might related to the error.
List<CovidTodayResult> covidTodayResultFromJson(String str) => List<CovidTodayResult>.from(json.decode(str).map((x) => CovidTodayResult.fromJson(x)));
String covidTodayResultToJson(List<CovidTodayResult> data) => json.encode(List<dynamic>.from(data.map((x) => x.toJson()))); ```

As your image states, you're declaring the return type as Future<CovidTodayResult>, but you're not returning a Future. If you want this specific code to work you should change your return type to List<CovidTodayResult> or if you're using await in your method, which I can't see, Future<List<CovidTodayResult>>.

Related

Google Slide API script updateShapeProperties autofit

Getting error "GoogleJsonResponseException: API call to slides.presentations.batchUpdate failed with error: Invalid requests[3].updateShapeProperties: Invalid field: autofit_type"
but I think my code is right:
'updateShapeProperties': {
'objectId': pageElementId,
'fields': 'autofitType',
'shapeProperties': {
'autofit': {
'autofitType':'SHAPE_AUTOFIT'
}
}
}
Any help much appreciated
Cheers
Greg
I thought that the error message means that the value of fields is not correct. In your script, how about modifying as follows.
From:
'fields': 'autofitType',
To:
'fields': 'autofit.autofitType',
Note:
But, in the current stage, it seems that the value of autofitType can only use NONE. So, when SHAPE_AUTOFIT and TEXT_AUTOFIT is used for autofitType, an error of Autofit types other than NONE are not supported. occurs. Please be careful this.
About this, it seems that this is not reported as the future request in the issue tracker. So how about reporting it as the future request? Ref
When you test above modification, please modify 'autofitType':'SHAPE_AUTOFIT' to 'autofitType':'NONE'. By this, the request occurs no error.
Reference:
AutofitType
You're using an invalid field as what the error message says.
You can refer here for the available fields that can be used to replace your 'autofitType' field.
In response to Jason E. response, please see the documented Enum for AutofitType 1

string.len() always returns the error "unexpected symbol"

function Main(Inhalt)
print(string.len(Inhalt))
end
Main(Bla)
This is just a example, I run in multiple problems like: "input:3: bad argument #1 to 'len' (string expected, got nil)" (Like here), or anything else with unexpected.
I'm kinda new to this, so please explain it to me from ground up I'm trying to figure out for a pretty long time. I already tried to convert this to a string with tostring(), but yes I'm missing something. Thanks for your help.
In this case Bla either needs to be a string which you can fix by putting quotes around it
function Main(Inhalt)
print(string.len(Inhalt))
end
Main("Bla")
or needs to be a variable that contains a string
Bla="test string"
function Main(Inhalt)
print(string.len(Inhalt))
end
Main(Bla)
Not a lua expert but it seems like you're trying to get the length of the string value Bla. The way you've written it right now does not indicate Bla is of string type. If you change it to the following, this should work.
function Main(Inhalt)
print(string.len(Inhalt))
end
Main("Bla")
Try this:
string1 = "Bla"
Main(string1)
In your code snippet Bla is not defined. Strings are surrounded by "".

Don't create a lambda when tear-off will do

I have a get function in my dart file where i have used a lambda. I am using DartLint which tells me not to create lambda if tear-off will do. I am not sure how to use a tear-off in my use case.
///To change data to our Stream using Sink.
Function(dynamic) get changeData => (event) {
_dataBlocController.add(event);
};
This is my lambda function, how will a tear-off look for this. I have gone through the documentation, but i am not getting a syntactically correct solution.
Thank you for the help!
This means that the closure is useless.
Instead of:
get changeData => (event) => _foo.add(event);
you can do:
get changeData => _foo.add;

firefox addon webrequest.addListener misbehaving

I want to examine http requests in an extension for firefox. To begin figuring out how to do what I want to do I figured I'd just log everything and see what comes up:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);},
{urls: [/^.*$/]}
);
The domain is insignificant, and I know the regex works, verified in the console. When running this code I get no logging. When I take out the filter parameter I get every request:
webRequest.onResponseStarted.addListener(
(stuff) => {console.log(stuff);}
);
Cool, I'm probably doing something wrong, but I can't see what.
Another approach is to manually filter on my own:
var webRequest = Components.utils.import("resource://gre/modules/WebRequest.jsm", {});
var makeRequest = function(type) {
webRequest[type].addListener(
(stuff) => {
console.log(!stuff.url.match(/google.com.*/));
if(!stuff.url.match(/google.com.*/))
return;
console.log(type);
console.log(stuff);
}
);
}
makeRequest("onBeforeRequest");
makeRequest("onBeforeSentHeaders");
makeRequest("onSendHeaders");
makeRequest("onHeadersReceived");
makeRequest("onResponseStarted");
makeRequest("onCompleted");
With the console.log above the if, I can see the regex returning true when I want it to and the code making it past the if. When I remove the console.log above the if the if no longer gets executed.
My question is then, how do I get the filtering parameter to work or if that is indeed broken, how can I get the code past the if to be executed? Obviously, this is a fire hose, and to begin searching for a solution I will need to reduce the data.
Thanks
urls must be a string or an array of match patterns. Regular expressions are not supported.
WebRequest.jsm uses resource://gre/modules/MatchPattern.jsm. Someone might get confused with the util/match-pattern add-on sdk api, which does support regular expressions.

Rails: Where clause doesn't work in any condition

I'm about to lose my mind due to a simple Rails where query. I simply cannot understand why it does work like 10 lines ago and does not after it. I could not figure out what might be causing the problem
#userID = Token.where(:tokenCode => #tokenReceived)
##init.tokenCode=#tokenReceived+"1" #randomize algorithm required!
#init.tokenCode=#codeGenerated=generate_activation_code()
if #userID.nil?
#newToken=Token.new
#newToken.tokenCode=#codeGenerated
else
#tokenToAdd = "12"
#newToken=Token.where(:userID => "1")
#if #newToken.nil?
#newToken.tokenCode="12"
#end
end
##newToken.save
#init.save
When I make a successful JSON request to 'http://localhost:3000/inits.json' it gives me a page with tons of erros but I think the main error among those are:
<h1>
NoMethodError
in InitsController#create
</h1>
<pre>undefined method `tokenCode=' for #<ActiveRecord::Relation:0x007fc43cb40b88></pre>
What could be the reason? Am I writing the where clause all wrong?
Edit: When I activate the if clause it works. I simply believe the #newToken object is null, however it is almost impossible for me to detect why. There is a data in my Token table with userID 1.
When you do:
#newToken=Token.where(:userID => "1")
You get an ActiveRecord::Relation, but you expect an object. So simply replace it with:
#newToken=Token.where(:userID => "1").first

Resources