Created
April 16, 2021 21:33
-
-
Save thenbe/58e879e54eb44ae53dcb22c1ac31184b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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