mysearch 0.0.1 copy "mysearch: ^0.0.1" to clipboard
mysearch: ^0.0.1 copied to clipboard

outdated

A flutter plugin for information on government services and bangla search

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:mysearch/mysearch.dart';
import 'package:mysearch/model.dart';

void main() => runApp(const MyMaterialApp());

class MyMaterialApp extends StatelessWidget {
  const MyMaterialApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      title: 'MySearch App',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 1,
      child: Scaffold(
          appBar: AppBar(
            title: const Text("MySearch App"),
          ),
          body: const MyHomepage()),
    );
  }
}

class MyHomepage extends StatefulWidget {
  const MyHomepage({Key? key}) : super(key: key);

  @override
  _MyHomepageState createState() => _MyHomepageState();
}

class _MyHomepageState extends State<MyHomepage> {
  Future<List<SearchResultItem>>? _futureSearchResultItem;

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.fromLTRB(22.0, 22.0, 22.0, 8),
      child: Column(
        children: <Widget>[
          const SizedBox(
            height: 10.0,
          ),
          MySearchField(
            textFieldConfiguration: TextFieldConfiguration(
              autofocus: true,
              style: DefaultTextStyle
                  .of(context)
                  .style
                  .copyWith(fontStyle: FontStyle.italic),
              decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  hintText: 'What are you looking for?'),
            ),
            onSearchResultFound: (List<SearchResultItem> searchResult) {
              _futureSearchResultItem =
              Future<List<SearchResultItem>>.value(searchResult);
              setState(() {});
            },
          ),
          const SizedBox(
            height: 10.0,
          ),
          (_futureSearchResultItem == null)
              ? const Text("Search Anything")
              : Flexible(
              child: Container(
                child: buildFutureBuilder(),
              ))
        ],
      ),
    );
  }

  FutureBuilder<List<SearchResultItem>> buildFutureBuilder() {
    return FutureBuilder<List<SearchResultItem>>(
      future: _futureSearchResultItem,
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return ListView.builder(
            scrollDirection: Axis.vertical,
            shrinkWrap: true,
            itemCount: snapshot.data!.length,
            itemBuilder: (context, index) {
              SearchResultItem project = snapshot.data![index];
              return Container(
                padding: const EdgeInsets.fromLTRB(8.0, 8.0, 8.0, 12.0),
                color: Colors.grey[100],
                child: Column(children: <Widget>[
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      project.service_id,
                      style: const TextStyle(
                          fontWeight: FontWeight.normal, color: Colors.grey,fontSize: 12),
                      textAlign: TextAlign.left,
                    ),
                  ),
                  const SizedBox(
                    height: 4.0,
                  ),
                  Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      project.name,
                      style: const TextStyle(
                          fontWeight: FontWeight.bold, color: Colors.grey),
                    ),
                  ),
                  const SizedBox(
                    height: 4.0,
                  ),Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      "Department : ${project.department}",
                      style: const TextStyle(
                          fontWeight: FontWeight.normal, color: Colors.grey),
                    ),
                  ), Align(
                    alignment: Alignment.centerLeft,
                    child: Text(
                      "Office : ${project.office}",
                      style: const TextStyle(
                          fontWeight: FontWeight.normal, color: Colors.grey),
                    ),
                  ),

                ]),
              );
            },
          );
        } else if (snapshot.hasError) {
          return Text('${snapshot.error}');
        }

        return const CircularProgressIndicator();
      },
    );
  }
}
3
likes
0
points
72
downloads

Publisher

verified publishersocian.ai

Weekly Downloads

A flutter plugin for information on government services and bangla search

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

Dependencies

flutter, flutter_keyboard_visibility, http

More

Packages that depend on mysearch

Packages that implement mysearch