A variety of useful plug-ins and third party libraries are available during Flutter development. Mastering the right third party libraries for a Flutter project is a must for anyone who is just starting out.

This post will share information on how to properly reference and update the installation of a third library or plugin in the Flutter project.

Methods that reference and install third-party libraries

Open the project and find the pubspec.yaml file in the directory structure of the project file. Then locate the dependencies node and add the library name and version number to the dependencies node.

The sample

Introduce the usual tripartite libraries for Flutter: dio library and image selection library. The details are as follows:

Dio: ^2.1.7 # image_picker: ^0.6.7+21 #Copy the code

Pull declared third-party libraries to the project local

After the introduction of the third-party libraries, the work is not finished. You need to pull the third-party libraries from the Internet to the local site of the project according to the terminal command as follows: flutter Packages get

You can import and install the third-party library using the preceding terminal commands.

The instance

After the third party library is introduced, it will be used in the project as follows:

import 'package:flutter/material.dart'; import 'package:image_picker/image_picker.dart'; void main() => runApp(new MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( title: 'Hello Flutter', home: new Scaffold(appBar: new appBar (title: new Text(' Hello Flutter'),), body: new Center( GestureDetector( onTap: _pickImage, child: Container( width: 150, height: 85, // It doesn't work to set rounded corners in the decorator, it should be set in the background inside the decorator. Borderradius.circular (10), // Set rounded corners, image does not have this property //fit fills image: DecorationImage(image: _avataFile == null? AssetImage('images/shenfen_a.png') : FileImage(_avataFile), fit: boxfit.cover),),,),),); }} void _pickImage() async {// ImageSource. Gallery PickedFile file = await ImagePicker().getimage (source: ImageSource.gallery); setState(() { _avataFile = File(file.path); }); }Copy the code

The above is all the content of this chapter. Welcome to pay attention to the wechat public account of Sanzhan “Program Ape by Sanzhan”, and the Sina Weibo account of Sanzhan “Sanzhan 666”, welcome to pay attention!