Dart Flutter export share JSON file or any file you like.

import 'dart:convert';
import 'package:share_plus/share_plus.dart';
import 'package:path_provider/path_provider.dart';
import 'dart:io';
import 'package:intl/intl.dart';
Future convertStringToFileShare(BuildContext context, String imputListAsString) async {
var filename = 'reperti_2022.par';
final temp = await getTemporaryDirectory();
final path = '${temp.path}/${filename}';

File(path).writeAsString(imputListAsString);
await Share.shareFiles([path]);
}
void main() { var fileContent = '{"text":"here is the content of the file"}';
convertStringToFileShare(fileContent);
}// call the function with the following command
// convertStringToFileShare("file content");

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store