This article explains how to export a text content, json list or object in an flutter application to the device. See the following image for a preview.

Here we used the following code:

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 {…



This article is to show you the basic operations to convert JSON objects in dart flutter.

Photo by Ferenc Almasi on Unsplash

JSON Object to String

import 'dart:convert';

After the import, you can add the following code or wrap it around a function.

const data = {'text': 'foo', 'value': 2, 'status': false};
final String jsonString = jsonEncode(data);
// Output
// {"text":"foo","value":2,"status":false,"extra":null}

String to JSON Object

To convert a String into a object in dart use the following code:

const String responseAPIData = '[{"id":1,"name":"Service1"},{"id":2,"name":"Service2"}]';final dataResp = json.decode(responseAPIData);// Print the name of the second product in the list     print(dataResp[1]['name']);
// Output -> Service2

JSON Object to Dart Class

if you need to convert your JSON object to a dart class to modify each attribute sepatly then the following website should be good to use:





If you like my work or have question contact me.