Search code examples
flutterflutter-layoutflutter-dependenciesmobile-applicationdart-pub

Sharing Listview in flutter?


I am new to flutter. I have a scrollable list to share via WhatsApp or mail. So, How can I share this List as Image or Text? Or is there any way to share the entire page(Scrollable) as an image or text? suggest methods to do this.


Solution

  • You can create a String of your data shown in the list and share it via the Share Package.

    Share Package: https://pub.dev/packages/share

    Exapmle:

    Share.share('Here insert your created String');
    

    After running this line of code it opens the share screen of your phone and you can choose if you want to share it via WhatsApp or so.

    Edit: Creating a List inside a String

    String list = '';
    itemList.forEach((item) {
        if(item.isChecked) {
            list += '-';
            list += item.title;
            list += '\n';
        }
    });