fluttersnackbar

Text in SnackBar: not selectable for copy/paste


 SnackBar snackBar = SnackBar(
          showCloseIcon: true,
          duration: 100,
          content: Text('Hello World'),
        );

Text in SnackBar: not selectable for copy/paste by mouse or tap. Is there a way to enable text selection?


Solution

  • Text is not selectable by default.

    If you want to make your Text selectable, you need to use SelectableText for that.

     SnackBar snackBar = SnackBar(
              showCloseIcon: true,
              duration: 100,
              content: SelectableText('Hello World'),
            );
    

    If you want to make an area selectable you can wrap your Widget with SelectionArea.

     SnackBar snackBar = SnackBar(
              showCloseIcon: true,
              duration: 100,
              content: SelectionArea (
                  child: Text('Hello World'),
            );