import 'dart:async';
import 'dart:html';
import 'package:flutter/material.dart';
import 'package:english_level_test/english_level_test.dart';
class EnglishLevelWidget extends StatefulWidget {
@override
_EnglishLevelWidgetState createState() => _EnglishLevelWidgetState();
}
class _EnglishLevelWidgetState extends State<EnglishLevelWidget> {
late EnglishLevelTest _englishLevelTest;
late Future<EnglishLevel> _englishLevel;
@override
void initState() {
super.initState();
_englishLevelTest = EnglishLevelTest();
_englishLevel = _englishLevelTest.getEnglishLevel();
}
@override
Widget build(BuildContext context) {
return FutureBuilder<EnglishLevel>(
future: _englishLevel,
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(
'Your English level is ${snapshot.data!.level}',
style: TextStyle(fontSize: 20),
);
} else if (snapshot.hasError) {
return Text(
'There was an error getting your English level',
style: TextStyle(fontSize: 20),
);
} else {
return CircularProgressIndicator();
}
},
);
}
}