In this article, I am going to discuss some of the most famous and useful flutter packages.
1. shared_preferences
The shared_preferences package saves data in key-value pairs in your local storage, So it is a good package if you want to store small data in your app.
Save data
SharedPreferences preferences = await SharedPreferences.getInstance();
preferences.setString("username", username); //string dta
preferences.setInt("pin", 1234); //integer data
preferences.setBool("status", true); //boolean data
preferences.setDouble("width", 11.2); //double data
Read data
SharedPreferences preferences = await SharedPreferences.getInstance();
preferences.getString("username"); //string data
preferences.getInt("username"); // integer data
preferences.getBool("status"); // boolean data
preferences.getBool("width"); // double data
Remove data
SharedPreferences preferences = await SharedPreferences.getInstance();
preferences.remove("username"); // double data
Package link: https://pub.dev/packages/shared_preferences
2. cached_network_image
The cached_network_image package gets the image from the URL and shows it in the app and also it keeps the image in cached memory for future use.
//With a placeholder
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/350x150",
placeholder: (context, url) => CircularProgressIndicator(),
errorWidget: (context, url, error) => Icon(Icons.error),
),
//Or with a progress indicator
CachedNetworkImage(
imageUrl: "http://via.placeholder.com/350x150",
progressIndicatorBuilder: (context, url, downloadProgress) =>
CircularProgressIndicator(value: downloadProgress.progress),
errorWidget: (context, url, error) => Icon(Icons.error),
),
Package link: https://pub.dev/packages/cached_network_image
3. http
The http package is used to send and receive HTTP requests and responses from the internet or in simple language you can say it is used to handle REST APIs.
var url = Uri.parse('https://example.com/whatsit/create');
var response = await http.post(url, body: {'name': 'doodle', 'color': 'blue'});
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
print(await http.read('https://example.com/foobar.txt'));
Package link: https://pub.dev/packages/http
4. webview_flutter
If want to open a web URL in your app, then it is a good option to use it provides a web view widget in a flutter.
bool _isLoading = true;
final _key = UniqueKey();
String url;
@override
Widget build(BuildContext context) {
final Completer<WebViewController> _controller =
Completer<WebViewController>();
final UserProvider userProvider = Provider.of<UserProvider>(context);
url = "https://www.c-sharpcorner.com";
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(“C# Corner"),
),
body: Stack(
children: <Widget>[
WebView(
key: _key,
initialUrl: url,
javascriptMode: JavascriptMode.unrestricted,
onWebViewCreated: (WebViewController webViewController) {
_controller.complete(webViewController);
},
onPageFinished: (finish) {
setState(() {
_isLoading = false;
});
},
),
_isLoading
? Center(
child: CircularProgressIndicator(),
)
: Stack(),
],
),
);
}

Join the conversation! Your thoughts help the community grow.