enter image description here
在这里,我从API中获取第一张卡中的"投票"数据
我正在尝试通过按下递增和递减按钮来递增后端中的"投票"值数据(不影响Api响应)(后端我们需要通过取原始值来递增"投票"值)
我已尝试将"投票"数据存储在变量中,并在后端递增投票值,然后打印后端递增/递减值
这是密码
return Card(
child: Column(
children: [
Row(
children: [
Container(
height: 140,
width: 70,
child: Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
elevation: 5,
margin: EdgeInsets.all(5),
child: Column(
children: [
IconButton(
onPressed: () {},
icon: const Icon(Icons.arrow_drop_up,
size: 50)),
Text(result![index].voting.toString()),
IconButton(
onPressed: () {},
icon: const Icon(Icons.arrow_drop_down,
size: 45)),
const Text("Votes"),
],
),
),
),
Container(
height: 140,
width: 80,
child: Card(
semanticContainer: true,
clipBehavior: Clip.antiAliasWithSaveLayer,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.0),
),
elevation: 5,
margin: const EdgeInsets.all(5),
child: Image.network(
result[index].poster.toString(),
fit: BoxFit.fill),
),
),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(result![index].title.toString(),
style: const TextStyle(fontSize: 25)),
const SizedBox(
height: 10,
),
Text(
'Genre:${result![index].genre.toString()}'),
Text(
'Director:${result![index].director.first.toString()}'),
Text(
'Writter :${result![index].writers.first.toString()}'),
Row(
children: [
Text(result![index].runTime.toString()),
const Text("|"),
Text(result![index].language.toString()),
const Text("|"),
Text(result[index].releasedDate.toString()),
],
),
Row(
children: <Widget>[
Text(
'${result![index].pageViews.toString()} Views'),
const Text("||"),
Text(
'Voted By ${result[index].voting}people'),
],
),
],
))
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Padding(
padding: const EdgeInsets.all(10.0),
child: SizedBox(
height: 35,
width: 330,
child: ElevatedButton(
onPressed: () {},
style: TextButton.styleFrom(
primary: Colors.white,
backgroundColor: Colors.blue,
// minimumSize: const Size.fromHeight(20),// Background Color
),
child: const Text("Watch Trailor",
style: TextStyle(fontSize: 15)),
)),
),
],
),
],
),
);
},
),
),
);
}}
1条答案
按热度按时间esyap4oy1#
我会在发送请求时添加某种锁定机制,例如bool标志,下面的一些代码可以更好地解释它
现在只需在onpress上添加此方法,这样就可以维护准确的数据;