- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
因此,我创建了代码,以在按下每个视频下方的下载按钮时显示进度指示,以指示下载文件(视频)的进度。
进度指示器可以正常工作,并且可以完美显示进度。
API JSON结构:https://pastebin.com/raw/JPCyaKMn
问题:
点击视频容器下方的下载按钮后,它将显示ListView.builder中所有视频的进度。
我想只显示被点击(选定)的视频容器的进度,我该怎么做?
我的代码:
@override
Widget build(BuildContext context) {
return data != null
? WillPopScope(
onWillPop: () async => false,
child: Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SafeArea(
child: Padding(
padding: const EdgeInsets.only(
left: 10, top: 50.0, bottom: 10.0),
child: Text(
"Videos",
style: TextStyle(
color: Colors.white,
fontSize: 32.0,
fontWeight: FontWeight.w700),
),
),
),
Expanded(
child: ListView.builder(
itemCount: data.body.videos.length,
itemBuilder: (context, index) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
InkWell(
onTap: () async {},
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 20),
child: Column(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width -
40,
margin: const EdgeInsets.only(
bottom: 0, top: 20),
height: 70,
decoration: BoxDecoration(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(5),
topRight: Radius.circular(5),
bottomLeft: Radius.zero,
bottomRight: Radius.zero),
color: Colors.white,
),
),
],
),
),
),
downloading ? Padding(
padding: const EdgeInsets.symmetric(horizontal: 20),
child: LinearProgressIndicator(
value: _progress,
),
) : Container(),
Center(
child: SizedBox(
width: 128,
child: MaterialButton(
minWidth: 40,
child: Center(
child: Text(
"Download",
style: TextStyle(color: Colors.white),
),
),
height: 40,
color: Colors.red,
onPressed: () async {
_getDownload(data
.body.videos[index].backblazeVideoId);
},
),
),
),
],
);
},
),
),
],
),
resizeToAvoidBottomPadding: false,
backgroundColor: thirdcolor,
),
)
: CircularProgressIndicator();
}
// Returns a file (mp4) after the API is given credentials & the fileid of the tapped video
_getDownload(String fileid) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
String email = prefs.getString('email');
String token = prefs.getString('accesstoken');
final Directory docDir = await getExternalStorageDirectory();
String docPath = docDir.path;
File docFile = File('$docPath/$fileid.mp4');
var dio = Dio();
var response = await dio.post(
"https://api.myvideovault.com/profile/downloadVideo",
data: {
"email": email,
"token": token,
"method": "download",
"fileid": fileid
},
options: Options(contentType: "application/x-www-form-urlencoded"),
onReceiveProgress: (received, total) {
String lol = "${((received / total) * 100).toInt()} %";
double haha = received/total;
print("${received ~/ total} %");
setState(() {
downloading = true;
_progress = haha;
});
});
}
最佳答案
这里的问题是您的downloading
变量会告诉您是否正在下载所有视频。如果您将index
作为参数传递给_getDownload
并保存了名为index
的按钮的_getDownload
,这将起作用。
然后,您可以将其用作三元运算符条件以显示线性进度指示器。
关于android - 如何仅显示listview.builder的选定索引的进度/进度指示器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61451058/
我正在开发一个应用程序,我成功地消除了除一个错误之外的所有错误: no suitable constructor found for builder 更改为“意图” https://file.io/O
我可以在 C++Builder 6 中成功编译以下代码片段,但我无法在 RAD Studio Seattle 中编译它: unsigned long x = 50; String s = In
我有一个项目(新开始),其中 C++ Builder 没有在任何断点处停止。我已确保我处于 Debug模式(未发布),链接器->完整调试信息 = True,C++ 编译器->调试配置,C++ 编译器-
我们想在正在开发的 C++ builder XE 应用程序中绘制大型控制流程图。 这些图表将以编程方式生成并以交互方式显示给用户(用户可以滚动大流程图、选择节点等)。节点必须能够显示自定义组件(如 T
我有以下问题 午餐时 FlashBuilder.exe (BURRITO):它崩溃并创建一个错误日志文件,例如: hs_err_pid7084.log 及以下 但是当我咀嚼 FlashBuilderC
我有一个大型 Flash Builder 项目,它是更大 (.net) 解决方案的一部分。对于整个项目,我通常有一个前进的开发分支,以及一个或多个错误修复分支。考虑到 Flash Builder 不想
乘数(自动布局中约束的属性)有什么作用? 最佳答案 约束中两个值之间的关系由以下公式确定: b = am + c 其中 a 和 b 是要关联的两个值,m 是乘数,c code> 是常量。 例如,如果
我们的开发团队使用 Borland C++ Builder 6 和 CodeGear C++ Builder 2007(以及 Visual Studio)。我听到很多评论说 Builder 2007
我想阐明我对构建器模式的使用,特别是构建器类型是如何创建的。在示例中,它只是假定构建器的类型并创建它。但是,我在“ChartBuilderFactory”类中创建了一个 CreateBuilder 方
首先,我对 Java 比较陌生,所以我问的可能是微不足道的,但我在这里或其他地方找不到答案。 为简单起见,假设我有以下类层次结构: class Shape { protected Shape(
我试图在另一个 AlertDialog 中打开一个 AlertDialog,但它不起作用,知道为什么它不起作用吗? String items[] = {"Details","Edit","Delete
我有一个包含 Form1 和 Form2 的程序。如何单击按钮从 form1 打开 form2? 最佳答案 更多信息 在你的 Project.cpp 中有这个:Application->CreateF
每当我使用 C++ Builder(XE4 版,但以前的版本也这样做)在 Release模式下构建 Win32 EXE 时,它总是创建一个导出目录并为我的项目中的每个单元导出一个 Initialize
我正在尝试在我的试用版 flashbuilder 上启用设计模式,但找不到任何选项, 我已经查看了 Windows 菜单,但没有启用设计模式, 和首选项,但首选项对话框中没有 Flex 来启用其设计模
我目前正在将一个大型 RAD Studio 2010 项目迁移到 XE4。作为其中的一部分,我正在重新创建许多项目文件。我想借此机会确保我们对预编译头使用最好的机制,因为似乎有几种方法可以做到这一点。
我观看了“Interface Builder 中的新增功能” session 视频并尝试复制显示的代码,但不幸的是,当我将 View 分配给具有 @IBDesignable 的自定义类时,出现 2 个
这个问题在这里已经有了答案: Why is NotificationCompat needed? (3 个答案) 关闭 5 年前。 我看到的几乎所有 Android 通知示例代码似乎都使用了 Not
我正在使用 fcm 从我的 Android 应用程序发送通知,并且我已经实现了它要求我提供的所有库。 val topic = "highScores" // See docum
我正在尝试在Flash Builder 4.6中进行项目范围内的查找和替换,但是对我而言,如何实现这一点并不明显。 我试过Edit-> Find/Replace然后全部替换,但它仅替换当前打开的文件中
帮助我在 XCode4 中取消 fubar 界面构建器。 我在 interface-builder 中创建了一个按钮,并在 View 的代码中为它定义了一个 IBAction 方法。它运行良好。然后我
我是一名优秀的程序员,十分优秀!