[英]Flutter- best widget to implement video feature like Instagram
I want to implement feature like Instagram story.我想实现像 Instagram 故事这样的功能。 I was wondering what widget comes into play in this situation.我想知道在这种情况下什么小部件会起作用。 What I was thinking is horizontal list view or dismissible.我在想的是水平列表视图或可关闭。 But since each video has to be initialized before playing and I want go to next video or go back to previous video and play it as quick as possible.但是由于每个视频都必须在播放前初始化,我想转到下一个视频或返回上一个视频并尽可能快地播放。 So, I want to ask what is the possibly best way to do this.所以,我想问一下什么是最好的方法来做到这一点。 Can someone please share your thoughts?有人可以分享您的想法吗? Any help is highly appreciated!任何帮助表示高度赞赏!
When I started learning flutter, the first app I wrote was this one .当我开始学习 flutter 时,我写的第一个应用就是这个。 The step-by-step of how to create this app is in the flutter website.如何创建此应用程序的分步说明位于 flutter 网站中。
This app use the english_words package to generate random Startup names.这个应用程序使用english_words包来生成随机启动名称。 There's a logic in the middle of the code that load the rest of content when certain quantity of lines is processed.代码中间有一个逻辑,可以在处理一定数量的行时加载其余内容。
Widget _buildSuggestions() {
return ListView.builder(
padding: const EdgeInsets.all(16.0),
// The itemBuilder callback is called once per suggested word pairing,
// and places each suggestion into a ListTile row.
// For even rows, the function adds a ListTile row for the word pairing.
// For odd rows, the function adds a Divider widget to visually
// separate the entries. Note that the divider may be difficult
// to see on smaller devices.
itemBuilder: (context, i) {
// Add a one-pixel-high divider widget before each row in theListView.
if (i.isOdd) return Divider();
// The syntax "i ~/ 2" divides i by 2 and returns an integer result.
// For example: 1, 2, 3, 4, 5 becomes 0, 1, 1, 2, 2.
// This calculates the actual number of word pairings in the ListView,
// minus the divider widgets.
final index = i ~/ 2;
// If you've reached the end of the available word pairings...
if (index >= _suggestions.length) {
// ...then generate 10 more and add them to the suggestions list.
_suggestions.addAll(generateWordPairs().take(10));
}
return _buildRow(_suggestions[index]);
}
);
}
It will make the app generate new lines when the user get to end of list.当用户到达列表末尾时,它将使应用程序生成新行。 You could maybe take a look at this how-to.你也许可以看看这个操作方法。 You could implement the logic for play/stop video on that part of code.您可以在该部分代码上实现播放/停止视频的逻辑。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.