00:00 歌词:
00:25 我要穿越这片沙漠
00:28 找寻真的自我
00:30 身边只有一匹骆驼陪我
00:34 这片风儿吹过
00:36 那片云儿飘过
loadData() async {
var jsonStr =
await DefaultAssetBundle.of(context).loadString('assets/subtitle.txt');
var list = jsonStr.split(RegExp('\n'));
list.forEach((f) {
if (f.isNotEmpty) {
var r = f.split(RegExp(' '));
if (r.length >= 2) {
_subtitleList.add(SubtitleEntry(r[0],r[1]));
}
}
});
setState(() {});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('弹幕'),),body: Stack(
children: <Widget>[
Positioned.fill(
child: Image.asset(
'assets/imgs/background.png',fit: BoxFit.cover,)),Positioned.fill(
child: Subtitle(
_subtitleList,selectedTextStyle: TextStyle(color: Colors.white,fontSize: 18),unSelectedTextStyle: TextStyle(
color: Colors.black.withOpacity(.6),diameterRatio: 5,itemExtent: 45,))
],);
}
@override
Widget build(BuildContext context) {
if (widget.data == null || widget.data.length == 0) {
return Container();
}
return ListWheelScrollView.useDelegate(
controller: _controller,diameterRatio: widget.diameterRatio,itemExtent: widget.itemExtent,childDelegate: ListWheelChildBuilderDelegate(
builder: (context,index) {
return Container(
alignment: Alignment.center,child: Text(
'${widget.data[index].content}',style: _currentIndex == index
? widget.selectedTextStyle
: widget.unSelectedTextStyle,);
},childCount: widget.data.length),);
}
Subtitle(
_subtitleList,unSelectedTextStyle: TextStyle(
color: Colors.black.withOpacity(.6),)
)
设置圆筒直径和主轴渲染窗口的尺寸的比,默认值是2,越小表示圆筒越圆
Subtitle(
_subtitleList,)