firestore_search 0.0.3 firestore_search: ^0.0.3 copied to clipboard
This package helps developers to implement cloud_firestore search in their apps.
import 'package:firestore_search/firestore_search.dart';
import 'package:flutter/material.dart';
import 'data_model.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Material App',
home: Scaffold(
appBar: AppBar(
title: Text('Material App Bar'),
),
body: Center(
child: Container(
child: Text('Hello World'),
),
),
),
);
}
}
class SearchFeed extends StatefulWidget {
@override
_SearchFeedState createState() => _SearchFeedState();
}
class _SearchFeedState extends State<SearchFeed> {
@override
Widget build(BuildContext context) {
return FirestoreSearchScaffold(
firestoreCollectionName: 'data',
dataListFromSnapshot: DataModel().dataListFromSnapshot,
builder: (context, snapshot) {
if (snapshot.hasData) {
final List<DataModel> dataList = snapshot.data;
return ListView.builder(
itemCount: dataList?.length ?? 0,
itemBuilder: (context, index) {
final DataModel data = dataList[index];
return Column(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('${data?.name ?? ''}'),
Text('${data?.description ?? ''}')
],
);
});
}
return Center(
child: CircularProgressIndicator(),
);
},
);
}
}