Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
[flutter]: hide scrollbar after stop scrolling
appflowyed412ab63a3c
diff --git a/app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dart b/app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dartindex 8a23dd460f..921eca1342 100644--- a/app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dart+++ b/app_flowy/packages/flowy_infra_ui/lib/style_widget/scrolling/styled_scroll_bar.dart@@ -1,4 +1,6 @@import 'dart:math';+import 'dart:async';+import 'package:async/async.dart';import 'package:flowy_infra/size.dart';import 'package:flowy_infra/theme.dart';import 'package:flowy_infra_ui/widget/mouse_hover_builder.dart';@@ -38,10 +40,34 @@ class StyledScrollbar extends StatefulWidget {class ScrollbarState extends State<StyledScrollbar> {double _viewExtent = 100;+ CancelableOperation? _hideScrollbarOperation;+ bool hideHandler = false;@overridevoid initState() {- widget.controller.addListener(() => setState(() {}));+ // widget.controller.addListener(() => setState(() {}));+ widget.controller.position.isScrollingNotifier.addListener(+ () {+ if (!mounted) {+ return;+ }+ _hideScrollbarOperation?.cancel();+ if (!widget.controller.position.isScrollingNotifier.value) {+ // scroll is stopped+ _hideScrollbarOperation = CancelableOperation.fromFuture(+ Future.delayed(const Duration(seconds: 2), () {+ // Opti: hide with animation+ hideHandler = true;+ setState(() {});+ }),+ );+ } else {+ // Do nothing+ hideHandler = false;+ setState(() {});+ }+ },+ );super.initState();}@@ -106,6 +132,10 @@ class ScrollbarState extends State<StyledScrollbar> {}// Hide the handle if content is < the viewExtentvar showHandle = contentExtent > _viewExtent && contentExtent > 0;+ if (hideHandler) {+ showHandle = false;+ }+// Handle colorvar handleColor = widget.handleColor ?? (theme.isDark ? theme.bg2.withOpacity(.2) : theme.bg2);// Track color