- import 'package:firebase_storage/firebase_storage.dart';
- import 'package:cloud_firestore/cloud_firestore.dart';
- class AnimalInfo extends StatefulWidget {
- final String qrCodeResult;
- AnimalInfo({this.qrCodeResult});
- @override
- _AnimalInfoState createState() => _AnimalInfoState();
- }
- class _AnimalInfoState extends State<AnimalInfo> {
- Animal animal;
- Gin gin;
- @override
- void initState() {
- super.initState();
- // Get the animal document from Firestore
- Firestore.instance
- .collection('animals')
- .where('qrCodeResult', isEqualTo: widget.qrCodeResult)
- .get()
- .then((querySnapshot) {
- if (querySnapshot.documents.isNotEmpty) {
- setState(() {
- animal = Animal(
- name: querySnapshot.documents[0]['name'],
- description: querySnapshot.documents[0]['description'],
- imageUrl: querySnapshot.documents[0]['imageUrl'],
- );
- });
- }
- });
- // Get the gin document from Firestore
- Firestore.instance
- .collection('gins')
- .where('qrCodeResult', isEqualTo: widget.qrCodeResult)
- .get()
- .then((querySnapshot) {
- if (querySnapshot.documents.isNotEmpty) {
- setState(() {
- gin = Gin(
- name: querySnapshot.documents[0]['name'],
- description: querySnapshot.documents[0]['description'],
- imageUrl: querySnapshot.documents[0]['imageUrl'],
- );
- });
- }
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Animal Info'),
- ),
- body: Center(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- Text('Animal Name: ${animal?.name ?? ''}'),
- Text('Animal Description: ${animal?.description ?? ''}'),
- Image.network(animal?.imageUrl ?? ''),
- SizedBox(height: 20),
- Text('Gin Name: ${gin?.name ?? ''}'),
- Text('Gin Description: ${gin?.description ?? ''}'),
- Image.network(gin?.imageUrl ?? ''),
- ],
- ),
- ),
- );
- }
- }
[text] Sips for qr
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: