How do I add an Example Project to a Flutter Package?

To create a Flutter package with an Example in Android Studio

  1. Create a new Flutter Project
    enter image description here
  2. Select Flutter Package
    enter image description here
  3. After the new project opens in Android Studio, select the “Terminal” tab and then run:

flutter create example

enter image description here

  1. Select “Edit Configuration”-> add configuration -> Select the main.dart file that is located in the example/lib folder
    enter image description here
    enter image description here
    enter image description here
    enter image description here

  2. Open your example pubspec.yaml and link to the library by adding:

    your_package_name:
    path: ..\
    enter image description here

NOTE: When you open the Example folder it will look like an entire Flutter app nested into your project; that’s because it is. Just open the io and android folders to see that they share that pattern:
enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)