3

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();
  }
}

Theuno de Bruin
  • 202
  • 2
  • 12
  • 1
    Does this answer your question? [ListView - Only allow double-finger scrolling and disable single-finger one (Flutter)](https://stackoverflow.com/questions/64220989/listview-only-allow-double-finger-scrolling-and-disable-single-finger-one-flu) – Nagual Sep 08 '22 at 13:49
  • Thank you for the comment, but the answer above is incomplete, will have a look to see if its usable – Theuno de Bruin Sep 08 '22 at 14:20

0 Answers0