【发布时间】:2021-07-17 11:30:30
【问题描述】:
我想在 Flutter 中从 Firestore 中获取联系方式,例如电话号码、电子邮件地址、网站 URL 以及社交媒体 URL。我完成了编码以直接在应用程序中显示联系方式,但我需要从 firestore 获取数据,因为如果假设我将来需要更改联系方式,这对我有好处。
我的编码
import 'package:cloud_firestore/cloud_firestore.dart';
class AboutPage extends StatelessWidget {
const AboutPage({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: LightColor.white,
appBar: CustomAppBar(
isBackButton: true,
title: customTitleText(
'Contact us',
),
),
body: ListView(
physics: BouncingScrollPhysics(),
children: <Widget>[
HeaderWidget(
'Feel free to contact us',
secondHeader: true,
),
SettingRowWidget(
"Phone",
vPadding: 0,
showDivider: false,
onPressed: () {
Utility.launchURL(///i want to display this url from firestore///
"tel:+918889999888");
},
),
HeaderWidget('Social media'),
SettingRowWidget("Facebook", showDivider: true, onPressed: () {
Utility.launchURL( ///i want to display this url from firestore///
"https://facebook.com/ecways");
}),
HeaderWidget('Website'),
SettingRowWidget("Open website", showDivider: true, onPressed: () {
Utility.launchURL( ///i want to display this url from firestore///
"https://facebook.com/");
}),
],
),
);
}
}
我创建了具有集合名称“my_contact”和文档名称“详细信息”的 firestore 数据库,还创建了电话、电子邮件、网站等字段。现在我只想知道如何使用我的编码在我的应用中显示该集合。
【问题讨论】:
-
能否发一份详细文件里面的截图。因为我想看看你是如何在其中放置字段的。
-
当然..我加了,请检查一下..
-
我将字段添加为字符串类型
-
好的,我去看看。
标签: database firebase flutter google-cloud-firestore