Skip to content

Instantly share code, notes, and snippets.

@Quingsley
Created October 10, 2022 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quingsley/00334fd782dd8d9e03e2dc8085a3a347 to your computer and use it in GitHub Desktop.
Save Quingsley/00334fd782dd8d9e03e2dc8085a3a347 to your computer and use it in GitHub Desktop.
ubiquitous-durian-3116

ubiquitous-durian-3116

Created with <3 with dartpad.dev.

import 'dart:convert';
import 'package:http/http.dart' as http;
void main() async{
final List<SubSection> subsections = [];
final graphQLQuery = {
'query': '''query {
getSubsections(courseId: 16, sectionId: 16) {
id
sectionId
subtopic
orderNum
}
}'''
};
final response = await http
.post(Uri.parse('https://7522-197-232-145-163.eu.ngrok.io'),
headers: {'Content-Type': 'application/json'},
body: jsonEncode(graphQLQuery)
);
final result = jsonDecode(response.body);
final arr = result['data']['getSubsections'];
print(arr);
arr.forEach((sub) => subsections
.add(SubSection(title: sub['subtopic'],
lessons: [],
subSectionId: sub['id'])
));
print(subsections[0].title);
}
class SubSection {
String title;
int subSectionId;
List lessons;
SubSection(
{required this.title, required this.lessons, required this.subSectionId});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment