Last active
December 12, 2021 16:43
-
-
Save csells/cf880582fae9f6c2a908c1500ffb2b6b to your computer and use it in GitHub Desktop.
Revisions
-
csells revised this gist
Dec 8, 2021 . 1 changed file with 0 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,3 @@ class UserListView extends StatelessWidget { UserListView({Key? key}) : super(key: key); -
csells created this gist
Dec 8, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,58 @@ import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:flutterfire_ui/firestore.dart'; void main() { runApp(MaterialApp(home: UserListView())); } class UserListView extends StatelessWidget { UserListView({Key? key}) : super(key: key); // live Firestore query final usersCollection = FirebaseFirestore.instance.collection('users'); @override Widget build(BuildContext context) => Scaffold( appBar: AppBar(title: const Text('Contacts')), body: FirestoreListView<Map>( query: usersCollection, pageSize: 15, primary: true, padding: const EdgeInsets.all(8), itemBuilder: (context, snapshot) { final user = snapshot.data(); return Column( children: [ Row( children: [ CircleAvatar( child: Text((user['firstName'] ?? 'Unknown')[0]), ), const SizedBox(width: 8), Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ Text( '${user['firstName'] ?? 'unknown'} ' '${user['lastName'] ?? 'unknown'}', style: Theme.of(context).textTheme.subtitle1, ), Text( user['number'] ?? 'unknown', style: Theme.of(context).textTheme.caption, ), ], ), ], ), const Divider(), ], ); }, ), ); }