我正在開發教育應用程式(類似于 udemy 應用程式)在講座串列螢屏中,我使用 Inkwell 顯示講座資料卡,并且 onTap(當用戶點擊卡片時)它將轉到視頻播放器頁面
講座串列頁面圖片在這里
當講座串列螢屏加載時:首先,我具有使用 http.POST 檢查每個講座的觀看次數的功能如果講座的觀看次數少于 2 次,我想讓講座卡可點擊(用戶可以再觀看一次講座)
但是如果用戶的觀看次數等于 2 我想禁用講座,以防止用戶再次觀看
我想使用 if 陳述句來檢查視圖數量然后啟用 Inkwell onTap 屬性,但它不起作用
我需要關于如何處理這種情況的幫助
======================== 觀看次數計數功能
checkViewsCount() async {
var XX = await checkLessonViews(lesson.id.toString(), lesson.lessonType);
if(int.parse(XX) >= 2){
//////////////////Here want to make lecture card disabled
} else {
//////////////////Here want to make lecture card enabled
}
}
============================ 這是 InkWell 代碼
return InkWell(
onTap: () {
setState(() {
_activeLesson = lesson;
});
lessonAction(lesson);
},
child: Column(
children: <Widget>[
Container(
padding: EdgeInsets.symmetric(
vertical: 10, horizontal: 30),
width: double.infinity,
child: Row(
children: <Widget>[
//////////////////////// Lesson No.
Expanded(
flex: 2,
child: Customtext(
text: lessonCount.toString(),
fontSize: 16
)),
//////////////////////// Lesson title
Expanded(
flex: 8,
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: <Widget>[
Customtext(
text: lesson.title,
fontSize: 14,
colors: kTextColor,
fontWeight:
FontWeight.bold,
),
getLessonSubtitle(lesson),
],
)),
],
),
),
Divider(),
],
),
);
提前致謝
uj5u.com熱心網友回復:
您不能在顫動中禁用墨水池,請使用 if 條件根據用戶擁有的視圖數量顯示墨水池或容器(沒有手勢處理屬性)。
uj5u.com熱心網友回復:
var canAddLecture = true;
if(int.parse(XX) >= 2){
canAddLecture = false;
} else {
canAddLecture = true;
}
在 onTap 中:
onTap: () {
if(canAddLecture == false) return;
setState(() {
_activeLesson = lesson;
});
lessonAction(lesson);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/317305.html
