-
-
Notifications
You must be signed in to change notification settings - Fork 628
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
NoSuchMethodError (NoSuchMethodError: The getter 'host' was called on null #586
Comments
I get the same problem by running the following demo: ====flutter run --verbose my codeimport 'package:flutter/material.dart';
import 'package:graphql_flutter/graphql_flutter.dart';
import './mutations.dart' as mutations;
import './queries.dart' as queries;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
final HttpLink httpLink = HttpLink(
uri:'https://countries.trevorblades.com/',
);
final ValueNotifier<GraphQLClient> client = ValueNotifier<GraphQLClient>(
GraphQLClient(
cache: InMemoryCache(),
link: httpLink,
),
);
return GraphQLProvider(
client: client,
child: CacheProvider(
child: MaterialApp(
title: 'GraphQL Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.orange,
),
home: MyHomePage(),
),
),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
GraphQLConfiguration graphQLConfiguration = GraphQLConfiguration();
var mq ='''
query Myquery {
continents {
name
}
}
''';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Hasura Vote'),
),
body: Container(
child: Query(
options: QueryOptions(
documentNode: gql(mq),
pollInterval: 4,
),
builder: (QueryResult result,
{VoidCallback refetch, FetchMore fetchMore}) {
if(result.data==null){
return Text('data is null');
}
if (result.loading) {
print('isloading');
return const Center(
child: CircularProgressIndicator(),
);
}
if (result.hasException) {
return Text('\nErrors: \n ' + result.exception.toString());
}
// result.data can be either a [List<dynamic>] or a [Map<String, dynamic>]
final List<dynamic> pls = result.data['programming_language'];
return ListView.builder(
itemCount: pls.length,
itemBuilder: (BuildContext context, int index) {
final Map<String, dynamic> pl = pls[index];
final String name = pl["name"];
final int voteCount = pl["vote_count"];
return Mutation(
options: MutationOptions(
documentNode: gql(mutations.vote),
),
builder: (
RunMutation vote,
QueryResult voteResult,
) {
if (voteResult.data != null && voteResult.data.isNotEmpty) {
pl['vote_count'] = pl['vote_count'] + 1;
}
return ListTile(
title: Text('$name - $voteCount'),
trailing: Icon(Icons.thumb_up),
onTap: () {
vote(<String, String>{
'name': name,
});
},
);
},
);
},
);
},
),
),
);
}
} |
I also have the same issue! |
As a temporary solution, you may manually edit the problematic line until we get an update from authors: |
this is already fixed on the current beta release 3.0.1-beta.3 |
The host failure problem is solved but the example still not working due the connection problem.
|
Can somebody point me to a worked example. |
Finally figured out that it was because I had my VPN on. |
Same issue . Could you show how to install the beta package? |
Adding this in my android manifest file solves my problem. I haven't checked with iOS yet
|
@Aljabri-Salman Probably too late as a tip for you but it might help others to know how to get onto the beta version/track given the severity of this issue (in the stable version). Otherwise I reproduce it simply by starting an app that makes an API call soon after, while the network is down. This is basically a simulation of a case where an app is started on mobile while for whatever reason their is no internet connection / the network is down. |
also experiencing the same issue when testing using emulator but it works on real device, might be some connection problem |
@muhrahmatullah take a look at #212 |
@micimize checked the issue but the sample I am trying to use is the github_bloc one. I think it doesn't have a correlation with setting the local host (?) |
@muhrahmatullah I just mean that if your real device is trying to connect to localhost or |
I'm using the |
@andersonmendesdev try use the beta version: graphql_flutter: ^3.1.0-beta.7 |
@muhrahmatullah Yes, thank you, I'm already using it. |
For those who are subscribed to this thread and don't know yet - version 3.1.0 has been released with the fix of this issue. |
closing for now – if anyone has a similar issue please comment or open a new one |
Thanks so much for your fixing |
when we call api in case internet is off, it crash because of issue
And seem we cannot catch exception.
Could you check on it?
The text was updated successfully, but these errors were encountered: