modify layout and add function to print error and text translate
This commit is contained in:
@@ -17,7 +17,7 @@ class WordsScreen extends StatefulWidget {
|
||||
class _WordsScreenState extends State<WordsScreen> {
|
||||
Future<Word> fetchWord() async {
|
||||
final response = await http.get(
|
||||
Uri.parse("https://5ddc-37-101-56-133.ngrok-free.app/api/words/tasto"));
|
||||
Uri.parse("https://9152-37-101-56-133.ngrok-free.app/api/words/tasto"));
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
return Word.fromJson(jsonDecode(response.body));
|
||||
@@ -32,12 +32,12 @@ class _WordsScreenState extends State<WordsScreen> {
|
||||
future: fetchWord(),
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasData) {
|
||||
// Display the fetched joke when data is available
|
||||
return Center(child: Text(
|
||||
// Display the fetched Word when data is available
|
||||
return Text(
|
||||
snapshot.data!.translation,
|
||||
style: TextStyle(fontSize: 30, color: Colors.grey[800])
|
||||
)
|
||||
);
|
||||
style: const TextStyle(fontSize: 30, color: Color(0xFFFFFFFF),fontWeight: FontWeight.bold)
|
||||
);
|
||||
|
||||
} else if (snapshot.hasError) {
|
||||
// Display an error message if there's an error
|
||||
return Text('${snapshot.error}');
|
||||
|
||||
Reference in New Issue
Block a user