I want to send the company and type of phone to Firebase and I used
my code
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);
},
.........
CodePudding user response:
You never call _deviceDetails
RaisedButton(
onPressed: () async {
await _deviceDetails(); // <------
Map<String, dynamic> data = {
"marque":brand,
"Modele:" :Modele,
};
var myStoredData = await readData();
FirebaseFirestore.instance
.collection(myStoredData)
.add(data);
},