Skip to content

ERROR: Tried calling: []("queryText") #21

@abbas-25

Description

@abbas-25
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 query = "hi";

  void _sendQuery() async {
    try {
    AuthGoogle authGoogle = await AuthGoogle(fileJson: "assets/dependencies/dialogflow.json").build();
    Dialogflow dialogflow = Dialogflow(authGoogle: authGoogle,language: Language.ENGLISH);
    print(dialogflow.toString());
    AIResponse response = await dialogflow.detectIntent(query);
    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)),
       ),
    );
  }
}

ERROR LOG -

I/flutter ( 9861): Instance of 'Dialogflow'
I/flutter ( 9861): ------------------------------NoSuchMethodError: The method '[]' was called on null.
I/flutter ( 9861): Receiver: null
I/flutter ( 9861): Tried calling: []("queryText")

I've taken all the necessary steps in my view. Is there anything missing out? in the code or in the process of GCP Json file downloading. I've not verified the OAuth screen though. And my GCP account is NOT payment verified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions