Example of Share TextField Data to Other Apps in Flutter

Hello friends, In today’s tutorial we would learn about Share Pub package. We would share TextField entered text message to another mobile apps. Using Share package we can share TextField typed message to WhatsApp, Instagram, Message, Copy to Clipboard, Gmail, Notes and Email. So in this tutorial we would learn about Example of Share TextField Data to Other Apps in Flutter.

Contents in this project Example of Share TextField Data to Other Apps in Flutter :-

1. First of all we have to install Share Pub package in our flutter project. So open your flutter project Root directory in Command Prompt or Terminal and execute below command.

Screenshot After done installation :-

2. Open your project’s main.dart file and import material.dart and share.dart package.

3. Creating void main runApp() method and here we would call our main MyApp class.

3. Creating our main MyApp extends StatelessWidget class. Here we would call our ContentShare() class.

4. Creating ContentShare extends StatefulWidget class. In this class we would make our main child class ShareState.

5. Creating ShareState extends State<ContentShare> class.

6. Creating 2 String variables text and subject. They are used to hold Text message and text subject.

7.Creating a ASYNC type of function named as _onShare(). This function is used to share TextField message to other apps.

8. Creating Widget Build area -> Column widget and Now we would make 2 TextField widget and 1 ElevatedButton widget.

9. Complete source code for main.dart file :-

Screenshots:-

Leave a Reply

Your email address will not be published. Required fields are marked *