Closed yashanghan22 closed 4 months ago
The source code in your screendump has many syntax errors, for example: final partyListParam = obx.ToMany<PartyModel>?();
.
issue is that every time i have to manually fix this so is this error from package side or my side my class is shown below which is getting error.
I'm not quite sure what you are saying here. I assume the screendump shows code that you have written, and hence I'd expect you to fix the syntax errors before you'd start worrying about errors being caused by anything other than your code.
On the other hand, the reference to "manually fix this" could imply that the code is generated, and in that case it would be the code generator which is buggy.
In any case, the initializing expression obx.ToMany<PartyModel>?()
is a syntax error. The error message about relational expressions are caused by the fact that no grammar rule allows for a ?
in that position, so the <
and the >
are forced to be considered as relational operators rather than angle brackets around type arguments. So you're evaluating a IS-LESS-THAN b IS-GREATER-THAN c
where a
is obx.ToMany
, b
is PartyModel
, and c
is a syntax error. You can't do that because a < b > c
puts two relational operators at the same level, so you'd have to make a choice and make it (a < b) > c
or a < (b > c)
, which is exactly what the error message 'A comparison expression can't be an operand of another comparison expression' tells us (on top of it all, c
is a syntax error, but even if you change c
such that it is a correct expression then you still have the error about two relational operators in the same expression).
Perhaps your intention is that the PartyModel
is a type argument, and it should be nullable? That would be obx.ToMany<PartyModel?>()
.
Or perhaps your intention is that obx.ToMany
is a method tear-off which is then subject to generic function instantiation (obx.ToMany<PartyModel>
), and that function is then conditionally invoked? It might seem natural to allow f?()
to be an invocation of f
which will shortcut and yield null if f
is null, but we don't have that syntax (we do have myArray?[someIndex]
, and we did discuss supporting f?()
). Anyway, we don't have that syntax because it can easily be done using call
, which would be (obx.ToMany<PartyModel>)?.call()
. But that would give rise to a warning, because obx.ToMany<PartyModel>
can't be null, so it doesn't make sense to test it for null.
Hope this helps! It is all working as intended, so I'll close the issue.
@eernstg, thanks for the suggestion, the correction, and the solution.
can be nullable marking showing error as comparison expression.
my list of objects are nullable list so that it is throwing error while generating error after g dart file generation and after generated file i have to fix this by removing question mark manually and then it wil be fixed.
so issue is that every time i have to manually fix this so is this error from package side or my side my class is shown below which is getting error.
-------info----------
3.4.3
3.22.2
2.4.11
windows-10
windows desktop application
package issue in terminal:
Issue containing code part: