[Desktop] SelectableText scrollbar can't hide.

This issue has been tracked since 2023-03-18.

Test code:

ConstrainedBox(
            constraints: const BoxConstraints(maxHeight: 80),
            child: const SelectableText(
              '''ASHDGHOAIHSGOHAASHDGHOAIHSGOHAOISDH
              FGIoAOSDJASHDGHOAIHSGOHAOISDHFGIoAOSD
              JGOASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJ
              AOSDGIOAJIOSJDIOGOIIJAOSDGIOAJIOSJDI
              OASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJAO
              SDGIOAJIOSJDIOGOIGOIGOIJAOSDGIOAJIOS
              JDIOGOIOISDHFGIoASHDGHOAIHSGASHDGHOA
              IHSGOHAOISDHFGIoAOSDJGOIJAOSDGIOAJIOS
              JDIOGOIOHAOISDHFGIoAOSDJGOIJAOSDGIOA
              JIOSJDIOGOIAOSDJGOIJAOSDGIOAJIOSJDIOGOI''',
              scrollPhysics: NeverScrollableScrollPhysics(),
              style: TextStyle(overflow: TextOverflow.ellipsis),
            ),
          )

You can disable scrolling with the mouse wheel. But moving the mouse over scroll bar will show and drag-and-drop scrolling is possible.

exaby73 wrote this answer on 2023-03-20

Triage report

While I cannot scroll the view by dragging the scroll bar, I can still see it even after adding a ScrollConfiguration with MaterialScrollBehavior.scrollbars: false or adding a Scrollbar with thumbVisibility: false.

Code Sample
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(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final controller = ScrollController();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ConstrainedBox(
          constraints: const BoxConstraints(maxHeight: 80),
          child: ScrollConfiguration(
            behavior:
                const MaterialScrollBehavior().copyWith(scrollbars: false),
            child: const SelectableText(
              '''ASHDGHOAIHSGOHAASHDGHOAIHSGOHAOISDH
                FGIoAOSDJASHDGHOAIHSGOHAOISDHFGIoAOSD
                JGOASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJ
                AOSDGIOAJIOSJDIOGOIIJAOSDGIOAJIOSJDI
                OASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJAO
                SDGIOAJIOSJDIOGOIGOIGOIJAOSDGIOAJIOS
                JDIOGOIOISDHFGIoASHDGHOAIHSGASHDGHOA
                IHSGOHAOISDHFGIoAOSDJGOIJAOSDGIOAJIOS
                JDIOGOIOHAOISDHFGIoAOSDJGOIJAOSDGIOA
                JIOSJDIOGOIAOSDJGOIJAOSDGIOAJIOSJDIOGOI''',
              scrollPhysics: NeverScrollableScrollPhysics(),
            ),
          ),
        ),
      ),
    );
  }
}
Screenshot

image

chifandeyu wrote this answer on 2023-03-21

Triage report

While I cannot scroll the view by dragging the scroll bar, I can still see it even after adding a with or adding a with .ScrollConfiguration``MaterialScrollBehavior.scrollbars: false``Scrollbar``thumbVisibility: false

Code Sample

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(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key});

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  final controller = ScrollController();

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: ConstrainedBox(
          constraints: const BoxConstraints(maxHeight: 80),
          child: ScrollConfiguration(
            behavior:
                const MaterialScrollBehavior().copyWith(scrollbars: false),
            child: const SelectableText(
              '''ASHDGHOAIHSGOHAASHDGHOAIHSGOHAOISDH
                FGIoAOSDJASHDGHOAIHSGOHAOISDHFGIoAOSD
                JGOASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJ
                AOSDGIOAJIOSJDIOGOIIJAOSDGIOAJIOSJDI
                OASHDGHOAIHSGOHAOISDHFGIoAOSDJGOIJAO
                SDGIOAJIOSJDIOGOIGOIGOIJAOSDGIOAJIOS
                JDIOGOIOISDHFGIoASHDGHOAIHSGASHDGHOA
                IHSGOHAOISDHFGIoAOSDJGOIJAOSDGIOAJIOS
                JDIOGOIOHAOISDHFGIoAOSDJGOIJAOSDGIOA
                JIOSJDIOGOIAOSDJGOIJAOSDGIOAJIOSJDIOGOI''',
              scrollPhysics: NeverScrollableScrollPhysics(),
            ),
          ),
        ),
      ),
    );
  }
}

Screenshot

Thank you very much. Use your try to avoid scrollbar display.

More Details About Repo
Owner Name flutter
Repo Name flutter
Full Name flutter/flutter
Language Dart
Created Date 2015-03-06
Updated Date 2023-03-30
Star Count 151602
Watcher Count 3555
Fork Count 25000
Issue Count 11498

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date