Added inital API call. Downloads and parses event info.
This commit is contained in:
parent
a5603f21f1
commit
ae70712e7c
2 changed files with 24 additions and 7 deletions
|
|
@ -1,9 +1,8 @@
|
||||||
// login.dart
|
// login.dart
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'login.dart';
|
||||||
|
|
||||||
class EventPicker extends StatelessWidget {
|
class EventPicker extends StatelessWidget {
|
||||||
const EventPicker({super.key});
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
|
|
@ -12,9 +11,6 @@ class EventPicker extends StatelessWidget {
|
||||||
backgroundColor: const Color.fromARGB(255, 19, 81, 179),
|
backgroundColor: const Color.fromARGB(255, 19, 81, 179),
|
||||||
iconTheme: const IconThemeData(color: Colors.white),
|
iconTheme: const IconThemeData(color: Colors.white),
|
||||||
),
|
),
|
||||||
body: Center(
|
|
||||||
child: Text('Login Page Content'),
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
} // Call the function with the apiKey
|
||||||
}
|
}
|
||||||
|
|
@ -2,7 +2,27 @@ import 'package:flutter/material.dart';
|
||||||
import 'eventpicker.dart';
|
import 'eventpicker.dart';
|
||||||
import 'package:http/http.dart' as http;
|
import 'package:http/http.dart' as http;
|
||||||
import 'dart:convert';
|
import 'dart:convert';
|
||||||
import 'eventpicker.dart';
|
|
||||||
|
void getData(String apiKey, teamNumber) async {
|
||||||
|
final response = await http.get(
|
||||||
|
Uri.parse('https://www.thebluealliance.com/api/v3/team/frc$teamNumber/events/2025'),
|
||||||
|
headers: {
|
||||||
|
'X-TBA-Auth-Key': apiKey,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if (response.statusCode == 200) {
|
||||||
|
String data = response.body;
|
||||||
|
var decodedData = jsonDecode(data);
|
||||||
|
List<String> eventNames = [];
|
||||||
|
|
||||||
|
for (var event in decodedData) {
|
||||||
|
eventNames.add(event['name']);
|
||||||
|
}
|
||||||
|
print(eventNames);
|
||||||
|
} else {
|
||||||
|
print(response.statusCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
|
@ -79,6 +99,7 @@ class _LoginPageState extends State<LoginPage> {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
String teamNumber = _teamNumberController.text;
|
String teamNumber = _teamNumberController.text;
|
||||||
String apiKey = _apiKeyController.text;
|
String apiKey = _apiKeyController.text;
|
||||||
|
getData(apiKey, teamNumber);
|
||||||
Navigator.push(
|
Navigator.push(
|
||||||
context,
|
context,
|
||||||
MaterialPageRoute(builder: (context) => EventPicker()),
|
MaterialPageRoute(builder: (context) => EventPicker()),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue