Download function not working anymore after latest FF update

Custom Code

I have a weird issue roughly since the latest FF update to 4.1.63 (or before, not sure).

What I expect: Pressing the button triggers custom fuction to parse firebase data to csv and downloads it.

My issue: The function works as expected as a web app (PWA) and used to work as an APK on my Samsung Galaxy S22. But since a few days it doesn't work on APK anymore.

This my code:

// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/backend/schema/structs/index.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 'dart:convert' show utf8;
import 'package:download/download.dart';
import 'dart:async';
import 'dart:convert';

Future downloadCollectionAsCSV(
    List<AlleEintraegeRecord>? firebaseAllDocs, dynamic verkuendigerMap) async {
  firebaseAllDocs = firebaseAllDocs ?? [];


  String fileContent = '\u{FEFF}status,gebiet,verkuendiger,datum';

  firebaseAllDocs.forEach((record) {
    String verkuendigerValue = record.verkuendiger.toString();
    String verkuendigerKey = verkuendigerValue;

    // Finde den entsprechenden Klartextnamen in der Mapping-JSON
    String klarname = 'Unbekannt';
    verkuendigerMap.forEach((key, value) {
      if (value['number'] == verkuendigerKey) {
        klarname = key;
      }
    });

    fileContent += "\n" +
        record.status.toString() +
        "," +
        record.gebiet.toString() +
        "," +
        klarname.toString() +
        "," +
        record.datum.toString();
  });

  final fileName = "helferlein_" + DateTime.now().toIso8601String() + ".csv";

// Encode the string as a List<int> of UTF-8 bytes
  List<int> bytes = utf8.encode(fileContent);

  // Create a StreamController to stream the bytes
  final StreamController<int> controller = StreamController<int>();

  // Add bytes to the stream
  controller.addStream(Stream.fromIterable(bytes)).then((_) {
    controller.close(); // Close the stream once all bytes are added
  });

  // Return the download with the stream
  return download(controller.stream, fileName);
}
What have you tried so far?

I put notifications in the action chain to verify that it goes through till the end (which it does).

I checked the pubspec dependencies and it doesn't seem to have any trouble.

I installed the PWA Version on my Samsung S22 and it works as expected!

I checked for any necessary persmissions, but the app doesn't need any special permissions.

Did you check FlutterFlow's Documentation for this topic?
Yes
2
2 replies