Download Base64 File Flutter [verified] May 2026

Add to your AndroidManifest.xml if saving to public folders.

No specific permission is needed for the application documents directory, but you may need LSSupportsOpeningDocumentsInPlace in your Info.plist to let users see the files in the "Files" app. How to save Base64 String to file and view it using Flutter download base64 file flutter

import 'dart:convert'; import 'dart:typed_data'; // Your Base64 string (ensure you strip any "data:application/pdf;base64," prefix) String base64String = "JVBERi0xLjQKJeLj..."; Uint8List bytes = base64Decode(base64String); Use code with caution. Add to your AndroidManifest

For mobile, you need the path_provider package to find valid storage directories. For mobile, you need the path_provider package to

import 'dart:io'; import 'package:path_provider/path_provider.dart'; Future downloadBase64File(String base64String, String fileName) async { // 1. Decode Uint8List bytes = base64Decode(base64String); // 2. Get Directory (e.g., Documents or Downloads) // Note: For public Downloads on Android, consider using a specialized package Directory dir = await getApplicationDocumentsDirectory(); String filePath = '${dir.path}/$fileName'; // 3. Write File File file = File(filePath); await file.writeAsBytes(bytes); print("File saved to: $filePath"); } Use code with caution.