Custom code that allow download information from a collection in firebase (in this case I use the default users collection) in .txt format. Without paying a blaze plan in Firebase $$.
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:download/download.dart';
import 'dart:convert' show utf8;
import 'package:download/download.dart';
//If you want to download other collection
//you have to change "List<____Record> and "usuarios" is the argument that i //create
Future prueba4DescargarColeccionTXT(List<UsersRecord>? usuarios) async {
usuarios = usuarios ?? [];
String contenidoTXT = "Información de la colección users de firebase";
usuarios.asMap().forEach((index, record) => contenidoTXT = contenidoTXT +
"\n" +
"\n" +
"Correo Electrónico: " +
record.email.toString() +
"\n" +
"Nombre Completo: " +
record.displayName.toString() +
"\n" +
"Número Telefónico: " +
record.phoneNumber.toString() +
"\n");
final archivo = "InfoUsuarios.txt"; // Cambiar la extensión a .txt
var bytes = utf8.encode(contenidoTXT);
final stream = Stream.fromIterable(bytes);
return download(stream, archivo);
}
// Set your action name, define your arguments and return parameter,
// and then add the boilerplate code using the button on the right!