Add touch scrolling on Linux
Workaround: on Linux, touch is recognized as mouse by Flutter, so this enables scroll by dragging with mouse.
This commit is contained in:
		
							parent
							
								
									0647f260db
								
							
						
					
					
						commit
						342b870e93
					
				
					 1 changed files with 36 additions and 0 deletions
				
			
		| 
						 | 
					@ -1,5 +1,8 @@
 | 
				
			||||||
 | 
					import 'dart:io';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import 'package:fluent_ui/fluent_ui.dart' as f;
 | 
					import 'package:fluent_ui/fluent_ui.dart' as f;
 | 
				
			||||||
import 'package:flutter/cupertino.dart' as c;
 | 
					import 'package:flutter/cupertino.dart' as c;
 | 
				
			||||||
 | 
					import 'package:flutter/gestures.dart';
 | 
				
			||||||
import 'package:flutter/material.dart' as m;
 | 
					import 'package:flutter/material.dart' as m;
 | 
				
			||||||
import 'package:flutter/services.dart';
 | 
					import 'package:flutter/services.dart';
 | 
				
			||||||
import 'package:flutter/widgets.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 {
 | 
					class StartPoint extends ConsumerWidget {
 | 
				
			||||||
  final String appTitle = 'Info Tren';
 | 
					  final String appTitle = 'Info Tren';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -83,6 +116,7 @@ class StartPoint extends ConsumerWidget {
 | 
				
			||||||
            //   ),
 | 
					            //   ),
 | 
				
			||||||
            // ),
 | 
					            // ),
 | 
				
			||||||
          ),
 | 
					          ),
 | 
				
			||||||
 | 
					          scrollBehavior: Platform.isLinux ? const DragCupertinoScrollBevahior() : null,
 | 
				
			||||||
          routes: routes,
 | 
					          routes: routes,
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
| 
						 | 
					@ -95,6 +129,7 @@ class StartPoint extends ConsumerWidget {
 | 
				
			||||||
          accentColor: f.Colors.blue,
 | 
					          accentColor: f.Colors.blue,
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
        routes: routes,
 | 
					        routes: routes,
 | 
				
			||||||
 | 
					        scrollBehavior: Platform.isLinux ? const DragFluentScrollBevahior() : const f.FluentScrollBehavior(),
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    else {
 | 
					    else {
 | 
				
			||||||
| 
						 | 
					@ -110,6 +145,7 @@ class StartPoint extends ConsumerWidget {
 | 
				
			||||||
          useMaterial3: true,
 | 
					          useMaterial3: true,
 | 
				
			||||||
          // fontFamily: 'Atkinson Hyperlegible',
 | 
					          // fontFamily: 'Atkinson Hyperlegible',
 | 
				
			||||||
        ),
 | 
					        ),
 | 
				
			||||||
 | 
					        scrollBehavior: Platform.isLinux ? const DragMaterialScrollBevahior() : null,
 | 
				
			||||||
        routes: routes,
 | 
					        routes: routes,
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue