Zir-AI logo

Zir-AI

Flutter widget for faster and simpler integration for Zir-AI.

For full :page_facing_up: documentation, visit the online documentation.

The perfect starting point to integrate Zir-Ai Semantic search within your Flutter project

:bulb: Example

import "dart:convert";
import "package:flutter/material.dart";
import "package:zir_semantic_search/zir_semantic_search.dart";
import "./search_box.dart";

void main() => runApp(InitialApp());

class InitialApp extends StatefulWidget {
  @override
  _InitialApp createState() => _InitialApp();
}

class _InitialApp extends State<InitialApp> {
  var results = new Map();
  GlobalKey<SearchBox> _myKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: "My App",
      home: Scaffold(
        body: Center(
          child: Column(
            children: [
              Padding(
                padding: EdgeInsets.only(top: 30),
                child: ZirSearchBox(
                  key: _myKey,
                  apiKey: 'zqt_cKg6-jmMWbiFViZw_6fEPl2JITLhXVk0jg3TQg',
                  corpusId: [234],
                  customerId: 1890073338,
                  image: "assets/images/logo.png",
                  results: 20,
                  offset: 0,
                  callback: (value) {
                    // printing received respose
                    print(res);
                    setState(() {
                      results = value;
                    });
                  },
                ),
              ),
              Container(
                width: 400,
                child: Row(
                  children: [
                    ActionChip(
                        label: Text("text to display in chip..."),
                        onPressed: () async {
                          final res = await _myKey.currentState!.runSearch("text for query...");
                          // printing received respose
                          print(res);
                          setState(() {
                            results = res;
                          });
                        }),
                    ActionChip(
                        label: Text("text to display in chip..."),
                        onPressed: () async {
                          final res = await _myKey.currentState!.runSearch("text for query...");
                          // printing received respose
                          print(res);
                          setState(() {
                            results = res;
                          });
                        }),
                  ],
                ),
              ),
              SearchApp() // another widget using ZirSearchBox
            ],
          ),
        ),
      ),
    );
  }
}

ZirSearchBox widget has 9 parameters

lets discuss the above:

key

make global key instance and pass the value to key in ZirSearchBox

apikey

apikey is your key which is linked with your single or multiple corpus. it's mandatory to pass apikey

customerID

it is your account ID which need to be passed to the component

corpusID

Basically it takes array of corpus id's which means on which corpus you want to make search

image

it is to change the logo in search box, if you dont want to change logo pass image parameter as a empty string

results

By default results value is 10, so which can be changed by passing number int value, if you dont want to change the default value, must pass results value 0

callback

It is a callback function with one parameter, which is response value will be received after request completion

runSearch

if you want to make search from anywhere outside, you can use method like _myKey.currentState!.runSearch("text for query..."), _myKey is global key which will be passed as a value of key.

Pagination

example:

...
ZirPagination(searchKey: _myKey1)
...

searchKey:

Pass the same global key to pagination which is being passed to the ZirSearchBox as key, but as searchKey.

Libraries

button
pagination
pagination_helpers