Flutter is Google’s toolkit for creating beautiful natively compiled applications for Mobile, Web, and Desktop devices from a single code base.
Flutter is based on the Dart programming language.
It has a large and vibrant community on Dart.dev, which offers both officially supported and third-party packages to make Flutter development even more productive.
What a Flutter Packages and Toolkit are
A Flutter package is a container that contains a set of features.
These features can be groups of classes, interfaces, or sub-packages.
In practice, we can see packages as folders on a computer within which we organize our content.
With Flutter, you primarily use Dart as your programming language.
In Dart, packages are used to organize and share a set of features allowing us to develop an App without developing everything from scratch.
This article lists the most promising and popular Flutter packages to give an idea of Flutter’s maturity as a platform.
HTTP
URL: https://pub.dev/packages/http
Works on: iOS, Android, Web
Everything is web-based these days, so a solid HTTP library is a must-have.
This Dart package contains several high-level functions and classes that simplify the use of HTTP resources.
HTTP is well developed and actively managed by the Dart team.
It has been around since 2012, which makes it rock solid!
The library offers high-level functions that simplify working 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'));
flutter_slidable
URL: https://pub.dev/packages/flutter_slidable
Works on: iOS, Android, Web
The flutter_slidable plug-in boosts your project by adding a feature-rich slider widget.
We can often see sliders like this in scrollable lists.
The Gmail App is a perfect example, where scrollable list items offer a significant productivity improvement.
This plug-in is feature-rich and ready to use but also highly customizable if needed.
These are some of the features of the flutter_slidable plug-in:
- Accepts main (left/top) and secondary (right/bottom) widget lists as slide actions.
- Can be uninstalled.
- Four built-in action panes.
- Two built-in slide action widgets.
- Built-in deletion animation.
- Easily create customized layouts and animations.
- Closes when a slide action has been touched (overridable).
- Closes when the nearest slide starts scrolling (overridable).
- Option to easily disable the slide effect.
shared_preferences
URL: https://pub.dev/packages/shared_preferences
Works on: iOS, Android, Web, Linux
This package encapsulates platform-specific persistent storage libraries.
It is indented for simple data, such as user preferences, and uses:
- NSUserDefaults on iOS and macOS.
- SharedPreferences on Android.
- LocalStorage on websites.
- JSON file on the local file system for Linux.
Data can be stored on a disk asynchronously, and there is no guarantee that writes will be kept on the disk after return, so this plug-in is not meant for storing critical data.
For that, you usually use sqflite, which we discuss in the next point.
sqflite
URL: https://pub.dev/packages/sqflite
Works on: iOS, Android, macOS
Sqflite is the SQLite plug-in for Flutter.
It supports iOS, Android, and macOS.
The Web is not supported as there is no SQL-based persistence in web browsers.
Some of its features are:
- Transaction and batch support.
- Automatic version management.
- Users to insert / query / update / delete queries.
Operations run in a background thread on iOS and Android to prevent UI crashing.
url_launcher
URL: https://pub.dev/packages/url_launcher
Works on: iOS, Android, Web
This plug-in helps you to launch a URL.
URLs can be of the following types:
- HTTP: http://example.org and https://example.org
- Email: mailto:
- Phone numbers: tel:
- SMS text message: SMS:
The basic usage is straightforward:
const url = 'https://flutter.dev';
if (await canLaunch(url)) {
await launch(url);
} else {
throw 'Could not launch $url';
}
video_player
URL: https://pub.dev/packages/video_player
Works on: iOS, Android, Web
Many formats are supported, but it all depends on the platform you’re using.
For example, the support libraries differ for iOS and Android.
Also, on the Web, the supported formats depend on the browser you’re using.
Keep in mind that even though it is called video_player, this plug-in can also play audio.
Since the plug-in is relatively mature and has achieved API stability, it’s not a bad idea to use it for audio on some of the alternatives.
This plug-in can play video from a local file (resources) and a remote server (for example, a website).
crypto
Works on: all platforms
Coming from the same team as Dart, crypto is a set of cryptographic hashing functions implemented in pure Dart; this means that you don’t need any external libraries to make it work.
The following hashing algorithms are supported:
- SHA-1
- SHA-224
- SHA-256
- SHA-384
- SHA-512
- MD5HMAC (i.e. HMAC-MD5, HMAC-SHA1, HMAC-SHA256)
Since this is not a GUI tool but simply a cryptographic library, it works on all supported platforms.
carousel_slider
URL: https://pub.dev/packages/carousel_slider
Works on: iOS, Android, Web
Many Apps and websites have a carousel slider.
The carousel_slider plug-in offers an excellent and customizable carousel that works on multiple platforms.
Since the carousel accepts widgets as content, you can slide anything that can be a widget.
Here’s an example of how 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, such as:
- height and aspect ratio.
- enable infinite scrolling.
- reversing the carousel.
- enable automatic playback with a configurable interval, animation duration.
- define the scrolling direction (vertical, horizontal).
path
URL: https://pub.dev/packages/path
Works on: iOS, Android, Web
Paths differ from platform to platform.
To ensure you don’t introduce bugs or security vulnerabilities into your code, always use the path library when managing paths.
To merge a directory and file with the file separator for the current operating system, use:
import 'package:path/path.dart' as p;
p.join('directory', 'file.txt');
location
URL: https://pub.dev/packages/location
Works on: iOS, Android, Web, macOS
One of the significant advantages of phones is their mobility combined with tracking location accurately; this has already provided us with many useful applications.
The location plug-in for Flutter makes it easy to access your current location.
It provides callbacks when the location is changed.
It also offers API endpoints to request access to a user’s location correctly.