Skip to content
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

hacker news : error thrown retrieving article list #102

Open
slfhstr opened this issue Aug 12, 2021 · 0 comments
Open

hacker news : error thrown retrieving article list #102

slfhstr opened this issue Aug 12, 2021 · 0 comments

Comments

@slfhstr
Copy link

slfhstr commented Aug 12, 2021

Nicce example code and generally working, but retrieving articles seems erratic
I am getting this error :

════════ Exception caught by widgets library ═══════════════════════════════════
The following _CastError was thrown building FutureBuilder<String>(dirty, state: _FutureBuilderState<String>#018ec):
type 'Null' is not a subtype of type 'String' in type cast

The relevant error-causing widget was
FutureBuilder<String>
lib/screens/news.dart:57
When the exception was thrown, this was the stack
#0      new MyHackerNewsArticle.fromJson
lib/screens/news.dart:167
#1      _NewsPage.build.<anonymous closure>.<anonymous closure>
lib/screens/news.dart:68
#2      _FutureBuilderState.build
package:flutter/…/widgets/async.dart:775
#3      StatefulElement.build
package:flutter/…/widgets/framework.dart:4691
#4      ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4574

I tried checking for nulls in retrieved article metadata, but ti does not fix the problem.
I'm thinking that _NewsPage.build.<anonymous closure>.<anonymous closure> is the problem.
How can I make this robust for network errors ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant