gpt4 book ai didi

In Flutter, the card design does not behave like an ExpansionTile when clicked(在颤动中,卡片设计在单击时并不像ExpansionTile那样工作)

转载 作者:bug小助手 更新时间:2023-10-25 21:37:45 31 4
gpt4 key购买 nike



Here's what I'm trying to do on the page I've designed; When I click on the Activities text, SuitableCards are displayed as a list in the form of ExpansionTile. But while doing this, I ran into some problems. The activities text is not written once, but writes as many elements as it pulls from the database. For example, if there are 3 files to be retrieved from the database, 'Activities' is written 3 times under each other. None of them are clicked and I don't see the list elements I'm trying to see. There is no important data in the SuitableCard widget. There is only design.

下面是我在设计页面时尝试做的事情;当我单击Activities文本时,SuitableCards以ExpansionTile的形式显示为列表。但在这样做的时候,我遇到了一些问题。活动文本不是只写一次,而是从数据库中提取尽可能多的元素。例如,如果有3个文件要从数据库中检索,则“活动”将在彼此下写入3次。它们都没有被点击,我看不到我想看到的列表元素。SuitableCard小部件中没有重要数据。只有设计。


class Suitable extends StatefulWidget {
const Suitable({super.key});

@override
State<Suitable> createState() => _SuitableState();
}

class _SuitableState extends State<Suitable> {
late dynamic suitableActivities;
late Map<dynamic, dynamic>? _user = null;

// get user from SecureStorage
void _getUser() {
AuthManager.getUser().then((value) => {
setState(() {
_user = value;
})
});
}

Future<dynamic> fetchActivities() async {
final response = await APIManager.call(
"GET", "/daily-numerology/daily-activity-analyse");
if (response["status"] == "success") {
return response["data"];
} else {
throw Exception('Failed to load activities');
}
}

@override
void initState() {
// TODO: implement initState
super.initState();
_getUser();
suitableActivities = fetchActivities();
}

@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: Container(
color: Colors.white,
child: ListView(
children: [
FutureBuilder(
future: suitableActivities,
builder: (context, snapshot) {
if (snapshot.hasData) {
final activities = snapshot.data as List<dynamic>;
return ListView.builder(
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
itemCount: activities.length,
itemBuilder: (context, index) {
return return GestureDetector(
onTap:() {
SuitableCard(
image:
'https://images.pexels.com/photos/745045/pexels-photo-745045.jpeg?auto=compress&cs=tinysrgb&w=1260&h=750&dpr=1',
title: activities[index]["title"],
cardTitle: 'Etkinlik',
);
},
child: Container(
child: Text('Activities'),
)
);
});
} else if (snapshot.hasError) {
return Text('${snapshot.error}');
}
return const Center(child: CircularProgressIndicator());
}),
],
),
),
);
}
}

更多回答
优秀答案推荐
更多回答

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com