【问题标题】:How do you get the values that the function outputs, to send to a firebase in a flutter?你如何获得函数输出的值,并迅速发送到火力基地?
【发布时间】:2022-01-22 22:17:14
【问题描述】:

我想将公司和电话类型发送到 Firebase,我使用plugin device_info 获取信息, 但在 firebase 中,我得到如下图所示的空字段。

我的代码

import 'package:device_info/device_info.dart';
......
  String Modele ='';
  String brand ='';
  .......
  Future<void>_deviceDetails() async{
    final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin();
    try {
      var build = await deviceInfoPlugin.androidInfo;
      setState(() {
        brand = build.brand;
        Modele = build.model;
      });
    } on PlatformException {
      print('Failed to get platform version');
    }
  }
.........
 .......
                      RaisedButton(
                          onPressed: () async {
                              Map<String, dynamic> data = {
                                "marque":brand,
                                "Modele:" :Modele,
                           
                              };
                           
                          var myStoredData = await readData();
                                  FirebaseFirestore.instance
                                      .collection(myStoredData)
                                      .add(data);
                          },
                         
                   .........
            

【问题讨论】:

    标签: android firebase flutter google-cloud-firestore


    【解决方案1】:

    你永远不会打电话给_deviceDetails

    RaisedButton(
      onPressed: () async {
        await _deviceDetails(); // <------
        Map<String, dynamic> data = {
          "marque":brand,
          "Modele:" :Modele,                     
        };
        var myStoredData = await readData();
        FirebaseFirestore.instance
          .collection(myStoredData)
          .add(data);
      },
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-09-28
      • 2018-01-14
      • 2016-09-17
      • 1970-01-01
      • 2018-10-27
      • 2017-12-14
      • 2016-10-16
      相关资源
      最近更新 更多