|
@@ -1,37 +1,39 @@
|
|
|
import 'dart:convert';
|
|
|
-
|
|
|
import 'package:flutter/material.dart';
|
|
|
-import 'package:flutter_cocktail/drink_detail.dart';
|
|
|
+import 'package:flutter_cocktail/model/config.dart';
|
|
|
+import 'package:flutter_cocktail/pages/drink_detail.dart';
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
|
|
-import 'main.dart';
|
|
|
-
|
|
|
+/// Description: home page
|
|
|
+/// Time : 11/06/2023 Monday
|
|
|
+/// Author : liuyuqi.gov@msn.cn
|
|
|
class HomePage extends StatefulWidget {
|
|
|
+ const HomePage({super.key});
|
|
|
+
|
|
|
@override
|
|
|
_HomePageState createState() => _HomePageState();
|
|
|
}
|
|
|
|
|
|
class _HomePageState extends State<HomePage> {
|
|
|
- String api = "https://www.thecocktaildb.com/api/json/v1/1/filter.php?c=Cocktail";
|
|
|
+ String api =
|
|
|
+ "https://www.thecocktaildb.com/api/json/v1/1/filter.php?c=Cocktail";
|
|
|
var res, drinks;
|
|
|
|
|
|
@override
|
|
|
void initState() {
|
|
|
super.initState();
|
|
|
-
|
|
|
fetchData();
|
|
|
}
|
|
|
|
|
|
fetchData() async {
|
|
|
res = await http.get(Uri.parse(api));
|
|
|
drinks = jsonDecode(res.body)["drinks"];
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@override
|
|
|
Widget build(BuildContext context) {
|
|
|
return Container(
|
|
|
- decoration: BoxDecoration(
|
|
|
+ decoration: const BoxDecoration(
|
|
|
gradient: LinearGradient(colors: [
|
|
|
myColor,
|
|
|
Colors.orange,
|
|
@@ -39,7 +41,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
child: Scaffold(
|
|
|
backgroundColor: Colors.transparent,
|
|
|
appBar: AppBar(
|
|
|
- title: Text("Cocktail App"),
|
|
|
+ title: const Text("Cocktail App"),
|
|
|
elevation: 0.0,
|
|
|
backgroundColor: Colors.transparent,
|
|
|
),
|
|
@@ -61,14 +63,14 @@ class _HomePageState extends State<HomePage> {
|
|
|
),
|
|
|
title: Text(
|
|
|
"${drink["strDrink"]}",
|
|
|
- style: TextStyle(
|
|
|
+ style: const TextStyle(
|
|
|
fontSize: 22,
|
|
|
color: Colors.white,
|
|
|
),
|
|
|
),
|
|
|
subtitle: Text(
|
|
|
"${drink["idDrink"]}",
|
|
|
- style: TextStyle(
|
|
|
+ style: const TextStyle(
|
|
|
color: Colors.white,
|
|
|
),
|
|
|
),
|
|
@@ -83,7 +85,7 @@ class _HomePageState extends State<HomePage> {
|
|
|
);
|
|
|
},
|
|
|
)
|
|
|
- : CircularProgressIndicator(backgroundColor: Colors.white),
|
|
|
+ : const CircularProgressIndicator(backgroundColor: Colors.white),
|
|
|
),
|
|
|
),
|
|
|
);
|