Flutter relies on the Dart programming language. It has a big and lively community on Dart.dev, offering both officially supported and third-party packages to create Flutter development even more productive.
In Flutter, the holding of shared packages is contributed by developers that enable us to create apps without much push or hustle. It saves developers from developing from the beginning. We may use classes, for instance, to request network (HTTP), custom navigation route handling in Fluro, API integration, and making use of a third-party platform.
The Dart ecosystem utilizes packages to manage shared software like libraries and tools. To receive Dart packages, you must make use of the pub package manager. You can find publicly available packages on the pub.dev site, otherwise you can load packages from the local file system or elsewhere, just like Git repositories. Wherever your packages come from, pub manages version dependencies and facilitates you to get package versions that work with one other and with your SDK version.
Most Dart-savvy IDEs offer support for using pub that comprises of creating, downloading, updating, and publishing packages. Else you can also use pub on the command line.
At a minimum, a Dart package could be a directory containing a pubspec file. The pubspec comprises of some metadata about the package. Additionally, a package can contain dependencies (listed within the pubspec), Dart libraries, apps, resources, tests, images, and examples.
To use a package, do the following:
- Create a pubspec (a file named pubspec.yaml that lists package dependencies and includes other metadata, like a version number).
- Use pub to obtain your package’s dependencies.
- If your Dart code depends on a library within the package, import the library.
This article lists the most promising and popular packages to prove you with an idea of Flutter’s maturity as a platform
Dart Packages
HTTP
Everything is web-based nowadays, so the HTTP library is a must-have thing. This Dart package comprises a group of high-level functions and classes which makes it simple to consume HTTP resources. It’s well developed and actively maintained by the Dart team. It’s been around since 2012, so it should be rock-solid!
The library offers top-level functions that make it easy to work with HTTP:
import 'package:http/http.dart' as http;# Posting data var url = 'https://example.com/whatsit/create'; var data = {'name': 'Jack', 'age': 38};var response = await http.post(url, body: data);print('Response status: ${response.statusCode}'); print('Response body: ${response.body}');# A simple GET request print(await http.read('https://example.com/foobar.txt'));
Firebase_storage
Firebase is a flutter plug-in that is used in firebase cloud storage API, which is a powerful, simple as well as cost-effective object storage service for Android as well as for iOS. To use this plug-in, add firebase_ storage as a dependency in your pubspec.yaml file. Note that this plug-in is remaining under development and a few APIs might be unavailable yet.
Flutter_slidable
The flutter_slidable plugin is attached with a feature-rich slider widget to your project. Sliders such as this are often seen in scrollable lists. The Gmail app could be seen as a noteworthy example, in which sliding list items offer a remarkable productivity enhancement.
This plugin is jam-packed with features and ready for use, but also highly customizable if needed. Some of the listed features are:
- Accepts primary (left/top) as well as a secondary (right/bottom) widget lists as slide actions
- It can be dismissed
- It has four built-in action panes
- It also comprises two built-in slide action widgets
- It has a Built-in dismiss animation
- It can easily create custom layouts and animations that are efficient when put to use.
- It automatically closes when a slide action has been tapped (overridable)
- It closes loses when the nearest Scrollable starts to scroll (overridable)
- It can be considered to be a great option to disable the slide effect easily
Shared Preferences
This package wraps platform-specific persistent storage libraries. It’s indented for easy and simple data, like user preferences, and it uses:
- NSUserDefaults on iOS and macOS
- SharedPreferences on Android
- LocalStorage on websites
- A JSON file on the local filesystem for Linux
Data could also be persisted to disk asynchronously, and no guarantee writes will be persisted to disk after returning, so this plugin isn’t meant for storing critical data.
Sqflite
This package wraps platform-specific persistent storage libraries. It is an important plug-in for flutter which supports iOS and Android development platforms. It supports transaction and batch processing. It’s automatic version management during the beginning. It has assistance for insert, query, update, delete queries. DB operations within the background thread. It’s indented for easy and simple data, like user preferences, and it uses:
- NSUserDefaults on iOS and macOS
- SharedPreferences on Android
- LocalStorage on websites
- A JSON file on the local filesystem for Linux
Data is also persisted to disk asynchronously, and no guarantee writes are going to be persisted to disk after returning, so this plugin isn’t meant for storing critical data.
Url_launcher
As the name implies, this Flutter package is employed to launch URLs in mobile apps. It supports both Android & iOS platforms and it becomes brilliantly handy and useful once you want the OS to handle the URL for you. The URL Launcher package supports multiple URL schemes like HTTP, mailto, SMS etc. This plugin helps you launch a URL. URLs will be of the following types:
- HTTP: http://example.org and https://example.org
- E-mail: mailto:<e-mail address>
- Phone numbers: tel:<phone number>
- SMS text message: sms:<phone number>
Basic usage is incredibly straightforward:
const url = 'https://flutter.dev';if (await canLaunch(url)) { await launch(url); } else { throw 'Could not launch $url'; }
Video_player
Many formats are supported, but it all depends on the platform you’re running. For Instance, the backing libraries differ for iOS and Android. Also, on the web, the supported formats rely on the browser you’re using.
Note that although it’s called video_player, this plugin can also play the audio. Since the plugin is pretty mature and has reached API stability, it’s not a bad idea to use this for audio over a number of the alternatives.
This plugin can play video from a local file (assets) and a remote server (e.g., a website).
AudioPlayers
A flutter plug-in is accustomed to playing different audio files simultaneously in Android and iOS. Start by installing dependencies as follows;
Dependencies:
audioplayers: ^0.13.0
An audioPlayer instance can play a sing audio file at a time by calling the constructor to form.
AudioPlayer audioPlayer = AudioPlayer ();
It is used for low latency API, which can serve a better experience for gaming sounds, use the following code:
AudioPlayer audioPlayer = AudioPlayer (mode: playermode.LOW_LATENCY);
Crypto
Comping from the Dart team itself, this is often a collection of cryptographic hashing functions implemented in pure Dart. This implies you don’t need external libraries to create this work.
The following hashing algorithms are supported:
- SHA-1
- SHA-224
- SHA-256
- SHA-384
- SHA-512
- MD5
- HMAC (i.e. HMAC-MD5, HMAC-SHA1, HMAC-SHA256)
Since this is not a GUI tool but simply a crypto library, it works on all supported platforms.
Carousel_slider
A carousel slider is part of many apps and websites. The carousel_slider plugin offers an excellent and customizable carousel that works on multiple platforms.
Because the carousel accepts widgets as content, you can slide anything that may be a widget.
For live examples, you can visit this website, which uses the Flutter web to demo the plugin.
Here’s an example of way to create a carousel in your app:
CarouselSlider( options: CarouselOptions(height: 400.0), items: [1,2,3,4,5].map((i) { return Builder( builder: (BuildContext context) { return Container( width: MediaQuery.of(context).size.width, margin: EdgeInsets.symmetric(horizontal: 5.0), decoration: BoxDecoration( color: Colors.amber ), child: Text('text $i', style: TextStyle(fontSize: 16.0),) ); }, ); }).toList(), )
The carousel has several configurable options, like:
- the height and aspect ratio
- enabling infinite scrolling
- reversing the carousel
- enabling autoplay with a configurable interval, animation duration
- defining the scroll direction (vertical, horizontal)
Path_provider
Paths are both easy and incredibly complicated ones because they vary from platform to platform. And to ensure you don’t introduce bugs or security vulnerabilities in your code, always remember to use the path library when dealing with paths. The path_provider package facilitates the developers to easily and quickly getting commonly used locations on Android and iOS file systems (such as temp and app data directories). By using this package you can gain the database path when using SQFlite library. It supports both internal as well as external storage and makes it easy to get directories such as documents, privates, etc. To join a directory and a file with the file separator for the current OS, use:
import 'package:path/path.dart' as p; p.join('directory', 'file.txt');
Location Plugin
One of the most important aspects of phones is their mobility combined with the ability to accurately track location. This has already given us many useful applications. The location plugin for Flutter makes it simpler to gain access to the current location. It gives callbacks when the location has changed. Not only does it give callbacks but also it offers API endpoints to properly request access to a user’s location. It is a flutter plugin that very well deals with real-time locations on iOS Android. It also provides settings for performance and battery optimization.
Conclusion
Flutter packages enable us to create applications quickly and save long hours of working to build a product. Flutter also enables the developers to publish and contribute towards flutters package development.
The long list of flutter packages has been ranked using package health, overall score, and ease of maintenance.