我有一个水平的import { CodemirrorComponent } from 'ng2-codemirror';
...
@ViewChild('novelEditor') private novelEditor: CodemirrorComponent;
...
removeIndentation() {
const cm = this.novelEditor.instance;
cm.replaceSelection("\n");
}
,我想强迫用户一次滚动一个项目,如何实现?
ListView
答案 0 :(得分:3)
使用
physics: PageScrollPhysics(), // in ListView
我找不到您的代码。试试这个,并进行相应的更改。
List<String> yourArray = ["A", "B", "C", "D"];
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
return Container(
height: 100,
child: ListView.builder(
physics: PageScrollPhysics(), // this is what you are looking for
scrollDirection: Axis.horizontal,
itemCount: yourArray.length,
itemBuilder: (context, index) {
return Container(
color: Colors.grey,
width: width,
child: Center(child: Text("Index = ${index}")),
);
},
),
);
}