12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import 'dart:math';
- import 'package:flutter/material.dart';
- import 'package:fis_common/env/env.dart';
- import 'package:flutter/rendering.dart';
- import 'package:vitalapp/architecture/app_parameters.dart';
- // 用于修正工作站 鼠标滚动速度过慢的问题 [弃用]
- class AndroidScrollWrapper extends StatefulWidget {
- const AndroidScrollWrapper({
- super.key,
- required this.child,
- required this.controller,
- this.scrollSpeed = 40.0,
- });
- final Widget child;
- final ScrollController controller;
- final double scrollSpeed;
- @override
- State<AndroidScrollWrapper> createState() => _AndroidScrollWrapperState();
- }
- class _AndroidScrollWrapperState extends State<AndroidScrollWrapper> {
- FPlatformEnum get platform => FPlatform.current;
- // ScrollNotification notification;
- // @override
- // void initState() {
- // super.initState();
- // if (platform == FPlatformEnum.android &&
- // !AppParameters.data.isLocalStation) {
- // widget.controller.addListener(_onScroll);
- // }
- // }
- // @override
- // void dispose() {
- // widget.controller.removeListener(_onScroll);
- // super.dispose();
- // }
- void _onScroll() {
- ScrollDirection scrollDirection =
- widget.controller.position.userScrollDirection;
- if (scrollDirection != ScrollDirection.idle) {
- double scrollEnd = widget.controller.offset +
- (scrollDirection == ScrollDirection.reverse
- ? widget.scrollSpeed
- : -widget.scrollSpeed);
- scrollEnd = min(widget.controller.position.maxScrollExtent,
- max(widget.controller.position.minScrollExtent, scrollEnd));
- widget.controller.jumpTo(scrollEnd);
- }
- }
- @override
- Widget build(BuildContext context) {
- // if (platform == FPlatformEnum.android) {
- // // 如果是安卓,需要监听滚动事件,加速安卓上鼠标的滚动
- // return NotificationListener<ScrollNotification>(
- // onNotification: (ScrollNotification notification) {
- // if (notification is ScrollUpdateNotification) {
- // widget.controller.jumpTo(
- // widget.controller.offset + (notification.scrollDelta ?? 0));
- // }
- // return true;
- // },
- // child: widget.child,
- // );
- // }
- return widget.child;
- }
- }
|