-
-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type 'LocationModel' is not a subtype of type 'CommandResult<LocationModel>' #30
Comments
you have to use |
@escamoteur, you mean with my existing code and without |
@escamoteur your right the error
|
It depends :-) If you need inside your Btw yu can omit the StreamBuilder<CommandResult<LocationModel>>(
// With CommandResult this doesn't work because lastResult would just be a LocationModel, not aCommandResult<LocationModel>
// initialData:
// sl<LocationsManager>().selectLocationCommand.lastResult,
// So either leave empty or use
initialData:
CommandResult<LocationModel>( sl<LocationsManager>().selectLocationCommand.lastResult, null, false) ,
stream:
sl<LocationsManager>().selectLocationCommand.results,
builder: (context, snapshot) {
CommandResult<LocationModel> result = snapshot.data.data;
return Text(result.data.city,
style: TextStyle(
fontSize: 14.0,
color: Colors.orange,
decoration: TextDecoration.underline,
));
}) Always tell StreamBuilder which Type you expect. If you are only interested in the data, because you might listen to the You use the Command directly without the StreamBuilder<LocationModel>(
initialData:
sl<LocationsManager>().selectLocationCommand.lastResult,
stream:
sl<LocationsManager>().selectLocationCommand.results,
builder: (context, snapshot) {
LocationModel result = snapshot.data;
return Text(result.data.city,
style: TextStyle(
fontSize: 14.0,
color: Colors.orange,
decoration: TextDecoration.underline,
));
}) |
Thanks @escamoteur ! Here's the final StreamBuilder that works for me:
omitting the
|
Um this should work, what exxor did you get? Did you possible delete the |
Errors are:
and I'm using |
ahh could you just show me the line looks where the error is? And the one below? |
Sorry my bad again I did this Thanks again @escamoteur and for all your great packages, you are awesome mate. |
What should be the correct snapshot type using streambuilder?
The codes are the following:
StreamBuilder
LocationsManager
If I'm gonna remove
CommandResult<LocationModel> result = snapshot.data;
it will throw an Error:The text was updated successfully, but these errors were encountered: