The Pub file represents package file in flutter project. Every Pubspec.yaml contains important information about flutter project meta data and dependencies. The Pubspec.yaml file written in YAML(Yaml Ain’t Markup Language). In flutter when we want to use images from local app directory then we should put the Assets/Images folder path in Pubspec.yaml file to notify the project that we have included some new folders in it. So in this tutorial we would Add Assets Images Folder Path in Pubspec.yaml File iOS Android Tutorial.
Contents in this project Add Assets Images Folder Path in Pubspec.yaml File iOS Android Tutorial:
1. Create a folder named as assets in your Flutter project like i did in below screenshot.
3. Open your Flutter project folder and locate Pubspec.yaml file.
4. Open Pubspec.yaml file in Visual Studio code editor or In android studio or Notepad editor.
5. Find the flutter: block and put assets: path below.
1 2 3 |
flutter: assets: - assets/images/ |
6. Source code of my Pubspec.yaml file after adding assets path.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
name: project description: A new Flutter project. version: 1.0.0+1 environment: sdk: ">=2.1.0 <3.0.0" dependencies: flutter: sdk: flutter cupertino_icons: ^0.1.2 dev_dependencies: flutter_test: sdk: flutter # The following section is specific to Flutter. flutter: assets: - assets/images/ uses-material-design: true |