Hitesh_jadhav

document.data()!["amount"]_error

Mar 8th, 2022
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. import 'package:cloud_firestore/cloud_firestore.dart';
  2. import 'package:firebase_auth/firebase_auth.dart';
  3. import 'package:flutter/cupertino.dart';
  4. import 'package:flutter/material.dart';
  5.  
  6. import 'add_view.dart';
  7.  
  8. class Homeview extends StatefulWidget {
  9. const Homeview({Key? key}) : super(key: key);
  10.  
  11. @override
  12. State<Homeview> createState() => _HomeviewState();
  13. }
  14.  
  15. class _HomeviewState extends State<Homeview> {
  16. @override
  17. Widget build(BuildContext context) {
  18. return Scaffold(
  19. body: Container(
  20. decoration: BoxDecoration(
  21. color: Colors.white,
  22. ),
  23. width: MediaQuery.of(context).size.width,
  24. height: MediaQuery.of(context).size.height,
  25. child: StreamBuilder(
  26. stream: FirebaseFirestore.instance
  27. .collection('Users')
  28. .doc(FirebaseAuth.instance.currentUser?.uid)
  29. .collection('Coins')
  30. .snapshots(),
  31. builder:
  32. (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
  33. if (!snapshot.hasData) {
  34. return Center(
  35. child: CircularProgressIndicator(),
  36. );
  37. }
  38. return ListView(
  39. children: snapshot.data!.docs.map((document) {
  40. return Container(
  41. child: Row(
  42. mainAxisAlignment: MainAxisAlignment.spaceEvenly,
  43. children: [
  44. Text("Coin Name: ${document.id}"),
  45. Text("Amount owned: ${document.data()!["amount"]}"),
  46. ],
  47. ),
  48. );
  49. }).toList(),
  50. );
  51. },
  52. ),
  53. ),
  54. floatingActionButton: FloatingActionButton(
  55. onPressed: () {
  56. Navigator.push(
  57. context,
  58. MaterialPageRoute(
  59. builder: (context) => Addview(),
  60. ));
  61. },
  62. child: Icon(
  63. Icons.add,
  64. color: Colors.white,
  65. ),
  66. backgroundColor: Colors.blue,
  67. ),
  68. );
  69. }
  70. }
  71.  
Advertisement
Add Comment
Please, Sign In to add comment