Skip to content

Commit

Permalink
Merge pull request #209 from sebastianbuechler/feature/enable-mouse-s…
Browse files Browse the repository at this point in the history
…croll

enable mouse scroll
  • Loading branch information
Frezyx authored Apr 5, 2024
2 parents 09e75c5 + af5bf86 commit 9acbb96
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/shop_app_example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import 'package:talker_flutter/talker_flutter.dart';
import 'package:talker_shop_app_example/repositories/products/products.dart';
import 'package:talker_shop_app_example/ui/presentation_frame.dart';
import 'package:talker_shop_app_example/ui/ui.dart';
import 'package:talker_shop_app_example/utils/scroll_behavior.dart';
import 'package:talker_shop_app_example/utils/utils.dart';

import 'firebase_options.dart';
Expand Down Expand Up @@ -82,6 +83,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
scrollBehavior: kIsWeb ? WebScrollBehavior() : null,
title: 'Talker shop app',
theme: lightTheme,
initialRoute: Routes.productsList,
Expand Down
25 changes: 25 additions & 0 deletions examples/shop_app_example/lib/utils/scroll_behavior.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

/// This class is used to override the default scroll behavior of the
/// [MaterialApp] widget.
///
/// The default scroll behavior of the [MaterialApp] widget is to only
/// scroll when the user is using a touch device. This class overrides
/// that behavior to allow scrolling when the user is using a mouse
/// device.
///
/// This class is used in the [MaterialApp.scrollBehavior] property.
///
/// See: https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag
class WebScrollBehavior extends MaterialScrollBehavior {
@override
Set<PointerDeviceKind> get dragDevices => {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.stylus,
PointerDeviceKind.trackpad,
PointerDeviceKind.unknown,
};
}

0 comments on commit 9acbb96

Please sign in to comment.