import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:flutter/material.dart'; import 'package:physigo/challenges/challenges_utils.dart'; import 'package:physigo/challenges/challenge.dart'; class ChallengePage extends StatelessWidget { const ChallengePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder>>( future: ChallengesUtils.getChallenge(), builder: (context, snapshot) { switch (snapshot.connectionState) { case ConnectionState.waiting: return const Center( child: Text('Getting challenges...'), ); case ConnectionState.done: if (snapshot.hasError) { return const Text('Error occurred'); } if (snapshot.hasData) { return buildChallenge(snapshot.data!, context); } return const Text('No data'); default: return const Text('Dunno'); } }, ), ); } }