How to only allow scrolling in SingleChildScrollView with two fingers with dart

Viewed 51

I have a drawing app with a PaintingBoard. Is there a way to disable scrolling when interacting with the PaintingBoard. And only allow the page to scroll when the user uses two fingers to scroll?

I've set the available space to draw 5 x the hight of the screen. I want to user to paint normally, and when they want more space they can scroll down with two fingers

import 'package:flutter/material.dart';
import 'package:flutter_painting_tools/flutter_painting_tools.dart';

class WhiteBoardScreen extends StatefulWidget {
  const WhiteBoardScreen({Key? key}) : super(key: key);

  @override
  State<WhiteBoardScreen> createState() => _WhiteBoardScreenState();
}

class _WhiteBoardScreenState extends State<WhiteBoardScreen> {
  final GlobalKey _paintingBoardKey = GlobalKey();
  final PaintingBoardController _controller = PaintingBoardController();
  bool _lightMode = false;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SingleChildScrollView(
        physics: const ClampingScrollPhysics(),
        child: PaintingBoard(
          key: _paintingBoardKey,
          boardBackgroundColor: _lightMode ? Colors.white : Colors.black54,
          boardHeight: MediaQuery.of(context).size.height * 5,
          controller: _controller,
        ),
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }
}

0 Answers
Related