I'm trying to use the flutter_dialogflow
package with Dialogflow v2. I've taken all the necessary steps in my view. I need help in knowing if I'm missing out on anything.
My Code -
import 'package:flutter/material.dart';
import 'package:flutter_dialogflow/dialogflow_v2.dart';
class Home extends StatefulWidget {
Home({Key key}) : super(key: key);
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
String sampleQuery = "travel destinations in india";
void _sendQuery() async {
try {
AuthGoogle _authGoogle = await AuthGoogle(fileJson: "assets/dependencies/dialogflow.json").build();
Dialogflow dialogflow = Dialogflow(authGoogle: _authGoogle, language: Language.english);
AIResponse response = await dialogflow.detectIntent("hi");
print(response.getMessage());
} catch(e) {
print('------------------------------${e.toString()}');
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Ask Now'),
),
body: RaisedButton(
onPressed: _sendQuery,
color: Colors.black87,
child: Text('Send Query', style: TextStyle(color: Colors.white)),
),
);
}
}
Please note:
- I've enabled Web API option in Dialogflow Integrations
- I've downloaded the JSON file and added it to the directory and assets in pubspec.yaml file
- I've checked the path to the file many times (no issues there)
- My Google Cloud Console is NOT payment verified (i don't think this should be the concern)
- I've NOT verified the OAUTH CONSENT SCREEN as I don't know what to put in the URL for a mobile app
Here's the error log -
I/flutter (18856): ------------------------------NoSuchMethodError: The method '[]' was called on null.
I/flutter (18856): Receiver: null
I/flutter (18856): Tried calling: []("queryText")
I believe the issue lies in AIResponse response = await dialogflow.detectIntent("hi");
line of code but can't find out why and how.
Maybe I'm missing out on some steps. Thank Youuu!