Skip to content

Instantly share code, notes, and snippets.

@thenbe
Created April 16, 2021 21:33
Show Gist options
  • Save thenbe/58e879e54eb44ae53dcb22c1ac31184b to your computer and use it in GitHub Desktop.
Save thenbe/58e879e54eb44ae53dcb22c1ac31184b to your computer and use it in GitHub Desktop.
import 'dart:convert';
void main() {
// sample JSON
String _userJsonInitial = '''{
"name" : "Mock",
"age" : 20,
"subscribed" : true}''';
// Define the function that will return the future
Future<Map<String, dynamic>> myJsonFutureFunction() async {
Map<String, dynamic> myDecodedJson = await json.decode(_userJsonInitial);
print(myDecodedJson);
return myDecodedJson;
}
// Now run it
myJsonFutureFunction();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment