![]() ![]() Now, we can go ahead and run the Flutter command to generate all of the necessary files for the setup configuration: flutter pub run build_runner build -delete-conflicting-outputs LazySingleton(classType: FishSpecieService), Import 'package:flutter_share/services/share_service.dart' Import 'package:flutter_share/services/fish_species_service.dart' Next, register the services as LazySingleton in the dependencies block: import 'package:flutter_share/services/api_service.dart' Also pass in the StackedLogger to the logger parameter. Create an empty class and mark it with the annotation. In this folder, create a new file named app.dart. We’ll use the dependencies block to register our services.Ĭreate a folder called app in the lib directory, which will hold all the configuration details of our application. The annotation grants us access to two parameters, routes and dependencies. We’ll use the annotation, which comes from the Stacked package. Next, we’ll set up our routes and register the services. Create a file named fish_response_model.dart where we’ll create the FishResponseModel class and the ImageGallery model class: class FishResponseModel However, we only need the name, image, protein content, and quota.Ĭreate a folder named models in the lib directory, which will hold all the models we’ll use. From the FishWatch API documentation, we see that the API returns the name, description, image, and a host of other details. Next, we’ll set up the models for converting the data we receive. Stacked_generator: ^0.5.7 Setting up the models image_downloader: Enables us download the image file we want to share.permission_handler: Enables us to request permission to use the phone’s mobile storage.share_plus: The package we’ll use to implement the share functionality.logger: Prints important information to the debug console.stacked_generator: Generates files from stacked annotations.build_runner: Provides access to run commands for auto-generating files from annotations.stacked: An architectural solution that uses Provider under the hood, giving us access to classes that will spice up our development process.http: To make a GET request to the FishWatch API and retrieve the list of various fish species.Next, we’ll import the following dependencies in our pubspec.yaml file: The command above would create the base files that we’ll build upon for our sample application. Let’s dive right in! File sharing in operation: Sample application walkthrough Project setupĬreate a new codebase by running the command below: flutter create flutter_share We’ll fetch a list of fish species from the FishWatch API, display it in our app, then add the share functionality, enabling us to share information like the image, name, habitat, and quota of each fish specie with any other application. In this tutorial, we’ll cover how to share texts and images from our sample application to other mobile applications. Sharing files, text, and images between apps File sharing in operation: Sample application walkthrough.Sharing files, text, and images between apps.In this article, you’ll learn how to implement content sharing in Flutter applications using the Share Plus plugin. To follow along with this article, you can check out the complete source code for the sample app. Giving your users the ability to share content from your app to other applications improves the overall user experience. If you’re an avid smartphone user, odds are you’ve seen something on a mobile application that you wanted to share with a friend, for example, while browsing through your favorite social media platform or exploring items for sale. As he says, "You just have to be consistent and intentional to make it." Sharing content in Flutter apps using Share Plus He is passionate about helping people learn mobile development with Flutter and the leadership strategies they need to succeed regardless of their background. ![]() David Adegoke Follow Well known for his skills and dynamic leadership, David has led development teams building and deploying great products. ![]()
0 Comments
Leave a Reply. |