我正在尝试获取 NestedScrollView 的滚动方向(向上/向下),以便我的小部件之一可以做出相应的反应。
我已经使用了NotificationListener小部件并尝试打印它返回的axisDirection,但当我向两个方向滚动时它只返回“向下”。显然,这就是它应该的行为方式,但是,Flutter 中似乎没有任何方法可以知道如何获取滚动方向。有没有办法获取滚动方向,无论是 AxisDirection 还是 bool ?
@override
Widget build(BuildContext context) {
return Container(
color: Colors.black,
child: SafeArea(
child: Scaffold(
backgroundColor: Color.fromARGB(255, 22, 22, 22),
body: NotificationListener<ScrollStartNotification>(
onNotification: (ScrollNotification scrollInfo) {
print("scrollInfo up ===== ${scrollInfo.metrics.axisDirection}");
},
child: NotificationListener<ScrollStartNotification>(
onNotification: (ScrollNotification scrollInfo) {
if (scrollInfo.metrics.axisDirection == AxisDirection.down) {
print(
"scrollViewColtroller down == ${scrollViewColtroller.position.axisDirection}");
}
},
child: NestedScrollView(
controller: scrollViewColtroller,
headerSliverBuilder:
(BuildContext context, bool boxIsScrolled) {
return <Widget>[
SliverAppBar(
floating: true,
snap: true,
pinned: false,
elevation: 10,
)
];
}, …Run Code Online (Sandbox Code Playgroud) 直接分配二进制值和十六进制值时,可以分别执行以下操作:
uint8_t val1 = 0b10101;
uint8_t val2 = 0xFF;
Run Code Online (Sandbox Code Playgroud)
什么是0b和0x是什么意思?特别是前面的0。您可以使用其他值代替0吗?
另外一个有趣的问题是,在“ b”和“ x”的地方还有哪些其他字符?以八进制为例吗?
我是编程的新手,我想制作一个从Vb Script的列表中随机选择名称或句子的程序。
这是列表:
Jacob
James
Jason
Caleb
Ashlee
John
Run Code Online (Sandbox Code Playgroud)
该程序需要从该列表中选择一个随机名称。
如果有人可以提供帮助,我将非常感谢,谢谢