15,884,472 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by ago2486 (Top 8 by date)
ago2486
4-Oct-22 11:19am
View
//import 'dart:html';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:djasse_application/ecran/page_produit.dart';
import 'package:djasse_application/services/firbase_services.dart';
import 'package:djasse_application/widget/custon_action_bar.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/foundation/key.dart';
import 'package:flutter/src/widgets/framework.dart';
class pagePanier extends StatefulWidget {
const pagePanier({Key? key}) : super(key: key);
@override
State<pagepanier> createState() => _pagePanierState();
}
class _pagePanierState extends State<pagepanier> {
/*final CollectionReference _productRef =
FirebaseFirestore.instance.collection("Users");*/
/*final CollectionReference _productRef =
FirebaseFirestore.instance.collection("Produit");*/
final FirebaseServices _firebaseServices = FirebaseServices();
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: [
FutureBuilder<querysnapshot>(
future: _firebaseServices.userRef
.doc(_firebaseServices.getUserId())
.collection("Panier")
.get(),
builder: (context, snapshot) {
if (snapshot.hasError) {
return Scaffold(
body: Center(
child: Text("Erreur: ${snapshot.error}"),
),
);
}
//collection Données prêtes à être affichées
if (snapshot.connectionState == ConnectionState.done) {
//Afficher les données dans une vue de liste
return ListView(
padding: EdgeInsets.only(
top: 108.0,
bottom: 12.0,
),
children: snapshot.data!.docs.map((document) {
return GestureDetector(
/*Click pour afficher l'image ou les info de l'image dans une autre page */
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => PageProduit(
produitId: document.id,
),
),
);
},
child: FutureBuilder(
future:
_firebaseServices.productRef.doc(document.id).get(),
builder: (context,
AsyncSnapshot<documentsnapshot> productSnap) {
if (productSnap.hasError) {
return Container(
child: Center(
child: Text("${productSnap.error}"),
),
);
}
if (productSnap.connectionState ==
ConnectionState.done) {
/*Map _productmap=productSnap.data.data(); */
final _productMap = productSnap.data!;
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
),
/*height: 350.0,*/
margin: EdgeInsets.symmetric(
vertical: 12.0,
horizontal: 24.0,
),
child: Container(
child: Text("${_productMap["nom"]}"),
),
/*child: Text("Nom: ${document['nom']}"),*/
ago2486
4-Oct-22 11:19am
View
I was able to find a solution with builder: (context,
AsyncSnapshot<documentsnapshot> productSnap)
and final _productMap = productSnap.data!;
it works but i need an explanation please.
ago2486
4-Oct-22 7:27am
View
understood sir I will check it and get back to you
ago2486
4-Oct-22 6:55am
View
https://stackoverflow.com/questions/68432119/error-the-method-data-isnt-defined-for-the-class-object
ago2486
4-Oct-22 6:54am
View
In one of my searches on the internet I came across:
The problem here is that by writing Map you are actually writing Map<dynamic, dynamic=""> which will remove important type information. I will recommend just using var or final and let Dart automatically assign the best possible type for the variable:
final _productMap = productSnap.data.data();
but its not working
ago2486
4-Oct-22 6:46am
View
here is the error: The method 'data' isn't defined for the type 'Object'.
Try correcting the name to the name of an existing method, or defining a method named 'data'.
child: FutureBuilder(
future:
_firebaseServices.productRef.doc(document.id).get(),
builder: (context, productSnap) {
/*Map _productMap = productSnap.data.data();*/
if (productSnap.hasError) {
return Container(
child: Center(
child: Text("${productSnap.error}"),
),
);
}
if (productSnap.connectionState ==
ConnectionState.done) {
Map? _productMap = productSnap.data?.data();
return Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(12.0),
),
//height: 350.0,
margin: EdgeInsets.symmetric(
vertical: 12.0,
horizontal: 24.0,
),
/*child: Text("Nom: ${document['nom']}"),*/
child: Container(
child: Text("${_productMap['nom']}"),
),
);
}
},
),
ago2486
4-Oct-22 5:23am
View
Deleted
Sorry sir, I didn't understand your answer. Since I have to translate it first. I'll send you the code with your answer.
ago2486
4-Oct-22 5:16am
View
Hello sir, I have just tried two solutions but it does not work.
Show More