Browse Source

Add touch scrolling on Linux

Workaround: on Linux, touch is recognized as mouse by Flutter,
so this enables scroll by dragging with mouse.
master
Kenneth Bruen 2 years ago
parent
commit
342b870e93
Signed by: kbruen
GPG Key ID: C1980A470C3EE5B1
  1. 36
      lib/main.dart

36
lib/main.dart

@ -1,5 +1,8 @@
import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart' as f;
import 'package:flutter/cupertino.dart' as c;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart' as m;
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
@ -59,6 +62,36 @@ Map<String, WidgetBuilder> get routes => {
},
};
class DragFluentScrollBevahior extends f.FluentScrollBehavior {
const DragFluentScrollBevahior();
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
};
}
class DragCupertinoScrollBevahior extends c.CupertinoScrollBehavior {
const DragCupertinoScrollBevahior();
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
};
}
class DragMaterialScrollBevahior extends m.MaterialScrollBehavior {
const DragMaterialScrollBevahior();
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.mouse,
PointerDeviceKind.touch,
};
}
class StartPoint extends ConsumerWidget {
final String appTitle = 'Info Tren';
@ -83,6 +116,7 @@ class StartPoint extends ConsumerWidget {
// ),
// ),
),
scrollBehavior: Platform.isLinux ? const DragCupertinoScrollBevahior() : null,
routes: routes,
),
);
@ -95,6 +129,7 @@ class StartPoint extends ConsumerWidget {
accentColor: f.Colors.blue,
),
routes: routes,
scrollBehavior: Platform.isLinux ? const DragFluentScrollBevahior() : const f.FluentScrollBehavior(),
);
}
else {
@ -110,6 +145,7 @@ class StartPoint extends ConsumerWidget {
useMaterial3: true,
// fontFamily: 'Atkinson Hyperlegible',
),
scrollBehavior: Platform.isLinux ? const DragMaterialScrollBevahior() : null,
routes: routes,
);
}

Loading…
Cancel
Save