Murtaza
Murtaza

Reputation: 61

How to add a library to flutter dependencies

I am new in flutter and I want to add Fast Android networking library to flutter dependencies and I don't know how to add, anyone, help me, please.

Upvotes: 5

Views: 20148

Answers (3)

Murtaza
Murtaza

Reputation: 549

Open the pubspec.yaml file under your root project and add your dependencies/libraries.

version: 1.0.0+1

environment:
  sdk: '>=3.0.3 <4.0.0'

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  path: ^1.8.3
  sqflite: ^2.2.8+4
  # add this line to your dependencies
  fluttertoast: ^8.2.2

dev_dependencies:
  flutter_test:
    sdk: flutter

  flutter_lints: ^2.0.0

flutter:
  uses-material-design: true

  # Enable generation of localized Strings from arb files.
  generate: true

  assets:
    # Add assets from the images directory to the application.
    - assets/images/
    - assets/database/

Upvotes: 2

user103185
user103185

Reputation: 1155

To add http package to your flutter project, from within a terminal at the project root, just type:

flutter pub add http

The latest stable version will be used.

For info on options take a look at https://dart.dev/tools/pub/cmd/pub-add

Upvotes: 5

Mwase
Mwase

Reputation: 1032

It is very simple to add a package in flutter dependencies. What you need to do is place it under the dependencies: inside the pubspec.yaml file.

So open the pubspec.yaml. You will find this file in root project folder of your flutter app. And do the following to add new dependencies/libraries:

dependencies:
  flutter:
    sdk: flutter
  # dependencies come below here
  example_dependency: ^3.2.0+1 // at the end is the version of the depenency
  second_example_dependecy: any // 'any' for any version of the dependecy

To find or discover new libraries for flutter and dart to help you in building your app you can find flutter and dart packages here.

Upvotes: 9

Related Questions