Skip to content

Instantly share code, notes, and snippets.

@Piinks
Created August 10, 2023 19:42
Show Gist options
  • Save Piinks/06166fc4dd02f77a2775831dc7a11c3e to your computer and use it in GitHub Desktop.
Save Piinks/06166fc4dd02f77a2775831dc7a11c3e to your computer and use it in GitHub Desktop.
Mouse wheel checker
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:math' as math;
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({ super.key });
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
debugShowCheckedModeBanner: false,
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
final String title;
const MyHomePage({
Key? key,
required this.title,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Listener(
onPointerSignal: (signal) {
if (signal is PointerScrollEvent) {
print('Mouse wheel delta: ${signal.scrollDelta.dy}');
}
},
child: ListView.builder(
itemBuilder: (_, int index) => Text('Item $index')
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment