├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── dev │ │ │ │ └── music │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── assets ├── icons │ └── splashIcon.png ├── images │ ├── 1.png │ ├── 10.png │ ├── 11.png │ ├── 12.png │ ├── 13.png │ ├── 2.png │ ├── 3.png │ ├── 4.png │ ├── 5.png │ ├── 6.png │ ├── 7.png │ ├── 8.png │ └── 9.png └── svgs │ ├── drawer.svg │ ├── loop.svg │ ├── more.svg │ ├── next.svg │ ├── notification-bell-new-svgrepo-com.svg │ ├── notification.svg │ ├── pause.svg │ ├── play.svg │ ├── prev.svg │ └── search.svg ├── demo.png ├── demo1.png ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings ├── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── Contents.json │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ ├── Icon-App-20x20@1x.png │ │ │ ├── Icon-App-20x20@2x.png │ │ │ ├── Icon-App-20x20@3x.png │ │ │ ├── Icon-App-29x29@1x.png │ │ │ ├── Icon-App-29x29@2x.png │ │ │ ├── Icon-App-29x29@3x.png │ │ │ ├── Icon-App-40x40@1x.png │ │ │ ├── Icon-App-40x40@2x.png │ │ │ ├── Icon-App-40x40@3x.png │ │ │ ├── Icon-App-60x60@2x.png │ │ │ ├── Icon-App-60x60@3x.png │ │ │ ├── Icon-App-76x76@1x.png │ │ │ ├── Icon-App-76x76@2x.png │ │ │ └── Icon-App-83.5x83.5@2x.png │ │ └── LaunchImage.imageset │ │ │ ├── Contents.json │ │ │ ├── LaunchImage.png │ │ │ ├── LaunchImage@2x.png │ │ │ ├── LaunchImage@3x.png │ │ │ └── README.md │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h └── RunnerTests │ └── RunnerTests.swift ├── lib ├── bloc │ ├── album_bloc │ │ ├── album_bloc.dart │ │ ├── album_event.dart │ │ └── album_state.dart │ ├── boarding_bloc │ │ ├── boarding_bloc.dart │ │ ├── boarding_event.dart │ │ └── boarding_state.dart │ ├── home_bloc │ │ ├── home_bloc.dart │ │ ├── home_event.dart │ │ └── home_state.dart │ └── player_bloc │ │ ├── player_bloc.dart │ │ ├── player_event.dart │ │ └── player_state.dart ├── db_helper │ └── db_helper.dart ├── main.dart ├── model │ └── audio_file_model.dart ├── res │ ├── app_colors.dart │ ├── app_icons.dart │ ├── app_images.dart │ └── app_svg.dart ├── utils │ └── utils.dart ├── view │ ├── all_music │ │ ├── all_music.dart │ │ └── components │ │ │ ├── folders_list.dart │ │ │ └── song_list.dart │ ├── common_widget │ │ ├── app_bar.dart │ │ ├── loading_files.dart │ │ └── soft_button.dart │ ├── home │ │ ├── components │ │ │ ├── home_bottom_player.dart │ │ │ ├── home_foler_list.dart │ │ │ ├── home_top_box.dart │ │ │ ├── recently_played_list.dart │ │ │ ├── song_list_home.dart │ │ │ ├── song_widget.dart │ │ │ └── songs.dart │ │ └── home_view.dart │ ├── onBoarding │ │ ├── components │ │ │ ├── boarding_page.dart │ │ │ ├── first_page.dart │ │ │ ├── second_page.dart │ │ │ └── third_page.dart │ │ └── onBoarding.dart │ ├── player │ │ ├── components │ │ │ ├── song_bottom_contianer.dart │ │ │ ├── song_circle_container.dart │ │ │ ├── song_controllers.dart │ │ │ └── song_title.dart │ │ └── player.dart │ └── splash │ │ └── splash.dart └── view_model │ └── services │ ├── audio_query_services.dart │ └── splash_services.dart ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart └── windows ├── .gitignore ├── CMakeLists.txt ├── flutter ├── CMakeLists.txt ├── generated_plugin_registrant.cc ├── generated_plugin_registrant.h └── generated_plugins.cmake └── runner ├── CMakeLists.txt ├── Runner.rc ├── flutter_window.cpp ├── flutter_window.h ├── main.cpp ├── resource.h ├── resources └── app_icon.ico ├── runner.exe.manifest ├── utils.cpp ├── utils.h ├── win32_window.cpp └── win32_window.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Symbolication related 35 | app.*.symbols 36 | 37 | # Obfuscation related 38 | app.*.map.json 39 | 40 | # Android Studio will place build artifacts here 41 | /android/app/debug 42 | /android/app/profile 43 | /android/app/release 44 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "67457e669f79e9f8d13d7a68fe09775fefbb79f4" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 17 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 18 | - platform: android 19 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 20 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 21 | - platform: ios 22 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 23 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 24 | - platform: windows 25 | create_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 26 | base_revision: 67457e669f79e9f8d13d7a68fe09775fefbb79f4 27 | 28 | # User provided section 29 | 30 | # List of Local paths (relative to this file) that should be 31 | # ignored by the migrate tool. 32 | # 33 | # Files that are not part of the templates will be ignored by default. 34 | unmanaged_files: 35 | - 'lib/main.dart' 36 | - 'ios/Runner.xcodeproj/project.pbxproj' 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Music App with BLoC 2 | 3 | A Flutter music streaming application that allows users to play audio files from local storage. The app features a beautiful neumorphic UI design and provides a smooth user experience for browsing and playing music. 4 | 5 | ## Screenshots 6 | 7 | Include some attractive screenshots of your app to give potential users a visual preview of your project's interface. 8 | 9 | 10 | 11 | 12 | **Immerse yourself in your music with this beautiful and intuitive Flutter app!** 13 | 14 | **Features:** 15 | 16 | * **Effortless browsing:** Explore your music library with ease. 17 | * **Stunning design:** Experience a captivating neumorphic UI. 18 | * **Seamless playback:** Enjoy smooth audio control and playback. 19 | * **Personalized favorites:** Create playlists and mark your favorites for quick access. 20 | * **Responsive experience:** BLoC ensures a fluid and reactive app. 21 | 22 | **Key Technologies:** 23 | 24 | * **Flutter:** Cross-platform development for flexibility. 25 | * **BLoC:** State management for a responsive experience. 26 | * **Neumorphic design:** Modern and elegant look. 27 | * **Just Audio:** Powerful audio playback engine. 28 | 29 | **Get Started:** 30 | 31 | 1. **Clone the repository:** `git clone https://github.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc.git` 32 | 2. **Install dependencies:** `flutter pub get` 33 | 3. **Connect your device or start an emulator.** 34 | 4. **Run the app:** `flutter run` 35 | 36 | ### Dependencies 37 | 38 | This project uses the following dependencies: 39 | 40 | * shared_preferences: For storing user preferences. 41 | * bloc: Core BLoC library for state management. 42 | * flutter_bloc: BLoC integration with Flutter widgets. 43 | * equatable: Simplifies object comparison for BLoC. 44 | * google_fonts: Access a wide variety of fonts for customization. 45 | * flutter_svg: Display and interact with SVG icons and images. 46 | * sqflite: SQLite database for persistent data storage. 47 | * path_provider: Provides access to device file system paths. 48 | * path: Utilities for handling file and directory paths. 49 | * permission_handler: Requests and manages runtime permissions. 50 | * just_audio: Powerful audio player for Flutter applications. 51 | * on_audio_query: Fetches and organizes audio files from device storage. 52 | * layout_pro: Advanced layout capabilities for complex UI structures. 53 | * shimmer_effect: Create shimmering loading animations for a polished look. 54 | 55 | **Contribute & Connect:** 56 | 57 | * **Report bugs or share ideas:** Submit pull requests or open issues. 58 | * **Join the community:** Get updates and engage with other developers. 59 | 60 | **Spread the Music:** 61 | 62 | * **Star the project on GitHub if you like it!** 63 | * **Share with your friends and music lovers.** 64 | 65 | **Let the music flow!** 66 | 67 | 68 | 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | id "dev.flutter.flutter-gradle-plugin" 5 | } 6 | 7 | def localProperties = new Properties() 8 | def localPropertiesFile = rootProject.file('local.properties') 9 | if (localPropertiesFile.exists()) { 10 | localPropertiesFile.withReader('UTF-8') { reader -> 11 | localProperties.load(reader) 12 | } 13 | } 14 | 15 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 16 | if (flutterVersionCode == null) { 17 | flutterVersionCode = '1' 18 | } 19 | 20 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 21 | if (flutterVersionName == null) { 22 | flutterVersionName = '1.0' 23 | } 24 | 25 | android { 26 | namespace "com.dev.music" 27 | compileSdkVersion 33 28 | ndkVersion flutter.ndkVersion 29 | 30 | compileOptions { 31 | sourceCompatibility JavaVersion.VERSION_1_8 32 | targetCompatibility JavaVersion.VERSION_1_8 33 | } 34 | 35 | kotlinOptions { 36 | jvmTarget = '1.8' 37 | } 38 | 39 | sourceSets { 40 | main.java.srcDirs += 'src/main/kotlin' 41 | } 42 | 43 | defaultConfig { 44 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 45 | applicationId "com.dev.music" 46 | // You can update the following values to match your application needs. 47 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 48 | minSdkVersion 19 49 | targetSdkVersion flutter.targetSdkVersion 50 | versionCode flutterVersionCode.toInteger() 51 | versionName flutterVersionName 52 | multiDexEnabled true 53 | } 54 | 55 | buildTypes { 56 | release { 57 | // TODO: Add your own signing config for the release build. 58 | // Signing with the debug keys for now, so `flutter run --release` works. 59 | signingConfig signingConfigs.debug 60 | } 61 | } 62 | } 63 | 64 | flutter { 65 | source '../..' 66 | } 67 | 68 | dependencies {} 69 | -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 12 | 20 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 35 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/dev/music/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.dev.music 2 | import io.flutter.embedding.android.FlutterActivity 3 | class MainActivity: FlutterActivity() { 4 | } 5 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 10 | } 11 | } 12 | 13 | allprojects { 14 | repositories { 15 | google() 16 | mavenCentral() 17 | } 18 | } 19 | 20 | rootProject.buildDir = '../build' 21 | subprojects { 22 | project.buildDir = "${rootProject.buildDir}/${project.name}" 23 | } 24 | subprojects { 25 | project.evaluationDependsOn(':app') 26 | } 27 | 28 | tasks.register("clean", Delete) { 29 | delete rootProject.buildDir 30 | } 31 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip 6 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | } 9 | settings.ext.flutterSdkPath = flutterSdkPath() 10 | 11 | includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle") 12 | 13 | repositories { 14 | google() 15 | mavenCentral() 16 | gradlePluginPortal() 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-gradle-plugin" version "1.0.0" apply false 21 | } 22 | } 23 | 24 | plugins { 25 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 26 | id "com.android.application" version "7.3.0" apply false 27 | } 28 | 29 | include ":app" 30 | -------------------------------------------------------------------------------- /assets/icons/splashIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/icons/splashIcon.png -------------------------------------------------------------------------------- /assets/images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/1.png -------------------------------------------------------------------------------- /assets/images/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/10.png -------------------------------------------------------------------------------- /assets/images/11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/11.png -------------------------------------------------------------------------------- /assets/images/12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/12.png -------------------------------------------------------------------------------- /assets/images/13.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/13.png -------------------------------------------------------------------------------- /assets/images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/2.png -------------------------------------------------------------------------------- /assets/images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/3.png -------------------------------------------------------------------------------- /assets/images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/4.png -------------------------------------------------------------------------------- /assets/images/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/5.png -------------------------------------------------------------------------------- /assets/images/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/6.png -------------------------------------------------------------------------------- /assets/images/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/7.png -------------------------------------------------------------------------------- /assets/images/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/8.png -------------------------------------------------------------------------------- /assets/images/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/assets/images/9.png -------------------------------------------------------------------------------- /assets/svgs/drawer.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /assets/svgs/loop.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /assets/svgs/more.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /assets/svgs/next.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /assets/svgs/notification-bell-new-svgrepo-com.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /assets/svgs/notification.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /assets/svgs/pause.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 8 | 10 | 11 | -------------------------------------------------------------------------------- /assets/svgs/play.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | play [#1000] 6 | Created with Sketch. 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /assets/svgs/prev.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /assets/svgs/search.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/demo.png -------------------------------------------------------------------------------- /demo1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/demo1.png -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | **/dgph 2 | *.mode1v3 3 | *.mode2v3 4 | *.moved-aside 5 | *.pbxuser 6 | *.perspectivev3 7 | **/*sync/ 8 | .sconsign.dblite 9 | .tags* 10 | **/.vagrant/ 11 | **/DerivedData/ 12 | Icon? 13 | **/Pods/ 14 | **/.symlinks/ 15 | profile 16 | xcuserdata 17 | **/.generated/ 18 | Flutter/App.framework 19 | Flutter/Flutter.framework 20 | Flutter/Flutter.podspec 21 | Flutter/Generated.xcconfig 22 | Flutter/ephemeral/ 23 | Flutter/app.flx 24 | Flutter/app.zip 25 | Flutter/flutter_assets/ 26 | Flutter/flutter_export_environment.sh 27 | ServiceDefinitions.json 28 | Runner/GeneratedPluginRegistrant.* 29 | 30 | # Exceptions to above rules. 31 | !default.mode1v3 32 | !default.mode2v3 33 | !default.pbxuser 34 | !default.perspectivev3 35 | -------------------------------------------------------------------------------- /ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Music 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | music 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /lib/bloc/album_bloc/album_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:music/bloc/album_bloc/album_event.dart'; 4 | import 'package:music/bloc/album_bloc/album_state.dart'; 5 | import 'package:music/bloc/home_bloc/home_state.dart'; 6 | import 'package:music/view_model/services/audio_query_services.dart'; 7 | 8 | class AlbumBloc extends Bloc { 9 | final PageController pageController; 10 | int currentPage = 0; 11 | AlbumBloc({required this.pageController}) : super(const AlbumState()) { 12 | on(_getFilesEvent); 13 | on(_folderTapEvent); 14 | on(_backArrowClick); 15 | on(_loadingStatusChange); 16 | } 17 | 18 | Future _getFilesEvent(GetFolderEvent event, 19 | Emitter emit) async { 20 | emit(state.copyWith(folders: await AudioFileQueries.getFolders())); 21 | } 22 | 23 | Future _folderTapEvent(FolderTapEvent event, 24 | Emitter emit) async { 25 | add(LoadingStatusChange(status: Status.loading)); 26 | try{ 27 | pageController.animateToPage(1, 28 | duration: const Duration(milliseconds: 200), curve: Curves.easeIn); 29 | currentPage = 1; 30 | }catch(_){ 31 | 32 | } 33 | emit(state.copyWith( 34 | audioFiles: await AudioFileQueries.getFiles(event.path), 35 | appBarTitle: event.folderName)); 36 | add(LoadingStatusChange(status: Status.complete)); 37 | } 38 | 39 | Future _backArrowClick(BackArrowTap event, 40 | Emitter emit) async { 41 | if (currentPage == 1) { 42 | try{ 43 | pageController.animateToPage(0, 44 | duration: const Duration(milliseconds: 200), curve: Curves.easeIn); 45 | currentPage = 0; 46 | }catch(_){ 47 | 48 | } 49 | emit(state.copyWith(audioFiles: [], appBarTitle: 'Album')); 50 | }else{ 51 | Navigator.pop(event.context); 52 | } 53 | } 54 | void _loadingStatusChange(LoadingStatusChange event, 55 | Emitter emit) { 56 | emit(state.copyWith(fileStatus: event.status)); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/bloc/album_bloc/album_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:music/bloc/home_bloc/home_state.dart'; 4 | 5 | abstract class AlbumEvent extends Equatable{ 6 | @override 7 | List get props=>[]; 8 | } 9 | 10 | class FolderTapEvent extends AlbumEvent{ 11 | final String folderName; 12 | final String path; 13 | FolderTapEvent({required this.path,required this.folderName}); 14 | @override 15 | List get props=>[folderName,path]; 16 | } 17 | class GetFolderEvent extends AlbumEvent{} 18 | class LoadingStatusChange extends AlbumEvent{ 19 | final Status status; 20 | LoadingStatusChange({required this.status}); 21 | } 22 | class BackArrowTap extends AlbumEvent{ 23 | final BuildContext context; 24 | BackArrowTap({required this.context}); 25 | @override 26 | List get props=>[context]; 27 | } -------------------------------------------------------------------------------- /lib/bloc/album_bloc/album_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:music/model/audio_file_model.dart'; 3 | 4 | import '../home_bloc/home_state.dart'; 5 | 6 | class AlbumState extends Equatable{ 7 | final Status fileStatus; 8 | final List audioFiles; 9 | final List> folders; 10 | final String appBarTitle; 11 | const AlbumState({this.audioFiles=const [],this.folders=const [],this.appBarTitle='Albums',this.fileStatus=Status.loading}); 12 | AlbumState copyWith({List? audioFiles, List>? folders,String? appBarTitle,Status? fileStatus}){ 13 | return AlbumState( 14 | appBarTitle: appBarTitle?? this.appBarTitle, 15 | audioFiles: audioFiles?? this.audioFiles, 16 | folders: folders?? this.folders, 17 | fileStatus: fileStatus ?? this.fileStatus 18 | ); 19 | } 20 | @override 21 | List get props=>[audioFiles,folders,fileStatus]; 22 | } 23 | -------------------------------------------------------------------------------- /lib/bloc/boarding_bloc/boarding_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'package:bloc/bloc.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:music/bloc/boarding_bloc/boarding_event.dart'; 4 | import 'package:music/bloc/boarding_bloc/boarding_state.dart'; 5 | import 'package:music/utils/utils.dart'; 6 | import 'package:music/view/home/home_view.dart'; 7 | import 'package:shared_preferences/shared_preferences.dart'; 8 | 9 | class BoardingBLoc extends Bloc{ 10 | final PageController pageController; 11 | BoardingBLoc({required this.pageController}) : super(const BoardingState()){ 12 | on(_onPageChangeEvent); 13 | on(_onSkipTapEvent); 14 | on(_letsGoTapEvent); 15 | } 16 | 17 | void _onPageChangeEvent(OnPageChangeEvent event, Emitter emit){ 18 | pageController.animateToPage(event.index, duration:const Duration(milliseconds: 200), curve: Curves.easeIn); 19 | emit(state.copyWith(index: event.index)); 20 | } 21 | 22 | Future _onSkipTapEvent(OnSkipTapEvent event, Emitter emit)async{ 23 | var pref= await SharedPreferences.getInstance(); 24 | final isPermissionGranted = await Utils.requestPermission(); 25 | if(isPermissionGranted){ 26 | Utils.go(context: event.context!, screen: const HomeView()); 27 | pref.setBool('OPENED', true); 28 | }else{ 29 | Utils.requestPermission(); 30 | } 31 | } 32 | Future _letsGoTapEvent(LetsGoTapEvent event, Emitter emit) async { 33 | var pref= await SharedPreferences.getInstance(); 34 | final isPermissionGranted = await Utils.requestPermission(); 35 | if(isPermissionGranted){ 36 | Utils.go(context: event.context!, screen: const HomeView()); 37 | pref.setBool('OPENED', true); 38 | }else{ 39 | Utils.requestPermission(); 40 | } 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /lib/bloc/boarding_bloc/boarding_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | 4 | abstract class BoardingEvent extends Equatable{ 5 | @override 6 | List get props=>[]; 7 | } 8 | 9 | class OnPageChangeEvent extends BoardingEvent{ 10 | final int index; 11 | OnPageChangeEvent({required this.index}); 12 | @override 13 | List get props=>[index]; 14 | } 15 | 16 | class OnSkipTapEvent extends BoardingEvent{ 17 | final BuildContext? context; 18 | OnSkipTapEvent({this.context}); 19 | @override 20 | List get props=>[]; 21 | } 22 | class LetsGoTapEvent extends BoardingEvent{ 23 | final BuildContext? context; 24 | LetsGoTapEvent({this.context}); 25 | @override 26 | List get props=>[]; 27 | } -------------------------------------------------------------------------------- /lib/bloc/boarding_bloc/boarding_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class BoardingState extends Equatable{ 4 | 5 | final int index; 6 | const BoardingState({this.index=0}); 7 | 8 | 9 | BoardingState copyWith({int? index}){ 10 | return BoardingState( 11 | index: index??this.index 12 | ); 13 | } 14 | @override 15 | List get props => [index]; 16 | 17 | } -------------------------------------------------------------------------------- /lib/bloc/home_bloc/home_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:music/bloc/home_bloc/home_event.dart'; 6 | import 'package:music/bloc/home_bloc/home_state.dart'; 7 | import 'package:music/db_helper/db_helper.dart'; 8 | import 'package:music/model/audio_file_model.dart'; 9 | import 'package:music/view_model/services/audio_query_services.dart'; 10 | 11 | class HomeBloc extends Bloc{ 12 | final List songList=[]; 13 | final List favouriteSongs=[]; 14 | final DbHelper dbHelper; 15 | HomeBloc({required this.dbHelper}) : super(const HomeState()){ 16 | on(_onSongFileEvent); 17 | on(_onLoadingFileStatus); 18 | on(_onFavSongFileEvent); 19 | on(_onLoadingFavStatus); 20 | on(_onAddToFavEvent); 21 | on(_onAddToAlbumEvent); 22 | } 23 | Future _onSongFileEvent(GetSongEvent event,Emitter emit) async { 24 | add(ChangeLoadingStatusSong(songStatus: Status.loading,)); 25 | try{ 26 | songList.clear(); 27 | for(var item in (await AudioFileQueries.getFiles('/storage/emulated/0/Music'))){ 28 | songList.add(item); 29 | } 30 | }catch(_){ 31 | 32 | } 33 | emit(state.copyWith(songList: songList,songListStatus: Status.complete,)); 34 | } 35 | Future _onFavSongFileEvent(GetFavSongEvent event,Emitter emit) async { 36 | add(ChangeLoadingStatusFav(songStatus: Status.loading,)); 37 | favouriteSongs.clear(); 38 | for(var item in (await dbHelper.getData())){ 39 | favouriteSongs.add(item); 40 | } 41 | emit(state.copyWith(favouriteSongs: List.from(favouriteSongs),favSongListStatus: Status.complete)); 42 | } 43 | void _onLoadingFileStatus(ChangeLoadingStatusSong event,Emitter emit){ 44 | emit(state.copyWith(songListStatus: event.songStatus,)); 45 | } 46 | void _onLoadingFavStatus(ChangeLoadingStatusFav event,Emitter emit){ 47 | emit(state.copyWith(favSongListStatus: event.songStatus,)); 48 | } 49 | 50 | 51 | Future _onAddToFavEvent(AddToFavouriteEvent event,Emitter emit) async { 52 | bool alreadyExist=await dbHelper.isFavoriteExists(event.file.name!); 53 | if(alreadyExist){ 54 | await dbHelper.delete(event.file.name!); 55 | favouriteSongs.remove(event.file); 56 | }else{ 57 | await dbHelper.insert(event.file); 58 | favouriteSongs.add(event.file); 59 | } 60 | add(GetFavSongEvent()); 61 | // emit(state.copyWith(favouriteSongs: List.generate(favouriteSongs.length, (index) => favouriteSongs[index]))); 62 | } 63 | Future _onAddToAlbumEvent(AddToAlbum event,Emitter emit) async { 64 | try{ 65 | if(Directory('/storage/emulated/0/Music').existsSync()){ 66 | }else{ 67 | Directory('/storage/emulated/0/Music').createSync(recursive: true); 68 | } 69 | 70 | final bool alreadyExist=File('/storage/emulated/0/Music/${event.file.name!}').existsSync(); 71 | if(alreadyExist){ 72 | }else{ 73 | File(event.file.path!).copySync('/storage/emulated/0/Music/${event.file.name!}'); 74 | songList.add(event.file); 75 | } 76 | add(GetSongEvent()); 77 | // emit(state.copyWith(songList: List.from(songList))); 78 | 79 | }catch(e){ 80 | debugPrint(e.toString()); 81 | } 82 | 83 | } 84 | List get props=>[songList,favouriteSongs]; 85 | } -------------------------------------------------------------------------------- /lib/bloc/home_bloc/home_event.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:music/bloc/home_bloc/home_state.dart'; 3 | import 'package:music/model/audio_file_model.dart'; 4 | 5 | abstract class HomeEvents extends Equatable{ 6 | @override 7 | List get props=>[]; 8 | } 9 | class GetSongEvent extends HomeEvents{} 10 | class GetFavSongEvent extends HomeEvents{} 11 | class ChangeLoadingStatusSong extends HomeEvents{ 12 | final Status songStatus; 13 | ChangeLoadingStatusSong({required this.songStatus,}); 14 | @override 15 | List get props=>[songStatus,]; 16 | } 17 | class ChangeLoadingStatusFav extends HomeEvents{ 18 | final Status songStatus; 19 | ChangeLoadingStatusFav({required this.songStatus,}); 20 | @override 21 | List get props=>[songStatus,]; 22 | } 23 | class AddToFavouriteEvent extends HomeEvents{ 24 | final AudioFile file; 25 | AddToFavouriteEvent({required this.file}); 26 | @override 27 | List get props=>[file]; 28 | } 29 | class AddToAlbum extends HomeEvents{ 30 | final AudioFile file; 31 | AddToAlbum({required this.file}); 32 | @override 33 | List get props=>[file]; 34 | } -------------------------------------------------------------------------------- /lib/bloc/home_bloc/home_state.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | import 'package:music/model/audio_file_model.dart'; 3 | enum Status{loading,complete} 4 | class HomeState extends Equatable { 5 | final List songList; 6 | final Status songListStatus; 7 | final Status favSongListStatus; 8 | final List favouriteSongs; 9 | const HomeState({this.songList = const [], this.favouriteSongs = const [], 10 | this.favSongListStatus=Status.loading, 11 | this.songListStatus=Status.loading 12 | }); 13 | HomeState copyWith({List? songList, List? favouriteSongs,Status? favSongListStatus,Status? songListStatus}) { 14 | return HomeState( 15 | favouriteSongs: favouriteSongs?? this.favouriteSongs, 16 | songList: songList?? this.songList, 17 | favSongListStatus: favSongListStatus?? this.favSongListStatus, 18 | songListStatus: songListStatus?? this.songListStatus 19 | ); 20 | } 21 | @override 22 | List get props => [songList,favouriteSongs,songListStatus,favSongListStatus]; 23 | } 24 | -------------------------------------------------------------------------------- /lib/bloc/player_bloc/player_bloc.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:bloc/bloc.dart'; 4 | import 'package:equatable/equatable.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:just_audio/just_audio.dart'; 7 | import 'package:music/db_helper/db_helper.dart'; 8 | import 'package:music/model/audio_file_model.dart'; 9 | 10 | part 'player_event.dart'; 11 | part 'player_state.dart'; 12 | 13 | class PlayerBloc extends Bloc { 14 | final AudioPlayer player; 15 | bool isPlaying = false; 16 | Timer? timer; 17 | final dbHelper = DbHelper(); 18 | 19 | PlayerBloc({ 20 | required this.player, 21 | }) : super(const PlayerState()) { 22 | on(_onPlayPauseEvent); 23 | on(_onPlayEvent); 24 | on(_progressUpdate); 25 | on(_onTapFavouriteEvent); 26 | on(_onTapForwardEvent); 27 | on(_onTapBackwardEvent); 28 | } 29 | 30 | Future _onPlayPauseEvent( 31 | PlayPauseEvent event, Emitter emit) async { 32 | if (isPlaying) { 33 | player.pause(); 34 | emit(state.copyWith( 35 | isPlaying: false, 36 | )); 37 | } else { 38 | player.play(); 39 | emit(state.copyWith( 40 | isPlaying: true, 41 | )); 42 | } 43 | isPlaying = event.isPlaying; 44 | } 45 | 46 | Future _onPlayEvent( 47 | OnPlayEvent event, Emitter emit) async { 48 | await player.setFilePath(event.file.path.toString()); 49 | player.play(); 50 | isPlaying = true; 51 | double progress = 0.0; 52 | emit(state.copyWith( 53 | isPlaying: true, 54 | isFavourite: event.file.isFavourite == 1, 55 | status: SongStatus.playing, 56 | file: event.file)); 57 | Timer.periodic(const Duration(milliseconds: 1), (timer) { 58 | progress = player.duration == null 59 | ? 0.0 60 | : player.position.inMilliseconds / player.duration!.inMilliseconds; 61 | add(ProgressUpdateEvent(progress: progress)); 62 | if (progress >= 1.0) { 63 | timer.cancel(); 64 | } 65 | }); 66 | } 67 | 68 | Future _progressUpdate( 69 | ProgressUpdateEvent event, Emitter emit) async { 70 | if (event.progress == 1.0) { 71 | // player.pause(); 72 | // player.seek(const Duration(seconds: 0)); 73 | // emit(state.copyWith(progress: 0.0,isPlaying: false)); 74 | add(OnPlayEvent(file: state.file!)); 75 | } else { 76 | emit(state.copyWith( 77 | progress: event.progress, 78 | )); 79 | } 80 | } 81 | 82 | Future _onTapFavouriteEvent( 83 | OnTapFavouriteEvent event, Emitter emit) async { 84 | final alreadyExist = 85 | await dbHelper.isFavoriteExists(event.file.name.toString()); 86 | if (alreadyExist) { 87 | showDialog( 88 | context: event.context, 89 | builder: (context) { 90 | return AlertDialog( 91 | backgroundColor: Colors.white, 92 | title: Text( 93 | 'Warning', 94 | style: TextStyle( 95 | color: Colors.black, 96 | fontWeight: FontWeight.bold, 97 | fontSize: 12), 98 | ), 99 | content: Text( 100 | 'This soong is already in favourite list, are you sure to delete it', 101 | style: TextStyle( 102 | color: Colors.black, 103 | fontSize: 10, 104 | ), 105 | ), 106 | actions: [ 107 | InkWell( 108 | onTap: () => Navigator.pop(context), 109 | child: Text( 110 | 'Cancle', 111 | style: TextStyle(fontSize: 12, color: Colors.black), 112 | )), 113 | SizedBox( 114 | width: 10, 115 | ), 116 | InkWell( 117 | onTap: () async { 118 | await dbHelper.delete(event.file.name.toString()); 119 | Navigator.pop(context); 120 | emit(state.copyWith(isFavourite: false)); 121 | }, 122 | child: Text( 123 | 'ok', 124 | style: TextStyle( 125 | color: Colors.red, 126 | fontWeight: FontWeight.bold, 127 | fontSize: 12), 128 | ), 129 | ), 130 | ], 131 | ); 132 | }, 133 | ); 134 | } else { 135 | await dbHelper.insert(event.file); 136 | emit(state.copyWith(isFavourite: true)); 137 | 138 | } 139 | } 140 | 141 | void _onTapForwardEvent(OnTapForwardEvent event, Emitter emit) { 142 | if (player.position.inSeconds < player.duration!.inSeconds - 10) { 143 | player.seek(Duration(seconds: player.position.inSeconds + 10)); 144 | emit(state.copyWith( 145 | progress: player.position.inMilliseconds / 146 | player.duration!.inMilliseconds)); 147 | } 148 | } 149 | 150 | void _onTapBackwardEvent( 151 | OnTapBackwardEvent event, Emitter emit) { 152 | if (player.position.inSeconds > 10) { 153 | player.seek(Duration(seconds: player.position.inSeconds - 10)); 154 | } else { 155 | player.seek(const Duration(seconds: 0)); 156 | } 157 | emit(state.copyWith( 158 | progress: 159 | player.position.inMilliseconds / player.duration!.inMilliseconds)); 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /lib/bloc/player_bloc/player_event.dart: -------------------------------------------------------------------------------- 1 | part of 'player_bloc.dart'; 2 | 3 | abstract class PlayerEvent extends Equatable { 4 | const PlayerEvent(); 5 | @override 6 | List get props=>[]; 7 | } 8 | class PlayPauseEvent extends PlayerEvent{ 9 | final bool isPlaying; 10 | final double progress; 11 | final AudioFile file; 12 | const PlayPauseEvent({required this.isPlaying,required this.file,this.progress=0.0}); 13 | @override 14 | List get props=>[isPlaying,file,progress]; 15 | } 16 | class OnPlayEvent extends PlayerEvent{ 17 | final bool isPlaying; 18 | final AudioFile file; 19 | 20 | const OnPlayEvent({ this.isPlaying=true,required this.file}); 21 | @override 22 | List get props=>[isPlaying,file]; 23 | } 24 | class OnTapPrevEvent extends PlayerEvent{} 25 | class ProgressUpdateEvent extends PlayerEvent{ 26 | final double progress; 27 | const ProgressUpdateEvent({required this.progress}); 28 | @override 29 | List get props=>[progress]; 30 | } 31 | class OnTapFavouriteEvent extends PlayerEvent{ 32 | final AudioFile file; 33 | final BuildContext context; 34 | const OnTapFavouriteEvent({required this.file,required this.context}); 35 | @override 36 | List get props=>[file,context]; 37 | } 38 | 39 | class OnTapForwardEvent extends PlayerEvent{} 40 | class OnTapBackwardEvent extends PlayerEvent{} 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /lib/bloc/player_bloc/player_state.dart: -------------------------------------------------------------------------------- 1 | part of 'player_bloc.dart'; 2 | 3 | enum SongStatus { playing, pause, stopped } 4 | 5 | class PlayerState extends Equatable { 6 | final bool isPlaying; 7 | final double progress; 8 | final bool isFavourite; 9 | final AudioFile? file; 10 | final SongStatus status; 11 | 12 | const PlayerState( 13 | {this.isPlaying = true, 14 | this.isFavourite = false, 15 | this.progress = 0.0, 16 | this.status = SongStatus.stopped, 17 | this.file}); 18 | 19 | PlayerState copyWith( 20 | {bool? isPlaying, 21 | double? progress, 22 | bool? isFavourite, 23 | SongStatus? status, 24 | AudioFile? file}) { 25 | return PlayerState( 26 | isFavourite: isFavourite ?? this.isFavourite, 27 | isPlaying: isPlaying ?? this.isPlaying, 28 | progress: progress ?? this.progress, 29 | status: status ?? this.status, 30 | file: file ?? this.file); 31 | } 32 | 33 | @override 34 | List get props => 35 | [isPlaying, progress, isFavourite, status, file ?? '']; 36 | } 37 | -------------------------------------------------------------------------------- /lib/db_helper/db_helper.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:music/model/audio_file_model.dart'; 4 | import 'package:path/path.dart'; 5 | import 'package:path_provider/path_provider.dart'; 6 | import 'package:sqflite/sqflite.dart'; 7 | class DbHelper 8 | { 9 | Database? _db; 10 | Future get db 11 | async { 12 | if(_db!=null) 13 | { 14 | return _db; 15 | } 16 | final directory = Platform.isAndroid 17 | ? await getExternalStorageDirectory() 18 | : await getApplicationSupportDirectory(); 19 | String path=join(directory!.path,'db'); 20 | var db=await openDatabase(path,version: 1,onCreate: (db, version) { 21 | db.execute("CREATE TABLE Favourite(id INTEGER PRIMARY KEY, name TEXT, path TEXT, size TEXT, length TEXT, isFavourite INTEGER)"); 22 | },); 23 | return db; 24 | } 25 | Future insert(AudioFile model) async { 26 | var dbClient=await db; 27 | dbClient!.insert('Favourite', model.toMap()).then((value) { 28 | }); 29 | return model; 30 | } 31 | Future delete (String name,) async { 32 | var dbClient=await db; 33 | return await dbClient!.delete( 34 | 'Favourite', 35 | where: 'name = ?', 36 | whereArgs: [name]).then((value) { 37 | // Utils.showSnackBar('Deleted', 'Task is removed successfully', const Icon(Icons.done,color: Colors.white,size: 16,)); 38 | return value; 39 | }); 40 | } 41 | Future> getData() async { 42 | var dbClient = await db; 43 | final List> queryResult = await dbClient!.query('Favourite'); 44 | return queryResult.map((e) { 45 | return AudioFile.fromMap(e); 46 | }).toList(); 47 | } 48 | 49 | Future isFavoriteExists(String name) async { 50 | var dbClient = await db; 51 | final List> queryResult = await dbClient!.query( 52 | 'Favourite', 53 | where: 'name = ?', 54 | whereArgs: [name], 55 | ); 56 | return queryResult.isNotEmpty; 57 | } 58 | } -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:just_audio/just_audio.dart'; 4 | import 'package:music/bloc/album_bloc/album_bloc.dart'; 5 | import 'package:music/bloc/boarding_bloc/boarding_bloc.dart'; 6 | import 'package:music/bloc/home_bloc/home_bloc.dart'; 7 | import 'package:music/bloc/player_bloc/player_bloc.dart'; 8 | import 'package:music/db_helper/db_helper.dart'; 9 | import 'package:music/res/app_colors.dart'; 10 | import 'package:music/view/splash/splash.dart'; 11 | void main() { 12 | WidgetsFlutterBinding.ensureInitialized(); 13 | runApp(const MyApp()); 14 | } 15 | class MyApp extends StatelessWidget { 16 | const MyApp({super.key}); 17 | @override 18 | Widget build(BuildContext context) { 19 | return MultiBlocProvider( 20 | providers: [ 21 | BlocProvider( 22 | create: (_) => BoardingBLoc(pageController: PageController()), 23 | ), 24 | BlocProvider( 25 | create: (_) => HomeBloc(dbHelper: DbHelper()), 26 | ), 27 | BlocProvider( 28 | create: (_) => PlayerBloc(player: AudioPlayer()), 29 | ), 30 | BlocProvider( 31 | create: (_) => AlbumBloc(pageController: PageController()), 32 | ), 33 | ], 34 | child: MaterialApp( 35 | debugShowCheckedModeBanner: false, 36 | theme: ThemeData( 37 | scaffoldBackgroundColor: backgroundColor, 38 | colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), 39 | useMaterial3: true, 40 | ), 41 | home: SplashScreen(), 42 | ), 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /lib/model/audio_file_model.dart: -------------------------------------------------------------------------------- 1 | class AudioFile { 2 | final int? id; 3 | final String? name; 4 | final String? path; 5 | final int? isFavourite; 6 | final String? size; 7 | final String? length; 8 | AudioFile({this.id, this.name, this.path, this.size, this.length,this.isFavourite,}); 9 | Map toMap() { 10 | return { 11 | 'id': id, 12 | 'name': name, 13 | 'path': path, 14 | 'size': size, 15 | 'length': length, 16 | 'isFavourite': isFavourite, 17 | }; 18 | } 19 | factory AudioFile.fromMap(Map map) { 20 | return AudioFile( 21 | id: map['id'], 22 | name: map['name'], 23 | path: map['path'], 24 | size: map['size'], 25 | length: map['length'], 26 | isFavourite: map['isFavourite'] 27 | ); 28 | } 29 | } -------------------------------------------------------------------------------- /lib/res/app_colors.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | Color backgroundColor = const Color(0xFFF1F2F6); 4 | Color shadowColor = const Color(0xFFDADFF0); 5 | Color blueShade = const Color(0xFF4D3FB4); 6 | Color lightBlueShade = const Color(0xFF027FFF); 7 | Color blueBackground = const Color(0xFF7026ED); 8 | Color lightShadowColor = Colors.white; 9 | Color textColor = const Color(0xFF707070); 10 | Color seekBarLightColor = const Color(0xFFB8ECED); 11 | Color seekBarDarkColor = const Color(0xFF37C8DF); -------------------------------------------------------------------------------- /lib/res/app_icons.dart: -------------------------------------------------------------------------------- 1 | class AppIcons{ 2 | static const splashIcons='assets/icons/splashIcon.png'; 3 | } -------------------------------------------------------------------------------- /lib/res/app_images.dart: -------------------------------------------------------------------------------- 1 | class AppImages { 2 | static const imageList={ 3 | 0: 'assets/images/1.png', 4 | 1: 'assets/images/2.png', 5 | 2: 'assets/images/3.png', 6 | 3: 'assets/images/4.png', 7 | 4: 'assets/images/5.png', 8 | 5: 'assets/images/6.png', 9 | 6: 'assets/images/7.png', 10 | 7: 'assets/images/8.png', 11 | 8: 'assets/images/9.png', 12 | 9: 'assets/images/10.png', 13 | 10: 'assets/images/11.png', 14 | 11: 'assets/images/12.png', 15 | 12: 'assets/images/13.png', 16 | }; 17 | } -------------------------------------------------------------------------------- /lib/res/app_svg.dart: -------------------------------------------------------------------------------- 1 | class AppSvg{ 2 | static const drawer='assets/svgs/drawer.svg'; 3 | static const loop='assets/svgs/loop.svg'; 4 | static const more='assets/svgs/more.svg'; 5 | static const next='assets/svgs/next.svg'; 6 | static const notification='assets/svgs/notification.svg'; 7 | static const pause='assets/svgs/pause.svg'; 8 | static const play='assets/svgs/play.svg'; 9 | static const prev='assets/svgs/prev.svg'; 10 | static const search='assets/svgs/search.svg'; 11 | } -------------------------------------------------------------------------------- /lib/utils/utils.dart: -------------------------------------------------------------------------------- 1 | // import 'package:get/get.dart'; 2 | // import 'package:just_audio/just_audio.dart'; 3 | // import 'package:permission_handler/permission_handler.dart'; 4 | // import 'package:path/path.dart' as path; 5 | // class Utils { 6 | // static final controller = Get.put(FilesController()); 7 | // 8 | // static Future permissionRequest()async{ 9 | // 10 | // var status = await Permission.storage.status; 11 | // if (status.isDenied) { 12 | // Map statuses = await [ 13 | // Permission.location, 14 | // Permission.storage, 15 | // ].request(); 16 | // var temp = await Permission.storage.status; 17 | // if(temp.isGranted){ 18 | // return true; 19 | // }else { 20 | // return false; 21 | // } 22 | // } 23 | // else 24 | // { 25 | // return true; 26 | // } 27 | // 28 | // } 29 | // 30 | // 31 | // static getFileLength(String filePath)async{ 32 | // final player=AudioPlayer(); 33 | // await player.setFilePath(filePath).then((value){ 34 | // String prefix=player.duration!.inMinutes.toString(); 35 | // String postFix=(player.duration!.inSeconds % 60).toString(); 36 | // if(prefix.length<2){ 37 | // prefix='0$prefix'; 38 | // } 39 | // if(postFix.length<2){ 40 | // postFix='0$postFix'; 41 | // } 42 | // controller.audioLength.add('$prefix:$postFix'); 43 | // }); 44 | // player.dispose(); 45 | // } 46 | // } 47 | 48 | import 'dart:math'; 49 | 50 | import 'package:flutter/material.dart'; 51 | import 'package:music/res/app_colors.dart'; 52 | import 'package:music/res/app_images.dart'; 53 | import 'package:permission_handler/permission_handler.dart'; 54 | class Utils{ 55 | static go({required BuildContext context,required dynamic screen,bool replace=false}){ 56 | replace ? 57 | Navigator.pushReplacement(context, MaterialPageRoute(builder: (context) => screen,)) 58 | : Navigator.push(context, MaterialPageRoute(builder: (context) => screen,)); 59 | } 60 | static String getRandomImage(){ 61 | return AppImages.imageList[Random().nextInt(13)]!; 62 | } 63 | static Future requestPermission()async{ 64 | var status1 = await Permission.audio.status; 65 | if(status1.isGranted){ 66 | return true; 67 | } 68 | else{ 69 | Map statuses = await [ 70 | Permission.storage, 71 | Permission.audio, 72 | Permission.manageExternalStorage, 73 | ].request(); 74 | var temp1 = await Permission.audio.status; 75 | if(temp1.isGranted){ 76 | return true; 77 | }else { 78 | return false; 79 | } 80 | } 81 | } 82 | static String getGreetingMessage() { 83 | DateTime now = DateTime.now(); 84 | int hour = now.hour; 85 | if (hour >= 5 && hour < 12) { 86 | return 'Good morning'; 87 | } else if (hour >= 12 && hour < 18) { 88 | return 'Good afternoon'; 89 | } else { 90 | return 'Good evening'; 91 | } 92 | } 93 | static showBottomSheet({required BuildContext context, 94 | required Widget widget, 95 | bool isDismissible=false 96 | }){ 97 | showModalBottomSheet( 98 | backgroundColor: backgroundColor, 99 | isDismissible: isDismissible, 100 | enableDrag: false, 101 | isScrollControlled: true, 102 | context: context, builder: (context) { 103 | return widget; 104 | },); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /lib/view/all_music/all_music.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:music/bloc/album_bloc/album_event.dart'; 4 | import 'package:music/view/all_music/components/folders_list.dart'; 5 | import 'package:music/view/all_music/components/song_list.dart'; 6 | import 'package:music/view/common_widget/app_bar.dart'; 7 | import 'package:music/view/home/components/home_bottom_player.dart'; 8 | 9 | import '../../bloc/album_bloc/album_bloc.dart'; 10 | import '../../bloc/album_bloc/album_state.dart'; 11 | 12 | class AllMusicAlbum extends StatelessWidget { 13 | const AllMusicAlbum({super.key}); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | body: WillPopScope( 19 | onWillPop: ()async{ 20 | if(context.read().currentPage==0){ 21 | return true; 22 | }else{ 23 | context.read().add(BackArrowTap(context: context)); 24 | return false; 25 | } 26 | }, 27 | child: SafeArea( 28 | child: Stack( 29 | alignment: Alignment.bottomCenter, 30 | children: [ 31 | Column( 32 | children: [ 33 | const SizedBox( 34 | height: 30, 35 | ), 36 | Padding( 37 | padding: const EdgeInsets.symmetric(horizontal: 20), 38 | child: BlocBuilder( 39 | buildWhen: (previous, current) => previous.appBarTitle!=current.appBarTitle, 40 | builder: (context, state) { 41 | return CustomAppBar( 42 | title: state.appBarTitle, 43 | preIcon: GestureDetector( 44 | onTap: () => context.read().add(BackArrowTap(context: context)), 45 | child: const Icon( 46 | Icons.arrow_back_ios_new_rounded, 47 | size: 20, 48 | ), 49 | ), 50 | postIcon: const Icon(Icons.more_horiz_rounded), 51 | ); 52 | }, 53 | ), 54 | ), 55 | const SizedBox( 56 | height: 20, 57 | ), 58 | Expanded(child: PageView( 59 | controller: context 60 | .read() 61 | .pageController, 62 | physics: const NeverScrollableScrollPhysics(), 63 | children: const [ 64 | FolderList(), 65 | SongList(), 66 | ], 67 | )) 68 | ], 69 | ), 70 | const HomeBottomPlayer(), 71 | ], 72 | ), 73 | ), 74 | ), 75 | ); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/view/all_music/components/folders_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:layout_pro/responsive_layout.dart'; 4 | import 'package:music/bloc/album_bloc/album_bloc.dart'; 5 | import 'package:music/bloc/album_bloc/album_event.dart'; 6 | import 'package:music/bloc/album_bloc/album_state.dart'; 7 | 8 | import '../../../res/app_colors.dart'; 9 | class FolderList extends StatelessWidget { 10 | const FolderList({super.key}); 11 | @override 12 | Widget build(BuildContext context) { 13 | return BlocBuilder( 14 | buildWhen: (previous, current) => previous.folders != current.folders, 15 | builder: (context, state) { 16 | return ResponsiveLayout( 17 | mobileCrossAxisCount: 3, 18 | mobileRatio: 1.1, 19 | largeMobileRatio: 3, 20 | largeMobileCrossAxisCount: 3, 21 | tabletCrossAxisCount: 5, 22 | largeTabletCrossAxisCount: 10, 23 | largeTabletRatio: 1.1, 24 | tabletRatio: 1.1, 25 | desktopScreenCrossAxisCount: 15, 26 | desktopRatio: 1.1, 27 | builder: (context, index) { 28 | return GestureDetector( 29 | onTap: () => context.read().add(FolderTapEvent( 30 | path: state.folders[index]['path'].toString(), folderName: state.folders[index]['name'].toString())), 31 | child: Container( 32 | height: 90, 33 | width: 90, 34 | margin: EdgeInsets.only(top: 20,left: 10,right: 10), 35 | decoration: BoxDecoration( 36 | color: backgroundColor, 37 | borderRadius: BorderRadius.circular(10), 38 | boxShadow: [ 39 | BoxShadow( 40 | color: shadowColor, 41 | offset: Offset(8, 6), 42 | blurRadius: 12), 43 | BoxShadow( 44 | color: Colors.white, 45 | offset: Offset(-8, -6), 46 | blurRadius: 12), 47 | ], 48 | ), 49 | child: Column( 50 | mainAxisAlignment: MainAxisAlignment.center, 51 | crossAxisAlignment: CrossAxisAlignment.center, 52 | children: [ 53 | Icon( 54 | Icons.folder_rounded, 55 | size: 40, 56 | color: Colors.orangeAccent, 57 | ), 58 | SizedBox( 59 | height: 5, 60 | ), 61 | Text( 62 | state.folders[index]['name'].toString(), 63 | overflow: TextOverflow.ellipsis, 64 | style: TextStyle(fontSize: 12), 65 | ) 66 | ], 67 | ), 68 | ), 69 | ); 70 | }, itemCount: state.folders.length); 71 | }, 72 | ); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/view/all_music/components/song_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:layout_pro/responsive_layout.dart'; 4 | import 'package:music/bloc/album_bloc/album_bloc.dart'; 5 | import 'package:music/bloc/home_bloc/home_state.dart'; 6 | import 'package:music/utils/utils.dart'; 7 | import 'package:music/view/common_widget/loading_files.dart'; 8 | import 'package:music/view/home/components/song_widget.dart'; 9 | 10 | import '../../../bloc/album_bloc/album_state.dart'; 11 | import '../../../bloc/player_bloc/player_bloc.dart'; 12 | import '../../../res/app_colors.dart'; 13 | import '../../player/player.dart'; 14 | 15 | class SongList extends StatelessWidget { 16 | const SongList({super.key}); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return BlocBuilder( 21 | buildWhen: (previous, current) => previous.fileStatus!=current.fileStatus, 22 | builder: (context, s) { 23 | if(s.fileStatus==Status.complete){ 24 | return BlocBuilder( 25 | buildWhen: (previous, current) => 26 | previous.audioFiles != current.audioFiles, 27 | builder: (context, state) { 28 | return ResponsiveLayout( 29 | mobileCrossAxisCount: 1, 30 | mobileRatio: 4.4, 31 | largeMobileCrossAxisCount: 1, 32 | largeMobileRatio: 5.8, 33 | tabletCrossAxisCount: 3, 34 | tabletRatio: 4, 35 | largeTabletCrossAxisCount: 4, 36 | largeTabletRatio: 4, 37 | desktopRatio: 4, 38 | desktopScreenCrossAxisCount: 4, 39 | builder: (context, index) { 40 | final String image = Utils.getRandomImage(); 41 | return Padding( 42 | padding: !ResponsiveLayout.isLargeMobile(context) 43 | ? const EdgeInsets.only(top: 10, right: 20, left: 20) 44 | : const EdgeInsets.only(top: 10, left: 20, right: 20), 45 | child: GestureDetector( 46 | onTap: () { 47 | context 48 | .read() 49 | .add(OnPlayEvent(file: state.audioFiles[index])); 50 | Utils.go( 51 | context: context, 52 | screen: Player( 53 | file: state.audioFiles[index], 54 | image: image, 55 | )); 56 | }, 57 | child: Container( 58 | alignment: Alignment.center, 59 | padding: EdgeInsets.symmetric( 60 | horizontal: 10, vertical: 5), 61 | decoration: BoxDecoration( 62 | color: backgroundColor, 63 | borderRadius: BorderRadius.circular(5), 64 | boxShadow: [ 65 | BoxShadow( 66 | color: shadowColor, 67 | offset: Offset(8, 6), 68 | blurRadius: 12), 69 | BoxShadow( 70 | color: Colors.white, 71 | offset: Offset(-8, -6), 72 | blurRadius: 12), 73 | ], 74 | ), 75 | child: SongWidget( 76 | image: image, 77 | name: state.audioFiles[index].name.toString(), 78 | length: state.audioFiles[index].length.toString(), file: state.audioFiles[index],), 79 | ), 80 | ), 81 | ); 82 | }, 83 | itemCount: state.audioFiles.length); 84 | }, 85 | ); 86 | }else{ 87 | return const FilesLoading(); 88 | } 89 | }, 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/view/common_widget/app_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_svg/svg.dart'; 3 | import 'package:music/utils/utils.dart'; 4 | 5 | import '../../res/app_svg.dart'; 6 | class CustomAppBar extends StatelessWidget { 7 | const CustomAppBar({super.key, this.title, this.preIcon, this.postIcon}); 8 | final String? title; 9 | final Widget? preIcon; 10 | final Widget? postIcon; 11 | @override 12 | Widget build(BuildContext context) { 13 | return Container( 14 | child: Stack( 15 | 16 | children: [ 17 | Positioned(left: 1, child: preIcon?? SvgPicture.asset(AppSvg.drawer, height: 20),), 18 | 19 | Center(child: Text(title?? Utils.getGreetingMessage(),style: const TextStyle( 20 | fontWeight: FontWeight.bold,color: Colors.black87 21 | ),),), 22 | 23 | Positioned(right: 1, child: postIcon?? Row( 24 | children: [ 25 | SvgPicture.asset( 26 | AppSvg.search, 27 | color: Colors.black87, 28 | width: 20, 29 | ), 30 | const SizedBox( 31 | width: 10, 32 | ), 33 | SvgPicture.asset( 34 | AppSvg.notification, 35 | color: Colors.black87, 36 | width: 20, 37 | ), 38 | ], 39 | ),) 40 | ], 41 | ), 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/view/common_widget/loading_files.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_svg/svg.dart'; 5 | import 'package:layout_pro/responsive_layout.dart'; 6 | import 'package:shimmer_effect/shimmer_effect.dart'; 7 | 8 | import '../../res/app_colors.dart'; 9 | import '../../res/app_svg.dart'; 10 | 11 | class FilesLoading extends StatelessWidget { 12 | const FilesLoading({super.key}); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return ResponsiveLayout( 17 | itemCount: Random().nextInt(20), 18 | mobileCrossAxisCount: 1, 19 | mobileRatio: 4.7, 20 | largeMobileCrossAxisCount: 1, 21 | largeMobileRatio: 5.8, 22 | tabletCrossAxisCount: 3, 23 | tabletRatio: 4, 24 | largeTabletCrossAxisCount: 4, 25 | largeTabletRatio: 4, 26 | desktopRatio: 4, 27 | desktopScreenCrossAxisCount: 4, 28 | builder: (context, index) { 29 | return Padding( 30 | padding: const EdgeInsets.symmetric(horizontal: 10,vertical: 10), 31 | child: Container( 32 | alignment: Alignment.center, 33 | padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 5), 34 | decoration: BoxDecoration( 35 | color: backgroundColor, 36 | borderRadius: BorderRadius.circular(5), 37 | boxShadow: [ 38 | BoxShadow( 39 | color: shadowColor, offset: const Offset(8, 6), blurRadius: 12), 40 | const BoxShadow( 41 | color: Colors.white, offset: Offset(-8, -6), blurRadius: 12), 42 | ], 43 | ), 44 | child: ShimmerEffect( 45 | baseColor: Colors.white, 46 | highlightColor: shadowColor, 47 | child: Row( 48 | crossAxisAlignment: CrossAxisAlignment.center, 49 | children: [ 50 | const CircleAvatar( 51 | radius: 27, 52 | ), 53 | const SizedBox( 54 | width: 10, 55 | ), 56 | Expanded( 57 | flex: 2, 58 | child: Column( 59 | mainAxisAlignment: MainAxisAlignment.center, 60 | crossAxisAlignment: CrossAxisAlignment.start, 61 | children: [ 62 | Container( 63 | width: 150, 64 | height: 8, 65 | decoration: BoxDecoration( 66 | color: Colors.white, 67 | borderRadius: BorderRadius.circular(10) 68 | ), 69 | ), 70 | const SizedBox( 71 | height: 8, 72 | ), 73 | Container( 74 | width: 50, 75 | height: 7, 76 | decoration: BoxDecoration( 77 | color: Colors.white, 78 | borderRadius: BorderRadius.circular(10) 79 | ), 80 | ), 81 | ], 82 | ), 83 | ), 84 | Spacer(), 85 | RotatedBox( 86 | quarterTurns: 1, 87 | child: SvgPicture.asset( 88 | AppSvg.more, 89 | height: 16, 90 | color: Colors.grey, 91 | )) 92 | ], 93 | ), 94 | ), 95 | ), 96 | ); 97 | }, 98 | ); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /lib/view/common_widget/soft_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../res/app_colors.dart'; 4 | class CircularSoftButton extends StatelessWidget { 5 | double? radius; 6 | final Widget? icon; 7 | final Color lightColor; 8 | final double? padding; 9 | final double? circularRadius; 10 | CircularSoftButton({super.key, this.radius, this.icon, this.lightColor=Colors.white, this.padding, this.circularRadius}){ 11 | if (radius == null || radius! <= 0) radius = 32; 12 | } 13 | @override 14 | Widget build(BuildContext context) { 15 | return Padding( 16 | padding: EdgeInsets.all(padding??radius! / 2), 17 | child: Stack( 18 | children: [ 19 | Container( 20 | width: radius! * 2, 21 | height: radius! * 2, 22 | decoration: BoxDecoration( 23 | color: backgroundColor, 24 | borderRadius: BorderRadius.circular(circularRadius??radius!), 25 | boxShadow: [ 26 | BoxShadow( 27 | color: shadowColor, offset: Offset(8, 6), blurRadius: 12), 28 | BoxShadow( 29 | color: lightColor, 30 | offset: Offset(-8, -6), 31 | blurRadius: 12), 32 | ], 33 | ), 34 | ), 35 | Positioned.fill(child: icon?? Container()), 36 | ], 37 | ), 38 | ); 39 | } 40 | } -------------------------------------------------------------------------------- /lib/view/home/components/home_bottom_player.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:flutter_svg/svg.dart'; 6 | 7 | import '../../../bloc/player_bloc/player_bloc.dart'; 8 | import '../../../res/app_colors.dart'; 9 | import '../../../res/app_icons.dart'; 10 | import '../../../res/app_svg.dart'; 11 | 12 | class HomeBottomPlayer extends StatelessWidget { 13 | const HomeBottomPlayer({super.key}); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return BlocBuilder( 18 | // buildWhen: (previous, current) => previous.progress != current.progress, 19 | builder: (context, state) { 20 | // print(state.file==null? '' : state.file!.name.toString()); 21 | return AnimatedPositioned( 22 | bottom: state.status == SongStatus.playing ? 20 : -150, 23 | duration: const Duration(milliseconds: 300), 24 | child: ClipRRect( 25 | borderRadius: BorderRadius.circular(30), 26 | child: SizedBox( 27 | width: MediaQuery.sizeOf(context).width - 40, 28 | child: Center( 29 | child: ClipRect( 30 | child: BackdropFilter( 31 | filter: ImageFilter.blur(sigmaX: 4, sigmaY: 4), 32 | child: Container( 33 | height: 80, 34 | width: 350, 35 | decoration: BoxDecoration( 36 | color: Colors.white, 37 | borderRadius: BorderRadius.circular(30)), 38 | padding: const EdgeInsets.symmetric(horizontal: 20), 39 | child: Row( 40 | children: [ 41 | const CircleAvatar( 42 | radius: 27, 43 | backgroundImage: AssetImage(AppIcons.splashIcons), 44 | ), 45 | const SizedBox( 46 | width: 10, 47 | ), 48 | Expanded( 49 | child: Column( 50 | crossAxisAlignment: CrossAxisAlignment.start, 51 | mainAxisAlignment: MainAxisAlignment.center, 52 | children: [ 53 | BlocBuilder( 54 | builder: (context, state) { 55 | return Text( 56 | state.file == null 57 | ? '' 58 | : state.file!.name.toString(), 59 | overflow: TextOverflow.ellipsis, 60 | style: const TextStyle( 61 | color: Colors.black, 62 | fontSize: 13, 63 | fontWeight: FontWeight.bold), 64 | ); 65 | }, 66 | ), 67 | Text( 68 | state.file == null 69 | ? '' 70 | : state.file!.length.toString(), 71 | style: const TextStyle( 72 | color: Colors.grey, 73 | fontSize: 11, 74 | fontWeight: FontWeight.bold), 75 | ), 76 | const SizedBox( 77 | height: 6, 78 | ), 79 | SizedBox( 80 | width: 120, 81 | child: LinearProgressIndicator( 82 | borderRadius: BorderRadius.circular(10), 83 | backgroundColor: 84 | Colors.grey.withOpacity(.1), 85 | color: blueBackground, 86 | value: state.progress, 87 | ), 88 | ) 89 | ], 90 | ), 91 | ), 92 | SizedBox(width: 20,), 93 | Row( 94 | children: [ 95 | GestureDetector( 96 | onTap: () { 97 | context 98 | .read() 99 | .add(OnTapBackwardEvent()); 100 | }, 101 | child: RotatedBox( 102 | quarterTurns: 2, 103 | child: SvgPicture.asset( 104 | AppSvg.prev, 105 | height: 20, 106 | )), 107 | ), 108 | const SizedBox( 109 | width: 10, 110 | ), 111 | GestureDetector( 112 | onTap: () { 113 | final bloc = context.read(); 114 | bloc.add(PlayPauseEvent( 115 | isPlaying: !bloc.state.isPlaying, 116 | file: bloc.state.file!)); 117 | }, 118 | child: CircleAvatar( 119 | radius: 20, 120 | backgroundColor: blueBackground, 121 | child: Center( 122 | child: 123 | BlocBuilder( 124 | builder: (context, state) { 125 | return SvgPicture.asset( 126 | state.isPlaying 127 | ? AppSvg.pause 128 | : AppSvg.play, 129 | color: Colors.white, 130 | width: 15, 131 | ); 132 | }, 133 | ), 134 | ), 135 | ), 136 | ), 137 | const SizedBox( 138 | width: 10, 139 | ), 140 | GestureDetector( 141 | onTap: () { 142 | context 143 | .read() 144 | .add(OnTapForwardEvent()); 145 | }, 146 | child: SvgPicture.asset( 147 | AppSvg.next, 148 | height: 20, 149 | ), 150 | ), 151 | ], 152 | ) 153 | ], 154 | ), 155 | ), 156 | ), 157 | ), 158 | ), 159 | ), 160 | )); 161 | }, 162 | ); 163 | } 164 | } 165 | -------------------------------------------------------------------------------- /lib/view/home/components/home_foler_list.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | import 'package:layout_pro/responsive_layout.dart'; 5 | import 'package:music/view/home/components/song_list_home.dart'; 6 | 7 | import '../../../bloc/album_bloc/album_bloc.dart'; 8 | import '../../../bloc/album_bloc/album_event.dart'; 9 | import '../../../res/app_colors.dart'; 10 | import '../../../res/app_svg.dart'; 11 | import '../../../utils/utils.dart'; 12 | import '../../all_music/all_music.dart'; 13 | 14 | class HomeFolderList extends StatelessWidget { 15 | const HomeFolderList({super.key, this.state}); 16 | final state; 17 | @override 18 | Widget build(BuildContext context) { 19 | return Column( 20 | children: [ 21 | SizedBox(height: 20,), 22 | Row( 23 | children: [ 24 | const Text( 25 | 'Album', 26 | style: TextStyle( 27 | color: Colors.black87, 28 | fontSize: 20, 29 | fontWeight: FontWeight.bold, 30 | ), 31 | ), 32 | Spacer(), 33 | InkWell( 34 | onTap: () { 35 | context.read().add(GetFolderEvent()); 36 | Utils.go(context: context, screen: AllMusicAlbum()); 37 | }, 38 | child: const Text( 39 | 'See all', 40 | style: TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), 41 | ), 42 | ) 43 | ], 44 | ), 45 | Expanded( 46 | child: ResponsiveLayout( 47 | mobileCrossAxisCount: 1, 48 | mobileRatio: 4.4, 49 | largeMobileCrossAxisCount: 1, 50 | largeMobileRatio: 5.8, 51 | tabletCrossAxisCount: 3, 52 | tabletRatio: 3.9, 53 | largeTabletCrossAxisCount: 4, 54 | largeTabletRatio: 4, 55 | desktopRatio: 4, 56 | desktopScreenCrossAxisCount: 4, 57 | builder: (context, index) { 58 | return Padding( 59 | padding: !ResponsiveLayout.isLargeMobile( 60 | context) ? 61 | const EdgeInsets.only( 62 | top: 20, right: 20, left: 20) : 63 | const EdgeInsets.only(top: 20) 64 | , 65 | child: GestureDetector( 66 | onTap: () async { 67 | context.read().add( 68 | FolderTapEvent(path: state.folders[index]['path'].toString(), 69 | folderName: state.folders[index]['name'].toString()) 70 | ); 71 | Utils.go(context: context, screen: const SongListFolder()); 72 | }, 73 | child: Container( 74 | alignment: Alignment.center, 75 | padding: EdgeInsets.symmetric( 76 | horizontal: 10, vertical: 5), 77 | decoration: BoxDecoration( 78 | color: backgroundColor, 79 | borderRadius: BorderRadius.circular( 80 | 5), 81 | boxShadow: [ 82 | BoxShadow( 83 | color: shadowColor, 84 | offset: Offset(8, 6), 85 | blurRadius: 12), 86 | BoxShadow( 87 | color: Colors.white, 88 | offset: Offset(-8, -6), 89 | blurRadius: 12), 90 | ], 91 | ), 92 | child: Row( 93 | crossAxisAlignment: CrossAxisAlignment.center, 94 | children: [ 95 | const Icon( 96 | Icons.folder_rounded, 97 | color: Colors.orangeAccent, 98 | size: 30, 99 | ), 100 | const SizedBox(width: 10,), 101 | Expanded( 102 | flex: 2, 103 | child: Column( 104 | mainAxisAlignment: MainAxisAlignment.center, 105 | crossAxisAlignment: CrossAxisAlignment.start, 106 | children: [ 107 | Text( 108 | state 109 | .folders[index]['name'].toString(), 110 | overflow: TextOverflow.ellipsis, 111 | style: const TextStyle( 112 | color: Colors.black87, 113 | fontWeight: FontWeight.bold, 114 | fontSize: 14), 115 | ), 116 | const Text( 117 | 'Listen Music', 118 | style: TextStyle( 119 | color: Colors.grey, 120 | fontSize: 10, 121 | fontWeight: FontWeight.bold), 122 | ) 123 | ], 124 | ), 125 | ), 126 | const Spacer(), 127 | RotatedBox( 128 | quarterTurns: 1, 129 | child: SvgPicture.asset( 130 | AppSvg.more, 131 | height: 16, 132 | color: Colors.grey, 133 | )) 134 | ], 135 | ), 136 | ), 137 | ), 138 | ); 139 | }, 140 | itemCount: state.folders.length), 141 | ), 142 | ], 143 | ); 144 | } 145 | } -------------------------------------------------------------------------------- /lib/view/home/components/home_top_box.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_svg/flutter_svg.dart'; 5 | import 'package:music/res/app_images.dart'; 6 | import 'package:music/res/app_svg.dart'; 7 | 8 | import '../../../res/app_colors.dart'; 9 | 10 | class HomeIntroBox extends StatelessWidget { 11 | const HomeIntroBox({super.key}); 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Center( 16 | child: Container( 17 | width: 400, 18 | height: 150, 19 | decoration: BoxDecoration( 20 | color: backgroundColor, 21 | borderRadius: BorderRadius.circular(10), 22 | boxShadow: [ 23 | BoxShadow(color: shadowColor, offset: const Offset(8, 6), blurRadius: 12), 24 | const BoxShadow( 25 | color: Colors.white, offset: Offset(-8, -6), blurRadius: 12), 26 | ], 27 | ), 28 | child: Stack( 29 | fit: StackFit.expand, 30 | children: [ 31 | ClipRRect( 32 | borderRadius: BorderRadius.circular(10), 33 | child: Image.asset( 34 | AppImages.imageList[11]!, 35 | fit: BoxFit.cover, 36 | )), 37 | Padding( 38 | padding: const EdgeInsets.symmetric(horizontal: 20.0), 39 | child: Row( 40 | children: [ 41 | Column( 42 | crossAxisAlignment: CrossAxisAlignment.start, 43 | mainAxisAlignment: MainAxisAlignment.end, 44 | children: [ 45 | Container( 46 | height: 30, 47 | width: 80, 48 | decoration: BoxDecoration( 49 | color: Colors.black38, 50 | borderRadius: BorderRadius.circular(20), 51 | border: Border.all( 52 | color: Colors.white70, 53 | ), 54 | ), 55 | alignment: Alignment.center, 56 | child: const Text( 57 | 'See Recently', 58 | style: TextStyle(color: Colors.white, fontSize: 8), 59 | ), 60 | ), 61 | const SizedBox( 62 | height: 5, 63 | ), 64 | const Text( 65 | 'Sweet Melody', 66 | style: TextStyle( 67 | color: Colors.white, 68 | fontWeight: FontWeight.bold, 69 | fontSize: 20), 70 | ), 71 | const SizedBox( 72 | height: 5, 73 | ), 74 | const Row( 75 | // crossAxisAlignment: CrossAxisAlignment.end, 76 | children: [ 77 | Text( 78 | 'Little Mix ', 79 | style: TextStyle( 80 | color: Colors.white70, 81 | fontWeight: FontWeight.bold, 82 | fontSize: 12), 83 | ), 84 | Text( 85 | '2033533 Listeners', 86 | style: TextStyle( 87 | color: Colors.white70, 88 | fontWeight: FontWeight.bold, 89 | fontSize: 8), 90 | ), 91 | ], 92 | ), 93 | const SizedBox( 94 | height: 20, 95 | ), 96 | ], 97 | ), 98 | const Spacer(), 99 | Align( 100 | alignment: Alignment.bottomRight, 101 | child: ClipRect( 102 | child: BackdropFilter( 103 | filter: ImageFilter.blur(sigmaY: 4, sigmaX: 4), 104 | child: Container( 105 | height: 40, 106 | width: 110, 107 | margin: const EdgeInsets.only(bottom: 30), 108 | decoration: BoxDecoration( 109 | borderRadius: BorderRadius.circular(20), 110 | color: Colors.black26), 111 | child: Row( 112 | mainAxisAlignment: MainAxisAlignment.center, 113 | crossAxisAlignment: CrossAxisAlignment.center, 114 | children: [ 115 | const Text('Listen',style: TextStyle( 116 | color: Colors.white, 117 | fontWeight: FontWeight.bold, 118 | fontSize: 12 119 | ),), 120 | const SizedBox(width: 10,), 121 | CircleAvatar( 122 | radius: 11, 123 | backgroundColor: Colors.white, 124 | child: Center( 125 | child: SvgPicture.asset(AppSvg.play,color: Colors.grey,), 126 | ), 127 | ) 128 | ], 129 | ), 130 | ), 131 | ), 132 | ), 133 | ) 134 | ], 135 | ), 136 | ) 137 | ], 138 | ), 139 | ), 140 | ); 141 | } 142 | } 143 | -------------------------------------------------------------------------------- /lib/view/home/components/song_list_home.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:music/view/all_music/components/song_list.dart'; 4 | 5 | import '../../../bloc/album_bloc/album_bloc.dart'; 6 | import '../../../bloc/album_bloc/album_event.dart'; 7 | import '../../../bloc/album_bloc/album_state.dart'; 8 | import '../../common_widget/app_bar.dart'; 9 | class SongListFolder extends StatelessWidget { 10 | const SongListFolder({super.key}); 11 | @override 12 | Widget build(BuildContext context) { 13 | return Scaffold( 14 | body: PopScope( 15 | canPop: true, 16 | // onPopInvoked: (didPop) { 17 | // context.read().add( 18 | // BackArrowTap(context: context) 19 | // ); 20 | // }, 21 | onPopInvoked: (didPop) { 22 | 23 | }, 24 | child: SafeArea(child: Column( 25 | children: [ 26 | const SizedBox( 27 | height: 30, 28 | ), 29 | Padding( 30 | padding: const EdgeInsets.symmetric(horizontal: 20), 31 | child: BlocBuilder( 32 | buildWhen: (previous, current) => previous.appBarTitle!=current.appBarTitle, 33 | builder: (context, state) { 34 | return CustomAppBar( 35 | title: state.appBarTitle, 36 | preIcon: GestureDetector( 37 | onTap: () { 38 | context.read().add(BackArrowTap(context: context)); 39 | Navigator.pop(context); 40 | }, 41 | child: const Icon( 42 | Icons.arrow_back_ios_new_rounded, 43 | size: 20, 44 | ), 45 | ), 46 | postIcon: const Icon(Icons.more_horiz_rounded), 47 | ); 48 | }, 49 | ), 50 | ), 51 | const SizedBox( 52 | height: 20, 53 | ), 54 | Expanded(child: SongList()) 55 | ], 56 | )), 57 | ), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /lib/view/home/components/song_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | import 'package:music/bloc/home_bloc/home_event.dart'; 5 | import 'package:music/model/audio_file_model.dart'; 6 | import 'package:music/res/app_colors.dart'; 7 | import 'package:music/utils/utils.dart'; 8 | import 'package:music/view/common_widget/soft_button.dart'; 9 | 10 | import '../../../bloc/home_bloc/home_bloc.dart'; 11 | import '../../../bloc/player_bloc/player_bloc.dart'; 12 | import '../../../res/app_svg.dart'; 13 | 14 | class SongWidget extends StatelessWidget { 15 | const SongWidget({super.key, required this.image, required this.name, required this.length, required this.file}); 16 | final String image; 17 | final String name; 18 | final String length; 19 | final AudioFile file; 20 | @override 21 | Widget build(BuildContext context) { 22 | return Row( 23 | crossAxisAlignment: CrossAxisAlignment.center, 24 | children: [ 25 | CircleAvatar( 26 | radius: 27, 27 | backgroundImage: AssetImage(image), 28 | ), 29 | const SizedBox( 30 | width: 20, 31 | ), 32 | Expanded( 33 | flex: 2, 34 | child: Column( 35 | mainAxisAlignment: MainAxisAlignment.center, 36 | crossAxisAlignment: CrossAxisAlignment.start, 37 | children: [ 38 | Text( 39 | name, 40 | overflow: TextOverflow.ellipsis, 41 | style: const TextStyle( 42 | color: Colors.black87, 43 | fontWeight: FontWeight.bold, 44 | fontSize: 14), 45 | ), 46 | Text( 47 | length, 48 | style: const TextStyle( 49 | color: Colors.grey, 50 | fontSize: 10, 51 | fontWeight: FontWeight.bold), 52 | ) 53 | ], 54 | ), 55 | ), 56 | Spacer(), 57 | GestureDetector( 58 | onTap: () { 59 | Utils.showBottomSheet(context: context, 60 | isDismissible: true, 61 | widget: Container( 62 | decoration: BoxDecoration( 63 | borderRadius: BorderRadius.circular(30), 64 | color: backgroundColor, 65 | ), 66 | height: 120, 67 | child: Row( 68 | crossAxisAlignment: CrossAxisAlignment.center, 69 | mainAxisAlignment: MainAxisAlignment.spaceAround, 70 | children: [ 71 | GestureDetector( 72 | onTap: () { 73 | Navigator.pop(context); 74 | context 75 | .read() 76 | .add(OnPlayEvent(file: file)); 77 | // Utils.go( 78 | // context: context, 79 | // screen: Player( 80 | // file: file, 81 | // image: image, 82 | // )); 83 | }, 84 | child: Column( 85 | mainAxisAlignment: MainAxisAlignment.center, 86 | children: [ 87 | CircularSoftButton( 88 | radius: 25, 89 | padding: 0, 90 | icon: Center(child: SvgPicture.asset(AppSvg.play,width: 20,color: blueBackground,)), 91 | ), 92 | SizedBox(height: 10,), 93 | Text('Play') 94 | ], 95 | ), 96 | ), 97 | GestureDetector( 98 | onTap: () { 99 | Navigator.pop(context); 100 | context.read().add(AddToFavouriteEvent(file: file)); 101 | 102 | }, 103 | child: Column( 104 | mainAxisAlignment: MainAxisAlignment.center, 105 | children: [ 106 | CircularSoftButton( 107 | radius: 25, 108 | padding: 0, 109 | icon: Center(child: Icon(Icons.favorite,color: blueBackground,)), 110 | ), 111 | SizedBox(height: 10,), 112 | Text('Add') 113 | ], 114 | ), 115 | ), 116 | GestureDetector( 117 | onTap: () { 118 | Navigator.pop(context); 119 | context.read().add(AddToAlbum(file: file)); 120 | }, 121 | child: Column( 122 | mainAxisAlignment: MainAxisAlignment.center, 123 | children: [ 124 | CircularSoftButton( 125 | radius: 25, 126 | padding: 0, 127 | icon: Center(child: Icon(Icons.album,color: blueBackground,)), 128 | ), 129 | SizedBox(height: 10,), 130 | Text('Album') 131 | ], 132 | ), 133 | ), 134 | ], 135 | ), 136 | ), 137 | ); 138 | }, 139 | child: Padding( 140 | padding: const EdgeInsets.only(left: 10), 141 | child: RotatedBox( 142 | quarterTurns: 1, 143 | child: SvgPicture.asset( 144 | AppSvg.more, 145 | height: 16, 146 | color: Colors.grey, 147 | )), 148 | ), 149 | ) 150 | ], 151 | ); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /lib/view/home/components/songs.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:layout_pro/responsive_layout.dart'; 4 | import 'package:music/bloc/home_bloc/home_bloc.dart'; 5 | import 'package:music/bloc/home_bloc/home_state.dart'; 6 | import 'package:music/bloc/player_bloc/player_bloc.dart'; 7 | import 'package:music/utils/utils.dart'; 8 | import 'package:music/view/all_music/all_music.dart'; 9 | import 'package:music/view/home/components/song_widget.dart'; 10 | import 'package:music/view/player/player.dart'; 11 | 12 | import '../../../bloc/album_bloc/album_bloc.dart'; 13 | import '../../../bloc/album_bloc/album_event.dart'; 14 | import '../../../res/app_colors.dart'; 15 | 16 | class SongsList extends StatelessWidget { 17 | const SongsList({super.key}); 18 | 19 | @override 20 | Widget build(BuildContext context) { 21 | return Column( 22 | children: [ 23 | SizedBox( 24 | height: 20, 25 | ), 26 | Row( 27 | children: [ 28 | const Text( 29 | 'Album', 30 | style: TextStyle( 31 | color: Colors.black87, 32 | fontSize: 20, 33 | fontWeight: FontWeight.bold, 34 | ), 35 | ), 36 | Spacer(), 37 | InkWell( 38 | // onTap: () => ), 39 | onTap: () { 40 | context.read().add(GetFolderEvent()); 41 | Utils.go(context: context, screen: AllMusicAlbum()); 42 | }, 43 | child: const Text( 44 | 'See all', 45 | style: 46 | TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), 47 | ), 48 | ) 49 | ], 50 | ), 51 | 52 | Expanded(child: BlocBuilder( 53 | buildWhen: (previous, current) => previous.songList!=current.songList, 54 | builder: (context, state) { 55 | return ResponsiveLayout( 56 | mobileCrossAxisCount: 1, 57 | mobileRatio: 4.7, 58 | largeMobileCrossAxisCount: 1, 59 | largeMobileRatio: 5.8, 60 | tabletCrossAxisCount: 3, 61 | tabletRatio: 4, 62 | largeTabletCrossAxisCount: 4, 63 | largeTabletRatio: 4, 64 | desktopRatio: 4, 65 | desktopScreenCrossAxisCount: 4, 66 | builder: (context, index) { 67 | final String image = Utils.getRandomImage(); 68 | return Padding( 69 | padding: !ResponsiveLayout.isLargeMobile(context) 70 | ? const EdgeInsets.only(top: 15, ) 71 | : const EdgeInsets.only(top: 15), 72 | child: GestureDetector( 73 | onTap: () { 74 | context 75 | .read() 76 | .add(OnPlayEvent(file: state.songList[index])); 77 | Utils.go( 78 | context: context, 79 | screen: Player( 80 | file: state.songList[index], 81 | image: image, 82 | )); 83 | }, 84 | child: Container( 85 | alignment: Alignment.center, 86 | padding: 87 | const EdgeInsets.symmetric(horizontal: 10, vertical: 5), 88 | decoration: BoxDecoration( 89 | color: backgroundColor, 90 | borderRadius: BorderRadius.circular(5), 91 | boxShadow: [ 92 | BoxShadow( 93 | color: shadowColor, 94 | offset: Offset(8, 6), 95 | blurRadius: 12), 96 | const BoxShadow( 97 | color: Colors.white, 98 | offset: Offset(-8, -6), 99 | blurRadius: 12), 100 | ], 101 | ), 102 | child: SongWidget( 103 | image: image, 104 | file: state.songList[index], 105 | name: state.songList[index].name.toString(), 106 | length: state.songList[index].length.toString(),), 107 | ), 108 | ), 109 | ); 110 | }, 111 | itemCount: state.songList.length, 112 | ); 113 | 114 | }, 115 | )) 116 | ], 117 | ); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /lib/view/home/home_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:music/bloc/album_bloc/album_bloc.dart'; 4 | import 'package:music/bloc/home_bloc/home_event.dart'; 5 | import 'package:music/view/common_widget/app_bar.dart'; 6 | import 'package:music/view/common_widget/loading_files.dart'; 7 | import 'package:music/view/home/components/home_top_box.dart'; 8 | import 'package:music/view/home/components/recently_played_list.dart'; 9 | import 'package:music/view/home/components/songs.dart'; 10 | 11 | import '../../bloc/home_bloc/home_bloc.dart'; 12 | import '../../bloc/home_bloc/home_state.dart'; 13 | import 'components/home_bottom_player.dart'; 14 | import 'components/home_foler_list.dart'; 15 | 16 | class HomeView extends StatefulWidget { 17 | const HomeView({super.key}); 18 | 19 | @override 20 | State createState() => _HomeViewState(); 21 | } 22 | 23 | class _HomeViewState extends State { 24 | @override 25 | void initState() { 26 | super.initState(); 27 | context.read()..add(GetFavSongEvent())..add(GetSongEvent()); 28 | } 29 | 30 | @override 31 | Widget build(BuildContext context) { 32 | var s = context.read().state; 33 | return Scaffold( 34 | body: SafeArea( 35 | child: Padding( 36 | padding: EdgeInsets.symmetric(horizontal: 20), 37 | child: Stack( 38 | fit: StackFit.expand, 39 | children: [ 40 | Column( 41 | crossAxisAlignment: CrossAxisAlignment.start, 42 | children: [ 43 | const SizedBox( 44 | height: 30, 45 | ), 46 | const CustomAppBar(), 47 | const SizedBox( 48 | height: 40, 49 | ), 50 | const HomeIntroBox(), 51 | const RecentlyPlayedList(), 52 | Expanded( 53 | child: BlocBuilder( 54 | buildWhen: (previous, current) => current.songListStatus!=previous.songListStatus, 55 | builder: (context, loadingState) { 56 | if(loadingState.songListStatus==Status.complete){ 57 | if (loadingState.songList.isEmpty) { 58 | return HomeFolderList( 59 | state: s, 60 | ); 61 | } else { 62 | return const SongsList(); 63 | } 64 | } 65 | return const Column( 66 | children: [ 67 | SizedBox(height: 20,), 68 | Row( 69 | children: [ 70 | Text( 71 | 'Album', 72 | style: TextStyle( 73 | color: Colors.black87, 74 | fontSize: 20, 75 | fontWeight: FontWeight.bold, 76 | ), 77 | ), 78 | Spacer(), 79 | InkWell( 80 | // onTap: () => Utils.go(context: context, screen: AllMusicAlbum()), 81 | 82 | child: Text( 83 | 'See all', 84 | style: 85 | TextStyle(color: Colors.grey, fontWeight: FontWeight.bold), 86 | ), 87 | ) 88 | ], 89 | ), 90 | Expanded(child: FilesLoading()), 91 | ], 92 | ); 93 | }, 94 | ), 95 | ), 96 | ], 97 | ), 98 | const HomeBottomPlayer(), 99 | 100 | ], 101 | ), 102 | ), 103 | )); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /lib/view/onBoarding/components/boarding_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:music/bloc/boarding_bloc/boarding_bloc.dart'; 4 | import 'package:music/bloc/boarding_bloc/boarding_state.dart'; 5 | 6 | import '../../../res/app_colors.dart'; 7 | 8 | class BoardingPage extends StatelessWidget { 9 | const BoardingPage( 10 | {super.key, required this.text, this.image, required this.title}); 11 | 12 | final String text; 13 | final String title; 14 | final String? image; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | var size = MediaQuery.sizeOf(context); 19 | return Column( 20 | children: [ 21 | SizedBox( 22 | height: size.height / 5, 23 | ), 24 | Text( 25 | title, 26 | style: TextStyle( 27 | color: blueShade, fontWeight: FontWeight.bold, fontSize: 18), 28 | ), 29 | const SizedBox( 30 | height: 8, 31 | ), 32 | const Text( 33 | 'Let\'s vibe together!Create your own\nplaylist and enjoy music', 34 | textAlign: TextAlign.center, 35 | style: TextStyle(fontSize: 14), 36 | ), 37 | const SizedBox( 38 | height: 30, 39 | ), 40 | BlocBuilder( 41 | builder: (context, state) { 42 | return Row( 43 | mainAxisAlignment: MainAxisAlignment.center, 44 | children: [ 45 | ...[0, 1, 2].map((e) => Container( 46 | height: state.index == e ? 10 : 8, 47 | width: state.index == e ? 10 : 8, 48 | margin: EdgeInsets.symmetric(horizontal: 2), 49 | decoration: BoxDecoration( 50 | color: state.index == e 51 | ? lightBlueShade 52 | : Colors.grey.withOpacity(.6), 53 | shape: BoxShape.circle, 54 | ), 55 | )) 56 | ], 57 | ); 58 | }, 59 | ), 60 | SizedBox( 61 | height: 60, 62 | ), 63 | Expanded( 64 | child: Stack( 65 | alignment: Alignment.bottomCenter, 66 | children: [ 67 | Container( 68 | height: size.height / 2.5, 69 | decoration: BoxDecoration( 70 | borderRadius: BorderRadius.only( 71 | topLeft: Radius.circular(200), 72 | topRight: Radius.circular(200), 73 | ), 74 | color: Colors.grey.withOpacity(.1)), 75 | ), 76 | // Image.asset(AppIcons.splashIcons), 77 | ], 78 | )), 79 | ], 80 | ); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /lib/view/onBoarding/components/first_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:music/view/onBoarding/components/boarding_page.dart'; 3 | class FirstPage extends StatelessWidget { 4 | const FirstPage({super.key}); 5 | @override 6 | Widget build(BuildContext context) { 7 | return BoardingPage( 8 | text: 'Let\'s vibe togather!Create your\nown playlist and enjoy music', 9 | title: 'Customize Your Beast'); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /lib/view/onBoarding/components/second_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:music/view/onBoarding/components/boarding_page.dart'; 3 | 4 | class SecondPage extends StatelessWidget { 5 | const SecondPage({super.key}); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return BoardingPage( 10 | text: 'Let\'s vibe togather!Create your\nown playlist and enjoy music', 11 | title: 'Customize Your Beast'); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/view/onBoarding/components/third_page.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'boarding_page.dart'; 4 | 5 | class ThirdPage extends StatelessWidget { 6 | const ThirdPage({super.key}); 7 | 8 | @override 9 | Widget build(BuildContext context) { 10 | return BoardingPage( 11 | text: 'Let\'s vibe togather!Create your\nown playlist and enjoy music', 12 | title: 'Customize Your Beast'); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /lib/view/onBoarding/onBoarding.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_bloc/flutter_bloc.dart'; 5 | import 'package:music/bloc/boarding_bloc/boarding_bloc.dart'; 6 | import 'package:music/bloc/boarding_bloc/boarding_event.dart'; 7 | import 'package:music/view/onBoarding/components/first_page.dart'; 8 | import 'package:music/view/onBoarding/components/second_page.dart'; 9 | import 'package:music/view/onBoarding/components/third_page.dart'; 10 | 11 | class OnBoarding extends StatelessWidget { 12 | const OnBoarding({super.key}); 13 | 14 | @override 15 | Widget build(BuildContext context) { 16 | return Scaffold( 17 | floatingActionButtonLocation: FloatingActionButtonLocation.endFloat, 18 | floatingActionButton: Padding( 19 | padding: const EdgeInsets.only(bottom: 30, right: 20), 20 | child: ClipRect( 21 | child: BackdropFilter( 22 | filter: ImageFilter.blur(sigmaY: 10, sigmaX: 10), 23 | child: InkWell( 24 | onTap: () { 25 | if(context.read().state.index<3){ 26 | context.read().add(OnPageChangeEvent( 27 | index: context.read().state.index + 1)); 28 | }else{ 29 | context.read().add(LetsGoTapEvent(context: context)); 30 | } 31 | }, 32 | child: Container( 33 | height: 50, 34 | width: 120, 35 | decoration: BoxDecoration( 36 | color: Colors.black12, 37 | borderRadius: BorderRadius.circular(20), 38 | ), 39 | child: const Row( 40 | mainAxisAlignment: MainAxisAlignment.center, 41 | children: [ 42 | Text( 43 | 'Let\'s go', 44 | style: TextStyle(color: Colors.white), 45 | ), 46 | SizedBox( 47 | width: 5, 48 | ), 49 | Icon( 50 | Icons.arrow_forward_rounded, 51 | color: Colors.white, 52 | ) 53 | ], 54 | ), 55 | ), 56 | ), 57 | ), 58 | ), 59 | ), 60 | body: SafeArea( 61 | child: Stack( 62 | fit: StackFit.expand, 63 | children: [ 64 | Positioned.fill( 65 | child: PageView( 66 | controller: context.read().pageController, 67 | onPageChanged: (value) => context 68 | .read() 69 | .add(OnPageChangeEvent(index: value)), 70 | children: const [ 71 | FirstPage(), 72 | SecondPage(), 73 | ThirdPage(), 74 | ], 75 | ), 76 | ), 77 | Positioned( 78 | right: 40, 79 | top: 50, 80 | child: InkWell( 81 | onTap: () => context 82 | .read() 83 | .add(OnSkipTapEvent(context: context)), 84 | child: Text( 85 | 'Skip', 86 | ), 87 | )) 88 | ], 89 | )), 90 | ); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /lib/view/player/components/song_bottom_contianer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class SongBottomContainer extends StatelessWidget { 4 | const SongBottomContainer({super.key}); 5 | 6 | @override 7 | Widget build(BuildContext context) { 8 | return Container( 9 | height: 80, 10 | width: 320, 11 | decoration: BoxDecoration( 12 | color: Colors.black12, 13 | borderRadius: BorderRadius.circular(40) 14 | ), 15 | padding: EdgeInsets.symmetric(horizontal: 30), 16 | child: Row( 17 | children: [ 18 | Text('UP NEXT',style: TextStyle(color: Colors.black,fontWeight: FontWeight.bold, 19 | fontSize: 12 20 | ),), 21 | Spacer(), 22 | Container(height: 20,width: 3,decoration: BoxDecoration( 23 | color: Colors.black, 24 | borderRadius: BorderRadius.circular(20) 25 | ),), 26 | Spacer(), 27 | Text('LYRICS',style:TextStyle(color: Colors.black,fontWeight: FontWeight.bold, 28 | fontSize: 12 29 | ),), 30 | Spacer(), 31 | Container(height: 20,width: 3,decoration: BoxDecoration( 32 | color: Colors.black, 33 | borderRadius: BorderRadius.circular(20) 34 | ),), 35 | Spacer(), 36 | Text('RELATED',style:TextStyle(color: Colors.black,fontWeight: FontWeight.bold, 37 | fontSize: 12 38 | ),), 39 | ], 40 | ), 41 | ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /lib/view/player/components/song_circle_container.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:flutter_svg/svg.dart'; 4 | import 'package:music/bloc/player_bloc/player_bloc.dart'; 5 | import 'package:music/model/audio_file_model.dart'; 6 | 7 | import '../../../res/app_colors.dart'; 8 | import '../../../res/app_svg.dart'; 9 | import '../../common_widget/soft_button.dart'; 10 | 11 | class SongCircleContainer extends StatelessWidget { 12 | const SongCircleContainer({super.key, required this.file, required this.image}); 13 | final String image; 14 | final AudioFile file; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return SizedBox( 19 | height: 300, 20 | width: MediaQuery.sizeOf(context).width, 21 | child: Stack( 22 | alignment: Alignment.topCenter, 23 | // fit: StackFit.expand, 24 | children: [ 25 | Container( 26 | height: 270, 27 | width: 270, 28 | margin: const EdgeInsets.only(bottom: 20), 29 | decoration: BoxDecoration( 30 | color: backgroundColor, 31 | boxShadow: [ 32 | BoxShadow( 33 | color: shadowColor, 34 | offset: const Offset(8, 6), 35 | blurRadius: 12), 36 | const BoxShadow( 37 | color: Colors.white, 38 | offset: Offset(-8, -6), 39 | blurRadius: 12), 40 | ], 41 | shape: BoxShape.circle), 42 | ), 43 | Positioned( 44 | top: 20, 45 | child: CircularSoftButton( 46 | padding: 0, 47 | radius: 120, 48 | icon: Padding( 49 | padding: const EdgeInsets.all(8.0), 50 | child: ClipRRect( 51 | borderRadius: BorderRadius.circular(300), 52 | child: Image.asset( 53 | image, 54 | fit: BoxFit.cover, 55 | )), 56 | ), 57 | ), 58 | ), 59 | Container( 60 | height: 270, 61 | width: 270, 62 | padding: EdgeInsets.all(10), 63 | child: Transform.flip( 64 | flipX: true, 65 | child: Transform.rotate( 66 | angle: 0.5, 67 | child: RotatedBox( 68 | quarterTurns: 2, 69 | child: BlocBuilder( 70 | builder: (context, state) { 71 | return CircularProgressIndicator( 72 | color: blueBackground, 73 | backgroundColor: Colors.grey.withOpacity(.1), 74 | value: state.progress, 75 | strokeWidth: 7, 76 | strokeCap: StrokeCap.round, 77 | ); 78 | }, 79 | ), 80 | ), 81 | ), 82 | ), 83 | ), 84 | Positioned( 85 | bottom: 7, 86 | child: GestureDetector( 87 | onTap: () => context.read().add(PlayPauseEvent( 88 | file: file, 89 | isPlaying: !context.read().isPlaying)), 90 | child: CircleAvatar( 91 | radius: 32, 92 | backgroundColor: blueBackground, 93 | child: BlocBuilder( 94 | buildWhen: (previous, current) => 95 | previous.isPlaying != current.isPlaying, 96 | builder: (context, state) { 97 | return AnimatedSwitcher( 98 | switchInCurve: Curves.easeInOutBack, 99 | transitionBuilder: (child, animation) { 100 | return ScaleTransition( 101 | scale: animation, 102 | child: child, 103 | ); 104 | }, 105 | duration: const Duration(milliseconds: 300), 106 | child: Center( 107 | child: SvgPicture.asset( 108 | state.isPlaying ? AppSvg.pause : AppSvg.play, 109 | color: Colors.white, 110 | width: 20, 111 | ), 112 | ), 113 | ); 114 | }, 115 | ), 116 | ), 117 | ), 118 | ), 119 | ], 120 | ), 121 | ); 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /lib/view/player/components/song_controllers.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_bloc/flutter_bloc.dart'; 4 | import 'package:flutter_svg/svg.dart'; 5 | import 'package:music/bloc/home_bloc/home_bloc.dart'; 6 | import 'package:music/bloc/home_bloc/home_event.dart'; 7 | import 'package:music/bloc/player_bloc/player_bloc.dart'; 8 | import 'package:music/model/audio_file_model.dart'; 9 | import 'package:music/res/app_colors.dart'; 10 | import 'package:music/view/common_widget/soft_button.dart'; 11 | import '../../../res/app_svg.dart'; 12 | 13 | class SongControllers extends StatelessWidget { 14 | const SongControllers({super.key, required this.file}); 15 | final AudioFile file; 16 | @override 17 | Widget build(BuildContext context) { 18 | return Row( 19 | mainAxisAlignment: MainAxisAlignment.center, 20 | children: [ 21 | // SvgPicture.asset(AppSvg.loop, width: 20,), 22 | GestureDetector( 23 | child: const Icon(Icons.volume_down_alt,color: Colors.black,)), 24 | const SizedBox(width: 20,), 25 | GestureDetector( 26 | onTap: () => context.read().add(OnTapBackwardEvent()), 27 | child: RotatedBox( 28 | quarterTurns: 2, 29 | child: SvgPicture.asset(AppSvg.prev, width: 25,)), 30 | ), 31 | const SizedBox(width: 20,), 32 | CircularSoftButton( 33 | radius: 25, 34 | padding: 0, 35 | icon: GestureDetector( 36 | onTap: () async { 37 | try{ 38 | context.read().add(OnTapFavouriteEvent(file: file,context: context)); 39 | }catch(_){ 40 | 41 | } 42 | Timer(const Duration(milliseconds: 500), () { 43 | context.read().add(GetFavSongEvent()); 44 | }); 45 | 46 | }, 47 | child: BlocBuilder( 48 | builder: (context, state) { 49 | return Icon( Icons.favorite, color: state.isFavourite ? blueBackground :Colors.black87,); 50 | }, 51 | ), 52 | ), 53 | ), 54 | const SizedBox(width: 20,), 55 | GestureDetector( 56 | onTap: () => context.read().add(OnTapForwardEvent()), 57 | child: SvgPicture.asset(AppSvg.next, width: 25,)), 58 | const SizedBox(width: 20,), 59 | SvgPicture.asset(AppSvg.loop, width: 20,), 60 | ], 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/view/player/components/song_title.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:music/model/audio_file_model.dart'; 3 | 4 | import '../../../res/app_colors.dart'; 5 | 6 | class SongTitle extends StatelessWidget { 7 | const SongTitle({super.key, required this.file}); 8 | final AudioFile file; 9 | @override 10 | Widget build(BuildContext context) { 11 | return Padding( 12 | padding: const EdgeInsets.only(top: 70,bottom: 60), 13 | child: Column( 14 | children: [ 15 | 16 | Text( 17 | file.name.toString().length>20? '${file.name.toString().substring(0,20)}...':file.name.toString(), 18 | style: const TextStyle( 19 | color: Colors.black87, 20 | fontWeight: FontWeight.bold, 21 | fontSize: 20), 22 | ), 23 | Text( 24 | 'Listen Music', 25 | style: TextStyle( 26 | color: blueBackground, 27 | fontWeight: FontWeight.bold, 28 | fontSize: 12), 29 | ), 30 | 31 | ], 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/view/player/player.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_svg/flutter_svg.dart'; 3 | import 'package:music/model/audio_file_model.dart'; 4 | import 'package:music/res/app_svg.dart'; 5 | import 'package:music/view/common_widget/app_bar.dart'; 6 | import 'package:music/view/player/components/song_bottom_contianer.dart'; 7 | import 'package:music/view/player/components/song_controllers.dart'; 8 | import 'package:music/view/player/components/song_title.dart'; 9 | 10 | import 'components/song_circle_container.dart'; 11 | class Player extends StatelessWidget { 12 | const Player({super.key, required this.file, required this.image}); 13 | final AudioFile file; 14 | final String image; 15 | @override 16 | Widget build(BuildContext context) { 17 | return Scaffold( 18 | body: SafeArea( 19 | child:Stack( 20 | fit: StackFit.expand, 21 | children: [ 22 | Positioned( 23 | top: 1, 24 | height: MediaQuery.sizeOf(context).height-100, 25 | width: MediaQuery.sizeOf(context).width, 26 | child: Center( 27 | child: SongCircleContainer(file : file,image:image, 28 | ), 29 | ), 30 | ), 31 | Padding( 32 | padding: const EdgeInsets.symmetric(horizontal: 20,vertical: 30), 33 | child: Column( 34 | children: [ 35 | CustomAppBar( 36 | preIcon: InkWell( 37 | onTap: () => Navigator.pop(context), 38 | child: Icon( 39 | Icons.keyboard_arrow_down_outlined, 40 | color: Colors.black, 41 | ), 42 | ), 43 | postIcon: SvgPicture.asset( 44 | AppSvg.more, 45 | width: 17, 46 | ), 47 | ), 48 | SongTitle(file: file,), 49 | Spacer(), 50 | SongControllers(file: file,), 51 | const SizedBox(height: 50,), 52 | const SongBottomContainer(), 53 | // SizedBox(height: 40,) 54 | ], 55 | ), 56 | ), 57 | 58 | ], 59 | ), 60 | ), 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /lib/view/splash/splash.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_bloc/flutter_bloc.dart'; 3 | import 'package:music/bloc/album_bloc/album_bloc.dart'; 4 | import 'package:music/bloc/album_bloc/album_event.dart'; 5 | import 'package:music/res/app_icons.dart'; 6 | import 'package:music/view/common_widget/soft_button.dart'; 7 | 8 | import '../../view_model/services/splash_services.dart'; 9 | 10 | class SplashScreen extends StatefulWidget { 11 | const SplashScreen({super.key}); 12 | @override 13 | State createState() => _SplashScreenState(); 14 | } 15 | 16 | class _SplashScreenState extends State { 17 | @override 18 | void initState() { 19 | super.initState(); 20 | SplashServices.isFirstTime(context: context); 21 | // context.read().add(GetFilesEvent()); 22 | } 23 | @override 24 | Widget build(BuildContext context) { 25 | return Scaffold( 26 | body: Center( 27 | child: Column( 28 | mainAxisAlignment: MainAxisAlignment.center, 29 | crossAxisAlignment: CrossAxisAlignment.center, 30 | children: [ 31 | CircularSoftButton( 32 | radius: 45, 33 | padding: 10, 34 | icon: Container( 35 | margin: const EdgeInsets.all(5), 36 | child: Center( 37 | child: Icon(Icons.play_arrow_rounded,color: Colors.blue,size: 60,), 38 | ), 39 | ), 40 | ), 41 | Text('Music',style: TextStyle( 42 | color: Colors.blue, 43 | fontWeight: FontWeight.bold, 44 | fontSize: 30 45 | ),) 46 | ], 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/view_model/services/audio_query_services.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | import 'dart:math'; 3 | 4 | import 'package:just_audio/just_audio.dart'; 5 | import 'package:music/model/audio_file_model.dart'; 6 | import 'package:on_audio_query/on_audio_query.dart'; 7 | import 'package:path/path.dart' as path; 8 | 9 | import '../../utils/utils.dart'; 10 | 11 | class AudioFileQueries{ 12 | static List favourite=[]; 13 | static Future> getFiles(String _path) async { 14 | List audioList = []; 15 | final isPermissionGranted = await Utils.requestPermission(); 16 | if (isPermissionGranted) { 17 | Directory directory = Directory(_path); 18 | List files = directory.listSync(); 19 | List audioExtensions = ['.mp3', '.wav', '.au', '.aac', '.smi', '.flac', '.ogg', '.m4a', '.wma']; 20 | for (int i = 0; i < files.length; i++) { 21 | String extension = path.extension(files[i].path).toLowerCase(); 22 | if (audioExtensions.contains(extension)) { 23 | String name = path.basename(files[i].path); 24 | String size = File(files[i].path).lengthSync().toString(); 25 | String length = await getFileLength(files[i].path); 26 | int isFavourite = 0; 27 | 28 | audioList.add(AudioFile( 29 | id: Random().nextInt(1000000), 30 | name: name, 31 | path: files[i].path, 32 | size: size, 33 | length: length, 34 | isFavourite: isFavourite, 35 | )); 36 | } 37 | } 38 | } else { 39 | return []; 40 | } 41 | 42 | return audioList; 43 | } 44 | static Future getFileLength(String filePath)async{ 45 | AudioPlayer player=AudioPlayer(); 46 | final _= await player.setFilePath(filePath); 47 | String prefix=player.duration!.inMinutes.toString(); 48 | String postFix=(player.duration!.inSeconds % 60).toString(); 49 | if(prefix.length<2){ 50 | prefix='0$prefix'; 51 | } 52 | if(postFix.length<2){ 53 | postFix='0$postFix'; 54 | } 55 | player.dispose(); 56 | return '$prefix:$postFix'; 57 | } 58 | static Future>> getFolders() async { 59 | List> list=[]; 60 | final audioQuery = OnAudioQuery(); 61 | List folders = await audioQuery.queryAllPath(); 62 | for(var folder in folders){ 63 | list.add({ 64 | 'path' : folder, 65 | 'name' : path.basename(folder) 66 | }); 67 | } 68 | return list; 69 | } 70 | } -------------------------------------------------------------------------------- /lib/view_model/services/splash_services.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:flutter/material.dart'; 4 | import 'package:music/utils/utils.dart'; 5 | import 'package:music/view/home/home_view.dart'; 6 | import 'package:permission_handler/permission_handler.dart'; 7 | class SplashServices{ 8 | static isFirstTime({required BuildContext context})async{ 9 | bool permission=await Utils.requestPermission(); 10 | Timer(const Duration(milliseconds: 1500), () async { 11 | if(permission){ 12 | Utils.go(context: context, screen: const HomeView(),replace: true); 13 | }else{ 14 | await openAppSettings(); 15 | } 16 | }); 17 | 18 | 19 | // SharedPreferences pref=await SharedPreferences.getInstance(); 20 | // final check=pref.getBool('OPENED') ?? false; 21 | // Timer(const Duration(seconds: 2), () { 22 | // if(check){ 23 | // Utils.go(context: context, screen: const HomeView(),replace: true); 24 | // }else{ 25 | // Utils.go(context: context, screen: const OnBoarding(),replace: true); 26 | // } 27 | // }); 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: music 2 | description: "A new Flutter project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: '>=3.2.0 <4.0.0' 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | 34 | 35 | # The following adds the Cupertino Icons font to your application. 36 | # Use with the CupertinoIcons class for iOS style icons. 37 | cupertino_icons: ^1.0.2 38 | shared_preferences: 39 | bloc: 40 | flutter_bloc: 41 | equatable: 42 | google_fonts: 43 | flutter_svg: 44 | sqflite: 45 | path_provider: 46 | path: 47 | permission_handler: 48 | just_audio: 49 | on_audio_query: 50 | layout_pro: 51 | shimmer_effect: 52 | 53 | dev_dependencies: 54 | flutter_test: 55 | sdk: flutter 56 | 57 | # The "flutter_lints" package below contains a set of recommended lints to 58 | # encourage good coding practices. The lint set provided by the package is 59 | # activated in the `analysis_options.yaml` file located at the root of your 60 | # package. See that file for information about deactivating specific lint 61 | # rules and activating additional ones. 62 | flutter_lints: ^2.0.0 63 | 64 | # For information on the generic Dart part of this file, see the 65 | # following page: https://dart.dev/tools/pub/pubspec 66 | 67 | # The following section is specific to Flutter packages. 68 | flutter: 69 | 70 | # The following line ensures that the Material Icons font is 71 | # included with your application, so that you can use the icons in 72 | # the material Icons class. 73 | uses-material-design: true 74 | 75 | # To add assets to your application, add an assets section, like this: 76 | assets: 77 | - assets/images/ 78 | - assets/svgs/ 79 | - assets/icons/ 80 | # - images/a_dot_ham.jpeg 81 | 82 | # An image asset can refer to one or more resolution-specific "variants", see 83 | # https://flutter.dev/assets-and-images/#resolution-aware 84 | 85 | # For details regarding adding assets from package dependencies, see 86 | # https://flutter.dev/assets-and-images/#from-packages 87 | 88 | # To add custom fonts to your application, add a fonts section here, 89 | # in this "flutter" section. Each entry in this list should have a 90 | # "family" key with the font family name, and a "fonts" key with a 91 | # list giving the asset and other descriptors for the font. For 92 | # example: 93 | # fonts: 94 | # - family: Schyler 95 | # fonts: 96 | # - asset: fonts/Schyler-Regular.ttf 97 | # - asset: fonts/Schyler-Italic.ttf 98 | # style: italic 99 | # - family: Trajan Pro 100 | # fonts: 101 | # - asset: fonts/TrajanPro.ttf 102 | # - asset: fonts/TrajanPro_Bold.ttf 103 | # weight: 700 104 | # 105 | # For details regarding fonts from package dependencies, 106 | # see https://flutter.dev/custom-fonts/#from-packages 107 | -------------------------------------------------------------------------------- /test/widget_test.dart: -------------------------------------------------------------------------------- 1 | // This is a basic Flutter widget test. 2 | // 3 | // To perform an interaction with a widget in your test, use the WidgetTester 4 | // utility in the flutter_test package. For example, you can send tap and scroll 5 | // gestures. You can also use WidgetTester to find child widgets in the widget 6 | // tree, read text, and verify that the values of widget properties are correct. 7 | 8 | import 'package:flutter/material.dart'; 9 | import 'package:flutter_test/flutter_test.dart'; 10 | 11 | import 'package:music/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(music LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "music") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | permission_handler_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.dev" "\0" 93 | VALUE "FileDescription", "music" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "music" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.dev. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "music.exe" "\0" 98 | VALUE "ProductName", "music" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"music", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Hamad-Anwar/Flutter-Music-Player-App-With-BLoc/fc7324c8d78b3f9ea5390876b77673ce5e86436e/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length <= 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | --------------------------------------------------------------------------------