├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ ├── google-services.json │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── java │ │ │ └── io │ │ │ │ └── flutter │ │ │ │ └── app │ │ │ │ └── FlutterMultiDexApplication.java │ │ ├── kotlin │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── blog_app │ │ │ │ └── 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 └── images │ └── logo.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 ├── lib ├── app │ ├── data │ │ ├── const.dart │ │ ├── firebase │ │ │ ├── firebase_auth.dart │ │ │ └── firebase_functions.dart │ │ └── global_widgets │ │ │ ├── app_bar.dart │ │ │ ├── custom_button.dart │ │ │ ├── indicator.dart │ │ │ ├── post.dart │ │ │ ├── text_field.dart │ │ │ ├── tiles.dart │ │ │ └── title_logo.dart │ ├── models │ │ └── blog_model.dart │ ├── modules │ │ ├── authentication │ │ │ ├── bindings │ │ │ │ └── authentication_binding.dart │ │ │ ├── controllers │ │ │ │ └── authentication_controller.dart │ │ │ └── views │ │ │ │ └── authentication_view.dart │ │ ├── blog_detail_screen │ │ │ ├── bindings │ │ │ │ └── blog_detail_screen_binding.dart │ │ │ ├── controllers │ │ │ │ └── blog_detail_screen_controller.dart │ │ │ └── views │ │ │ │ └── blog_detail_screen_view.dart │ │ ├── favourite │ │ │ ├── bindings │ │ │ │ └── favourite_binding.dart │ │ │ ├── controllers │ │ │ │ └── favourite_controller.dart │ │ │ └── views │ │ │ │ └── favourite_view.dart │ │ ├── home │ │ │ ├── bindings │ │ │ │ └── home_binding.dart │ │ │ ├── controllers │ │ │ │ └── home_controller.dart │ │ │ └── views │ │ │ │ └── home_view.dart │ │ ├── login │ │ │ ├── bindings │ │ │ │ └── login_binding.dart │ │ │ ├── controllers │ │ │ │ └── login_controller.dart │ │ │ └── views │ │ │ │ └── login_view.dart │ │ ├── my_blogs │ │ │ ├── bindings │ │ │ │ └── my_blogs_binding.dart │ │ │ ├── controllers │ │ │ │ └── my_blogs_controller.dart │ │ │ └── views │ │ │ │ └── my_blogs_view.dart │ │ ├── profile │ │ │ ├── bindings │ │ │ │ └── profile_binding.dart │ │ │ ├── controllers │ │ │ │ └── profile_controller.dart │ │ │ └── views │ │ │ │ └── profile_view.dart │ │ ├── sign_up │ │ │ ├── bindings │ │ │ │ └── sign_up_binding.dart │ │ │ ├── controllers │ │ │ │ └── sign_up_controller.dart │ │ │ └── views │ │ │ │ └── sign_up_view.dart │ │ ├── title │ │ │ ├── bindings │ │ │ │ └── title_binding.dart │ │ │ ├── controllers │ │ │ │ └── title_controller.dart │ │ │ └── views │ │ │ │ └── title_view.dart │ │ └── upload_blog │ │ │ ├── bindings │ │ │ └── upload_blog_binding.dart │ │ │ ├── controllers │ │ │ └── upload_blog_controller.dart │ │ │ └── views │ │ │ └── upload_blog_view.dart │ └── routes │ │ ├── app_pages.dart │ │ └── app_routes.dart ├── generated_plugin_registrant.dart └── main.dart ├── linux ├── .gitignore ├── CMakeLists.txt ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake ├── main.cc ├── my_application.cc └── my_application.h ├── macos ├── .gitignore ├── Flutter │ ├── Flutter-Debug.xcconfig │ ├── Flutter-Release.xcconfig │ └── GeneratedPluginRegistrant.swift ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── app_icon_1024.png │ │ ├── app_icon_128.png │ │ ├── app_icon_16.png │ │ ├── app_icon_256.png │ │ ├── app_icon_32.png │ │ ├── app_icon_512.png │ │ └── app_icon_64.png │ ├── Base.lproj │ └── MainMenu.xib │ ├── Configs │ ├── AppInfo.xcconfig │ ├── Debug.xcconfig │ ├── Release.xcconfig │ └── Warnings.xcconfig │ ├── DebugProfile.entitlements │ ├── Info.plist │ ├── MainFlutterWindow.swift │ └── Release.entitlements ├── pubspec.lock ├── pubspec.yaml ├── test └── widget_test.dart ├── web ├── favicon.png ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html └── manifest.json └── 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 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Web related 36 | lib/generated_plugin_registrant.dart 37 | 38 | # Symbolication related 39 | app.*.symbols 40 | 41 | # Obfuscation related 42 | app.*.map.json 43 | 44 | # Android Studio will place build artifacts here 45 | /android/app/debug 46 | /android/app/profile 47 | /android/app/release 48 | -------------------------------------------------------------------------------- /.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. 5 | 6 | version: 7 | revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 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: fb57da5f945d02ef4f98dfd9409a72b7cce74268 17 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 18 | - platform: android 19 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 20 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 21 | - platform: ios 22 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 23 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 24 | - platform: linux 25 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 26 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 27 | - platform: macos 28 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 29 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 30 | - platform: web 31 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 32 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 33 | - platform: windows 34 | create_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 35 | base_revision: fb57da5f945d02ef4f98dfd9409a72b7cce74268 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Md. Abdullah Ibna Harun 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # blog_app 2 | 3 | ### Introduction 4 | 5 | The purpose of this project was the design of a Basic Blog application using a UI toolkit for crafting apps for mobile, web, and desktop named Flutter. This project is supposed to execute the common functionality of any CRUD application. With, This Blog Application, at first you need to Sign-in or Sign-Up then you can create a blog by clicking on the (Create Blog) button shown on the home screen, and type, save and view, the data will be stored in firebase storage. Our blog app is an entire service It has the (My Blogs) option, which allows you to do things such as delete or update them in one place. You can make a collection of your favorite blogs, It is easy to use and a very light project. 6 | 7 | ### Development Tools 8 | 9 | Hardware and Software Requirements for Development – 10 | 11 | Any desktop/laptop with 8GB RAM and a 2.0 GHz Processor that is capable of running a modern web browser For Development/Debugging. 12 | Any smartphone with 2+ GB RAM and a 1+ GHz processor For Using App. 13 | Used Tools in this project are mentioned below - 14 | 15 | • Framework/library – Flutter 3.0.1, GetX 16 | 17 | • Language – Dart v2.5 18 | 19 | • Database – Firebase. 20 | 21 | • Authentication – Firebase Auth. 22 | 23 | • IDE - VS Code 24 | 25 | • Version Control – GitHub 26 | 27 | • Android Emulator – Google Pixel. (Android v 7.0) 28 | 29 | 30 | 31 | ### Objective 32 | 33 | There are several objectives behind this project that can be described. However, the most significant aims of carrying out this project work are: 34 | 35 | 1. To implement our first project in a new framework and participate in the implementation of a project. 36 | 2. To design a project using flutter and manipulate object-oriented programming and perform input-output and store data. 37 | 3. The areas of application of the project are development challenges related to learning and front-end development. 38 | 4. To apply and adapt a variety of problem-solving strategies to solve real-life problems in a flutter. 39 | 5. To promote decoupling designing knowledge as well as effective thinking skills 40 | 6. To develop a CRUD app with Firebase. 41 | 7. Develop good coding habits like Using separate code class declaration and implementation 42 | 8. Use functions to make the code concise and modular by using Getx. 43 | 9. Use comments where necessary. 44 | 10. Develop this project Use of Version control. 45 | 46 | ### Motivation 47 | 48 | There are many major motivations behind this project. One of them is getting ourselves prepared for Mobile App developers and the second one is working with a real-life problem-solving project. For becoming developers it’s good to start with Mobiles Application Development in Flutter, which supports development cross-platform. Blog applications are a great way for you to make some personal blogs. Whereas you would post with more detail, these applications are great for writing personal basic blogs. From here, In conclusion, the motive was to step on the very first step of mobile application development solving a real-life problem. 49 | 50 | ### Functional requirements 51 | 52 | 1. Register App. 53 | 2. Login App. 54 | 3. Create, view, and update blogs with a picture. 55 | 4. Blog Preview from Firestore. 56 | 5. Add and Remove favorite blog. 57 | 6. Delete blog. 58 | 7. Update Blog. 59 | 8. Logout. 60 | 61 | ### Use-Case Diagram 62 | 63 | ![image](https://user-images.githubusercontent.com/60839928/175297660-310cce54-1be6-4d15-a748-99cf39b64159.png) 64 | 65 | ### Entity Relationship Diagram 66 | 67 | ![image](https://user-images.githubusercontent.com/60839928/175297701-181261a5-ad4c-4ebf-9292-2c7225906cfd.png) 68 | 69 | ### Working process 70 | 71 | ![image](https://user-images.githubusercontent.com/60839928/175297954-5b025040-c97f-44c7-ac72-528a95d1c908.png) 72 | 73 | 74 | ## Snapshot 75 | 76 | ![image](https://user-images.githubusercontent.com/60839928/175298484-22ed93e2-b912-4052-9c39-aa6713d728ec.png) 77 | 78 | ![image](https://user-images.githubusercontent.com/60839928/175298527-a7bfbcd3-144c-462e-9673-0d198f8c512f.png) 79 | 80 | ![image](https://user-images.githubusercontent.com/60839928/175298589-c1ee3fa7-b01d-4059-8ce9-a825d28a9ebf.png) 81 | 82 | ![image](https://user-images.githubusercontent.com/60839928/175350212-6c0bbb60-230f-4fbd-b145-e1367465e1bb.png) 83 | 84 | 85 | ![image](https://user-images.githubusercontent.com/60839928/175298675-278ba731-89c4-4b2e-bf71-4234d58044f6.png) 86 | 87 | 88 | ### Challenges 89 | 90 | • Faced error in Firebase Authentication. 91 | 92 | • Different kinds of Flutter Dependency version issues. 93 | 94 | • Faced not getting any data from user input. 95 | 96 | • Front end logical issue. 97 | 98 | • Go-back preview Problems. 99 | 100 | ### Future Updates 101 | 102 | • User Details Service. 103 | 104 | • Master Admin and Moderator Integration. 105 | 106 | • Relational Database. 107 | 108 | • Share and comment on blogs. 109 | 110 | • Categorize Blogs. 111 | 112 | • Search Blog. 113 | 114 | ### Conclusion 115 | 116 | This was a great experience doing this project. This project was intended to make a basic blog application with GetX. I hope the intention of the program gets fully filled out. The challenges faced and the learning I have gone through will come of great help in the future. There is something that should be noted in this conclusion. 117 | 118 | Limitations: Still there are some limitations to this blog app. If I just want to go through a brief discussion then we can say that we could make the UI more attractive. We could add more features to this project. 119 | 120 | • It would be better if I could add time and date for each post. 121 | 122 | • It would be better if creator details were also shown in their blog post. 123 | 124 | • If I could add auto-reload functionality in this app. 125 | 126 | • If I could make a more efficient UI. 127 | 128 | I have found out the mentioned limitations above. I am so on it to meet those limitations and build a competitive application. 129 | 130 | Highlighting point: 131 | 132 | • Authorized Users can create a blog post in this application. 133 | 134 | • Authorized Users can update and delete any post at any time. 135 | 136 | • The UI is simple and minimal. 137 | 138 | • This App has Favourite options. 139 | 140 | • Firebase Authentication For better security. 141 | 142 | 143 | ### Future Scope 144 | This project has achieved the objective of building a simple application using flutter, The development of this project has been achieved by using dart and flutter with Getx and may dev. tools that are becoming popular and likely to be the choice for the cross-platform application. This project can be further extended as per user requirements Because this is developed by using decoupling version controlling. 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /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 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /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 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | apply plugin: 'com.google.gms.google-services' 28 | 29 | android { 30 | compileSdkVersion flutter.compileSdkVersion 31 | ndkVersion flutter.ndkVersion 32 | 33 | compileOptions { 34 | sourceCompatibility JavaVersion.VERSION_1_8 35 | targetCompatibility JavaVersion.VERSION_1_8 36 | } 37 | 38 | kotlinOptions { 39 | jvmTarget = '1.8' 40 | } 41 | 42 | sourceSets { 43 | main.java.srcDirs += 'src/main/kotlin' 44 | } 45 | 46 | defaultConfig { 47 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 48 | applicationId "com.example.blog_app" 49 | // You can update the following values to match your application needs. 50 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 51 | minSdkVersion flutter.minSdkVersion = 20; 52 | targetSdkVersion flutter.targetSdkVersion; 53 | versionCode flutterVersionCode.toInteger() 54 | versionName flutterVersionName 55 | } 56 | 57 | buildTypes { 58 | release { 59 | // TODO: Add your own signing config for the release build. 60 | // Signing with the debug keys for now, so `flutter run --release` works. 61 | signingConfig signingConfigs.debug 62 | } 63 | } 64 | } 65 | 66 | flutter { 67 | source '../..' 68 | } 69 | 70 | dependencies { 71 | implementation platform('com.google.firebase:firebase-bom:30.1.0') 72 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 73 | } 74 | -------------------------------------------------------------------------------- /android/app/google-services.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_info": { 3 | "project_number": "726420206480", 4 | "project_id": "blog-app-ec969", 5 | "storage_bucket": "blog-app-ec969.appspot.com" 6 | }, 7 | "client": [ 8 | { 9 | "client_info": { 10 | "mobilesdk_app_id": "1:726420206480:android:db05b719e5f514f2053915", 11 | "android_client_info": { 12 | "package_name": "com.example.blog_app" 13 | } 14 | }, 15 | "oauth_client": [ 16 | { 17 | "client_id": "726420206480-q074rbbpiqq9dbrcq0dtk72pvfgjbip8.apps.googleusercontent.com", 18 | "client_type": 3 19 | } 20 | ], 21 | "api_key": [ 22 | { 23 | "current_key": "AIzaSyCPGdjHBlY1cAweBY4UfXF77B85NEdvNos" 24 | } 25 | ], 26 | "services": { 27 | "appinvite_service": { 28 | "other_platform_oauth_client": [ 29 | { 30 | "client_id": "726420206480-q074rbbpiqq9dbrcq0dtk72pvfgjbip8.apps.googleusercontent.com", 31 | "client_type": 3 32 | } 33 | ] 34 | } 35 | } 36 | } 37 | ], 38 | "configuration_version": "1" 39 | } -------------------------------------------------------------------------------- /android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /android/app/src/main/java/io/flutter/app/FlutterMultiDexApplication.java: -------------------------------------------------------------------------------- 1 | // Generated file. 2 | // 3 | // If you wish to remove Flutter's multidex support, delete this entire file. 4 | // 5 | // Modifications to this file should be done in a copy under a different name 6 | // as this file may be regenerated. 7 | 8 | package io.flutter.app; 9 | 10 | import android.app.Application; 11 | import android.content.Context; 12 | import androidx.annotation.CallSuper; 13 | import androidx.multidex.MultiDex; 14 | 15 | /** 16 | * Extension of {@link android.app.Application}, adding multidex support. 17 | */ 18 | public class FlutterMultiDexApplication extends Application { 19 | @Override 20 | @CallSuper 21 | protected void attachBaseContext(Context base) { 22 | super.attachBaseContext(base); 23 | MultiDex.install(this); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /android/app/src/main/kotlin/com/example/blog_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.blog_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.6.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.1.2' 10 | classpath 'com.google.gms:google-services:4.3.10' 11 | // classpath 'com.google.gms:google-services:4.3.0' 12 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 13 | } 14 | } 15 | 16 | allprojects { 17 | repositories { 18 | google() 19 | mavenCentral() 20 | } 21 | } 22 | 23 | rootProject.buildDir = '../build' 24 | subprojects { 25 | project.buildDir = "${rootProject.buildDir}/${project.name}" 26 | } 27 | subprojects { 28 | project.evaluationDependsOn(':app') 29 | } 30 | 31 | task clean(type: Delete) { 32 | delete rootProject.buildDir 33 | } 34 | 35 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip 7 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /assets/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/assets/images/logo.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 | 9.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 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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 | Blog App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | blog_app 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 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/app/data/const.dart: -------------------------------------------------------------------------------- 1 | import 'package:fluttertoast/fluttertoast.dart'; 2 | import 'package:uuid/uuid.dart'; 3 | 4 | void showAlert(String message) { 5 | Fluttertoast.showToast(msg: message); 6 | } 7 | 8 | String generateId() { 9 | return const Uuid().v1(); 10 | } 11 | -------------------------------------------------------------------------------- /lib/app/data/firebase/firebase_auth.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/routes/app_pages.dart'; 2 | import 'package:firebase_auth/firebase_auth.dart'; 3 | import 'package:get/get.dart'; 4 | 5 | class FirebaseAuthentication { 6 | final FirebaseAuth _auth = FirebaseAuth.instance; 7 | 8 | get instance => null; 9 | 10 | Future createAccount(String email, String password) async { 11 | try { 12 | await _auth.createUserWithEmailAndPassword( 13 | email: email, 14 | password: password, 15 | ); 16 | } catch (e) { 17 | print(e.toString()); 18 | } 19 | } 20 | 21 | Future login(String email, String password) async { 22 | try { 23 | await _auth.signInWithEmailAndPassword(email: email, password: password); 24 | } catch (e) { 25 | print(e.toString()); 26 | } 27 | } 28 | 29 | Future logOut() async { 30 | try { 31 | await _auth.signOut().whenComplete(() { 32 | Get.toNamed(Routes.LOGIN); 33 | }); 34 | // await _auth.signOut().then((value) { 35 | // Get.toNamed(Routes.AUTHENTICATION); 36 | // }); 37 | } catch (e) { 38 | print(e.toString()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/app/data/firebase/firebase_functions.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:blog_app/app/data/const.dart'; 4 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 5 | import 'package:blog_app/app/models/blog_model.dart'; 6 | import 'package:blog_app/app/routes/app_pages.dart'; 7 | import 'package:cloud_firestore/cloud_firestore.dart'; 8 | import 'package:firebase_auth/firebase_auth.dart'; 9 | import 'package:firebase_storage/firebase_storage.dart'; 10 | import 'package:get/get.dart'; 11 | 12 | class FirebaseFunctions { 13 | final FirebaseFirestore _firebaseFirestore = FirebaseFirestore.instance; 14 | final FirebaseAuth _auth = FirebaseAuth.instance; 15 | final FirebaseStorage _storage = FirebaseStorage.instance; 16 | bool _hasMoreData = true; 17 | DocumentSnapshot? _lastDocument; 18 | int _documentLimit = 5; 19 | var isLoading = false.obs; 20 | 21 | Future createUserCredential(String name, String email) async { 22 | try { 23 | await _firebaseFirestore 24 | .collection('users') 25 | .doc(_auth.currentUser!.uid) 26 | .set({ 27 | "uid": _auth.currentUser!.uid, 28 | "name": name, 29 | "email": email 30 | }).then((value) { 31 | Indicator.closeLoading(); 32 | Get.toNamed(Routes.HOME); 33 | }); 34 | } catch (e) { 35 | showAlert(e.toString()); 36 | } 37 | } 38 | 39 | Future uploadBlog(String title, String description, File image) async { 40 | try { 41 | String id = generateId(); 42 | DateTime time = DateTime.now(); 43 | 44 | String imageUrl = await uploadImage(image); 45 | 46 | Map blogDetails = { 47 | 'id': id, 48 | 'title': title, 49 | 'description': description, 50 | 'img': imageUrl, 51 | 'time': time, 52 | }; 53 | 54 | await _firebaseFirestore 55 | .collection('blogs') 56 | .doc(id) 57 | .set(blogDetails) 58 | .then((value) { 59 | saveDataToMyBlogs(id); 60 | }); 61 | } catch (e) { 62 | showAlert("$e"); 63 | } 64 | } 65 | 66 | Future uploadImage(File file) async { 67 | try { 68 | String imageName = generateId(); 69 | 70 | var refrence = _storage.ref().child("/images").child("/$imageName.jpg"); 71 | 72 | var uploadTask = await refrence.putFile(file); 73 | 74 | String url = await uploadTask.ref.getDownloadURL(); 75 | 76 | return url; 77 | } catch (e) { 78 | showAlert("$e"); 79 | return ""; 80 | } 81 | } 82 | 83 | Future> getBlogs() async { 84 | if (_hasMoreData) { 85 | if (!isLoading.value) { 86 | try { 87 | if (_lastDocument == null) { 88 | return await _firebaseFirestore 89 | .collection('blogs') 90 | .orderBy('time') 91 | .limit(_documentLimit) 92 | .get() 93 | .then((value) { 94 | _lastDocument = value.docs.last; 95 | 96 | if (value.docs.length < _documentLimit) { 97 | _hasMoreData = false; 98 | } 99 | 100 | Indicator.closeLoading(); 101 | 102 | return value.docs 103 | .map((e) => BlogsModel.fromJson(e.data())) 104 | .toList(); 105 | }); 106 | } else { 107 | isLoading.value = true; 108 | 109 | return await _firebaseFirestore 110 | .collection("blogs") 111 | .orderBy('time') 112 | .startAfterDocument(_lastDocument!) 113 | .limit(_documentLimit) 114 | .get() 115 | .then((value) { 116 | _lastDocument = value.docs.last; 117 | 118 | if (value.docs.length < _documentLimit) { 119 | _hasMoreData = false; 120 | } 121 | 122 | isLoading.value = false; 123 | 124 | return value.docs 125 | .map((e) => BlogsModel.fromJson(e.data())) 126 | .toList(); 127 | }); 128 | } 129 | } catch (e) { 130 | showAlert("$e"); 131 | print(e.toString()); 132 | return []; 133 | } 134 | } else { 135 | return []; 136 | } 137 | } else { 138 | print("No More Data"); 139 | return []; 140 | } 141 | } 142 | 143 | Future saveDataToMyBlogs(String id) async { 144 | try { 145 | await _firebaseFirestore 146 | .collection('users') 147 | .doc(_auth.currentUser!.uid) 148 | .collection('myblos') 149 | .doc(id) 150 | .set({ 151 | 'id': id, 152 | }); 153 | } catch (e) { 154 | showAlert("$e"); 155 | } 156 | } 157 | 158 | Future getMyBlogs() async { 159 | try { 160 | var snapshot = await _firebaseFirestore 161 | .collection('users') 162 | .doc(_auth.currentUser!.uid) 163 | .collection("myblos") 164 | .get(); 165 | 166 | return snapshot.docs.map((e) => e.data()['id']).toList(); 167 | } catch (e) { 168 | showAlert("$e"); 169 | return []; 170 | } 171 | } 172 | 173 | Future getBlogsById(String id) async { 174 | try { 175 | var documentSnapshot = 176 | await _firebaseFirestore.collection('blogs').doc(id).get(); 177 | 178 | return BlogsModel.fromJson(documentSnapshot.data()!); 179 | } catch (e) { 180 | showAlert("$e"); 181 | return BlogsModel(description: "", title: "", id: "", image: ""); 182 | } 183 | } 184 | 185 | Future deleteBlog(String id) async { 186 | await Future.wait([ 187 | deleteMyBlog(id), 188 | deletePublicBlog(id), 189 | ]); 190 | } 191 | 192 | Future deletePublicBlog(String id) async { 193 | try { 194 | await _firebaseFirestore.collection('blogs').doc(id).delete(); 195 | } catch (e) { 196 | showAlert("$e"); 197 | } 198 | } 199 | 200 | Future deleteMyBlog(String id) async { 201 | try { 202 | await _firebaseFirestore 203 | .collection('users') 204 | .doc(_auth.currentUser!.uid) 205 | .collection('myblos') 206 | .doc(id) 207 | .delete(); 208 | } catch (e) { 209 | showAlert("$e"); 210 | } 211 | } 212 | 213 | Future editBlog(String id, Map map) async { 214 | try { 215 | await _firebaseFirestore.collection('blogs').doc(id).update(map); 216 | } catch (e) { 217 | showAlert("$e"); 218 | } 219 | } 220 | 221 | Future addToFavourite(String id) async { 222 | try { 223 | await _firebaseFirestore 224 | .collection("users") 225 | .doc(_auth.currentUser!.uid) 226 | .collection('favourite') 227 | .doc(id) 228 | .set({ 229 | 'id': id, 230 | }); 231 | } catch (e) { 232 | showAlert("$e"); 233 | } 234 | } 235 | 236 | Future getFavouriteList() async { 237 | try { 238 | var querySnapshot = await _firebaseFirestore 239 | .collection('users') 240 | .doc(_auth.currentUser!.uid) 241 | .collection('favourite') 242 | .get(); 243 | 244 | return querySnapshot.docs.map((e) => e.data()['id']).toList(); 245 | } catch (e) { 246 | showAlert("$e"); 247 | return []; 248 | } 249 | } 250 | 251 | Future deleteFromFavorite(String id) async { 252 | try { 253 | await _firebaseFirestore 254 | .collection('users') 255 | .doc(_auth.currentUser!.uid) 256 | .collection('favourite') 257 | .doc(id) 258 | .delete(); 259 | } catch (e) { 260 | showAlert("$e"); 261 | } 262 | } 263 | } 264 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/app_bar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class CustomAppBar extends StatelessWidget { 5 | final String title; 6 | final IconButton? button; 7 | const CustomAppBar({this.button, required this.title, Key? key}) 8 | : super(key: key); 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Container( 13 | padding: EdgeInsets.symmetric(horizontal: 15.sp, vertical: 10.sp), 14 | child: Row( 15 | mainAxisAlignment: button == null 16 | ? MainAxisAlignment.start 17 | : MainAxisAlignment.spaceBetween, 18 | children: [ 19 | const BackButton(), 20 | SizedBox( 21 | width: button == null ? 60.w : 0, 22 | ), 23 | button == null 24 | ? Text( 25 | title, 26 | style: TextStyle( 27 | fontSize: 23.sp, 28 | fontWeight: FontWeight.w500, 29 | ), 30 | ) 31 | : button!, 32 | ], 33 | ), 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/custom_button.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class CustomButton extends StatelessWidget { 5 | final String title; 6 | final Function function; 7 | 8 | const CustomButton({required this.function, required this.title, Key? key}) 9 | : super(key: key); 10 | 11 | @override 12 | Widget build(BuildContext context) { 13 | return GestureDetector( 14 | onTap: () => function(), 15 | child: Container( 16 | padding: EdgeInsets.symmetric(horizontal: 24.sp, vertical: 8.sp), 17 | decoration: BoxDecoration( 18 | color: Colors.black, 19 | borderRadius: BorderRadius.circular(5), 20 | ), 21 | child: Text( 22 | title, 23 | style: TextStyle( 24 | fontSize: 18.sp, 25 | color: Colors.white, 26 | fontWeight: FontWeight.w500, 27 | ), 28 | ), 29 | ), 30 | ); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/indicator.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:get/get.dart'; 3 | 4 | class Indicator { 5 | static void showLoading() { 6 | Get.dialog( 7 | const Center( 8 | child: CircularProgressIndicator(), 9 | ), 10 | ); 11 | } 12 | 13 | static void closeLoading() { 14 | if (Get.isDialogOpen!) { 15 | Get.back(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/post.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/models/blog_model.dart'; 2 | import 'package:blog_app/app/routes/app_pages.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | class Post extends StatelessWidget { 8 | final BlogsModel model; 9 | final bool isPopUpMenuEnabled; 10 | final Function? edit, delete; 11 | 12 | const Post( 13 | {required this.isPopUpMenuEnabled, 14 | required this.model, 15 | this.edit, 16 | this.delete, 17 | Key? key}) 18 | : super(key: key); 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return GestureDetector( 23 | onTap: () { 24 | Get.toNamed(Routes.BLOG_DETAIL_SCREEN, arguments: model); 25 | }, 26 | child: Material( 27 | elevation: 4, 28 | borderRadius: BorderRadius.circular(10), 29 | child: SizedBox( 30 | height: 220.h, 31 | width: 100.w, 32 | child: Column( 33 | children: [ 34 | //Image. 35 | Container( 36 | height: 155.h, 37 | width: 330.w, 38 | decoration: BoxDecoration( 39 | borderRadius: const BorderRadius.only( 40 | topLeft: Radius.circular(5), 41 | topRight: Radius.circular(5), 42 | ), 43 | image: DecorationImage( 44 | image: NetworkImage(model.image), 45 | fit: BoxFit.cover, 46 | ), 47 | ), 48 | alignment: Alignment.topRight, 49 | child: isPopUpMenuEnabled 50 | ? Padding( 51 | padding: EdgeInsets.all(10.sp), 52 | child: PopupMenuButton( 53 | onSelected: (value) { 54 | if (value == 0) { 55 | edit!(); 56 | } else if (value == 1) { 57 | delete!(); 58 | } 59 | }, 60 | child: const Icon( 61 | Icons.more_vert, 62 | color: Colors.white, 63 | ), 64 | itemBuilder: (context) => [ 65 | const PopupMenuItem( 66 | child: Text("Edit"), 67 | value: 0, 68 | ), 69 | const PopupMenuItem( 70 | child: Text("Delete"), 71 | value: 1, 72 | ), 73 | ], 74 | ), 75 | ) 76 | : const SizedBox(), 77 | ), 78 | 79 | SizedBox( 80 | height: 5.h, 81 | ), 82 | 83 | Text( 84 | model.title, 85 | overflow: TextOverflow.ellipsis, 86 | maxLines: 2, 87 | style: TextStyle( 88 | fontSize: 17.sp, 89 | fontWeight: FontWeight.w500, 90 | ), 91 | ) 92 | ], 93 | ), 94 | ), 95 | ), 96 | ); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/text_field.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class ReusableTextField extends StatelessWidget { 5 | final TextEditingController controller; 6 | final String hintText; 7 | final bool isMultiline; 8 | 9 | const ReusableTextField( 10 | {required this.hintText, 11 | required this.controller, 12 | required this.isMultiline, 13 | Key? key}) 14 | : super(key: key); 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return Container( 19 | height: isMultiline ? 200.h : 55.h, 20 | width: double.infinity, 21 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 22 | child: TextField( 23 | controller: controller, 24 | maxLines: isMultiline ? null : 1, 25 | keyboardType: isMultiline ? TextInputType.multiline : null, 26 | decoration: InputDecoration( 27 | hintText: hintText, 28 | border: OutlineInputBorder( 29 | borderRadius: BorderRadius.circular(5), 30 | ), 31 | ), 32 | ), 33 | ); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/tiles.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class Tile extends StatelessWidget { 5 | final IconData icon; 6 | final String title; 7 | final Function function; 8 | const Tile( 9 | {required this.function, 10 | required this.title, 11 | required this.icon, 12 | Key? key}) 13 | : super(key: key); 14 | 15 | @override 16 | Widget build(BuildContext context) { 17 | return Padding( 18 | padding: EdgeInsets.symmetric(vertical: 10.sp), 19 | child: GestureDetector( 20 | onTap: () => function(), 21 | child: Material( 22 | elevation: 4, 23 | borderRadius: BorderRadius.circular(5), 24 | child: SizedBox( 25 | height: 60.h, 26 | width: 330.w, 27 | child: Row( 28 | children: [ 29 | SizedBox( 30 | width: 25.w, 31 | ), 32 | Icon( 33 | icon, 34 | size: 25.sp, 35 | ), 36 | SizedBox( 37 | width: 30.w, 38 | ), 39 | Text( 40 | title, 41 | style: TextStyle( 42 | fontSize: 20.sp, 43 | fontWeight: FontWeight.w500, 44 | ), 45 | ), 46 | ], 47 | ), 48 | ), 49 | ), 50 | ), 51 | ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/app/data/global_widgets/title_logo.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | class TitleLogo extends StatelessWidget { 5 | const TitleLogo({Key? key}) : super(key: key); 6 | 7 | @override 8 | Widget build(BuildContext context) { 9 | return Container( 10 | width: double.infinity, 11 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 12 | child: Center( 13 | child: Row( 14 | mainAxisAlignment: MainAxisAlignment.center, 15 | children: [ 16 | Text( 17 | "B", 18 | style: TextStyle( 19 | fontSize: 40.sp, 20 | color: Colors.blue, 21 | fontWeight: FontWeight.w500, 22 | ), 23 | ), 24 | Text( 25 | "l", 26 | style: TextStyle( 27 | fontSize: 40.sp, 28 | color: Colors.lime, 29 | fontWeight: FontWeight.w500, 30 | ), 31 | ), 32 | Text( 33 | "o", 34 | style: TextStyle( 35 | fontSize: 40.sp, 36 | color: Colors.orange, 37 | fontWeight: FontWeight.w500, 38 | ), 39 | ), 40 | Text( 41 | "g", 42 | style: TextStyle( 43 | fontSize: 40.sp, 44 | color: Colors.green, 45 | fontWeight: FontWeight.w500, 46 | ), 47 | ), 48 | Text( 49 | "-", 50 | style: TextStyle( 51 | fontSize: 40.sp, 52 | color: Colors.white30, 53 | fontWeight: FontWeight.w500, 54 | ), 55 | ), 56 | Text( 57 | " A", 58 | style: TextStyle( 59 | fontSize: 40.sp, 60 | color: Colors.black, 61 | fontWeight: FontWeight.w400, 62 | ), 63 | ), 64 | Text( 65 | "p", 66 | style: TextStyle( 67 | fontSize: 40.sp, 68 | color: Colors.black, 69 | fontWeight: FontWeight.w400, 70 | ), 71 | ), 72 | Text( 73 | "p", 74 | style: TextStyle( 75 | fontSize: 40.sp, 76 | color: Colors.black, 77 | fontWeight: FontWeight.w400, 78 | ), 79 | ), 80 | ], 81 | ), 82 | ), 83 | ); 84 | ; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /lib/app/models/blog_model.dart: -------------------------------------------------------------------------------- 1 | class BlogsModel { 2 | late String id, title, description, image; 3 | 4 | BlogsModel( 5 | {required this.description, 6 | required this.title, 7 | required this.id, 8 | required this.image}); 9 | 10 | BlogsModel.fromJson(Map map) { 11 | id = map['id']; 12 | title = map['title']; 13 | description = map['description']; 14 | image = map['img']; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/app/modules/authentication/bindings/authentication_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/authentication_controller.dart'; 4 | 5 | class AuthenticationBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.put( 9 | AuthenticationController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/authentication/controllers/authentication_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/routes/app_pages.dart'; 2 | import 'package:firebase_auth/firebase_auth.dart'; 3 | import 'package:get/get.dart'; 4 | 5 | class AuthenticationController extends GetxController { 6 | final FirebaseAuth _auth = FirebaseAuth.instance; 7 | 8 | void isLoggedIn() { 9 | if (_auth.currentUser != null) { 10 | Get.toNamed(Routes.HOME); 11 | } else { 12 | Get.toNamed(Routes.LOGIN); 13 | } 14 | } 15 | 16 | @override 17 | void onReady() { 18 | 19 | super.onReady(); 20 | isLoggedIn(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/app/modules/authentication/views/authentication_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'package:get/get.dart'; 4 | 5 | import '../controllers/authentication_controller.dart'; 6 | 7 | class AuthenticationView extends GetView { 8 | 9 | @override 10 | Widget build(BuildContext context) { 11 | return Scaffold(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /lib/app/modules/blog_detail_screen/bindings/blog_detail_screen_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/blog_detail_screen_controller.dart'; 4 | 5 | class BlogDetailScreenBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => BlogDetailScreenController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/blog_detail_screen/controllers/blog_detail_screen_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 2 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 3 | import 'package:blog_app/app/modules/favourite/controllers/favourite_controller.dart'; 4 | import 'package:blog_app/app/modules/home/controllers/home_controller.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | class BlogDetailScreenController extends GetxController { 8 | final controller = Get.find(); 9 | final FirebaseFunctions _firebaseFunctions = FirebaseFunctions(); 10 | var isAdded = false.obs; 11 | 12 | void addToFavourite(String id) async { 13 | Indicator.showLoading(); 14 | 15 | await _firebaseFunctions.addToFavourite(id).then((value) async { 16 | await controller.getFavouriteList(); 17 | 18 | if (Get.isRegistered()) { 19 | Get.find().getFavouriteList(); 20 | } 21 | 22 | Indicator.closeLoading(); 23 | checkIfAlreadyFavourite(id); 24 | }); 25 | } 26 | 27 | void deleteFromFavourite(String id) async { 28 | Indicator.showLoading(); 29 | 30 | await _firebaseFunctions.deleteFromFavorite(id).then((value) async { 31 | await controller.getFavouriteList(); 32 | 33 | if (Get.isRegistered()) { 34 | Get.find().getFavouriteList(); 35 | } 36 | 37 | Indicator.closeLoading(); 38 | isAdded.value = false; 39 | checkIfAlreadyFavourite(id); 40 | }); 41 | } 42 | 43 | void checkIfAlreadyFavourite(String id) { 44 | for (var i = 0; i < controller.favouriteList.length; i++) { 45 | if (controller.favouriteList[i] == id) { 46 | isAdded.value = true; 47 | 48 | break; 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /lib/app/modules/blog_detail_screen/views/blog_detail_screen_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/app_bar.dart'; 2 | import 'package:blog_app/app/models/blog_model.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | 6 | import 'package:get/get.dart'; 7 | 8 | import '../controllers/blog_detail_screen_controller.dart'; 9 | 10 | class BlogDetailScreenView extends GetView { 11 | final BlogsModel model = Get.arguments; 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | controller.checkIfAlreadyFavourite(model.id); 16 | 17 | return SafeArea( 18 | child: Scaffold( 19 | body: SingleChildScrollView( 20 | child: Column( 21 | mainAxisSize: MainAxisSize.max, 22 | children: [ 23 | Obx(() { 24 | return CustomAppBar( 25 | title: "", 26 | button: IconButton( 27 | onPressed: () { 28 | if (controller.isAdded.value) { 29 | controller.deleteFromFavourite(model.id); 30 | } else { 31 | controller.addToFavourite(model.id); 32 | } 33 | }, 34 | icon: controller.isAdded.value 35 | ? const Icon( 36 | Icons.favorite, 37 | color: Colors.pinkAccent, 38 | ) 39 | : const Icon(Icons.favorite_outline_outlined), 40 | ), 41 | ); 42 | }), 43 | SizedBox( 44 | height: 10.h, 45 | ), 46 | Container( 47 | padding: EdgeInsets.symmetric(horizontal: 25.sp), 48 | alignment: Alignment.centerLeft, 49 | child: Text( 50 | model.title, 51 | style: TextStyle( 52 | fontSize: 25.sp, 53 | fontWeight: FontWeight.w500, 54 | ), 55 | ), 56 | ), 57 | SizedBox( 58 | height: 10.h, 59 | ), 60 | Container( 61 | height: 200.h, 62 | width: 300.w, 63 | decoration: BoxDecoration( 64 | borderRadius: BorderRadius.circular(5), 65 | image: DecorationImage( 66 | image: NetworkImage(model.image), 67 | fit: BoxFit.cover, 68 | ), 69 | ), 70 | ), 71 | SizedBox( 72 | height: 12.h, 73 | ), 74 | Container( 75 | padding: EdgeInsets.symmetric(horizontal: 25.sp), 76 | alignment: Alignment.centerLeft, 77 | child: Text( 78 | model.description, 79 | style: TextStyle( 80 | fontSize: 16.sp, 81 | fontWeight: FontWeight.w500, 82 | ), 83 | ), 84 | ), 85 | ], 86 | ), 87 | ), 88 | ), 89 | ); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /lib/app/modules/favourite/bindings/favourite_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/favourite_controller.dart'; 4 | 5 | class FavouriteBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => FavouriteController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/favourite/controllers/favourite_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 2 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 3 | import 'package:blog_app/app/models/blog_model.dart'; 4 | import 'package:blog_app/app/modules/home/controllers/home_controller.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | class FavouriteController extends GetxController { 8 | final FirebaseFunctions _functions = FirebaseFunctions(); 9 | final controller = Get.find(); 10 | List models = []; 11 | 12 | void getFavouriteList() async { 13 | models = []; 14 | for (var i = 0; i < controller.favouriteList.length; i++) { 15 | models.add(await _functions.getBlogsById(controller.favouriteList[i])); 16 | } 17 | 18 | Indicator.closeLoading(); 19 | update(); 20 | } 21 | 22 | @override 23 | void onReady() { 24 | super.onReady(); 25 | Indicator.showLoading(); 26 | } 27 | 28 | @override 29 | void onInit() { 30 | super.onInit(); 31 | getFavouriteList(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /lib/app/modules/favourite/views/favourite_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/app_bar.dart'; 2 | import 'package:blog_app/app/data/global_widgets/post.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | 6 | import 'package:get/get.dart'; 7 | 8 | import '../controllers/favourite_controller.dart'; 9 | 10 | class FavouriteView extends GetView { 11 | @override 12 | Widget build(BuildContext context) { 13 | return SafeArea( 14 | child: Scaffold( 15 | body: Column( 16 | mainAxisSize: MainAxisSize.max, 17 | children: [ 18 | const CustomAppBar(title: "Favourite"), 19 | Expanded( 20 | child: GetBuilder(builder: (value) { 21 | if (value.models.isNotEmpty) { 22 | return ListView.builder( 23 | itemCount: value.models.length, 24 | itemBuilder: (context, index) { 25 | return Padding( 26 | padding: EdgeInsets.symmetric( 27 | horizontal: 15.sp, vertical: 5.sp), 28 | child: Post( 29 | isPopUpMenuEnabled: false, 30 | model: value.models[index], 31 | ), 32 | ); 33 | }, 34 | ); 35 | } else { 36 | return const Center( 37 | child: Text("No Favourites available"), 38 | ); 39 | } 40 | }), 41 | ), 42 | ], 43 | ), 44 | ), 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/app/modules/home/bindings/home_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/home_controller.dart'; 4 | 5 | class HomeBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => HomeController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/home/controllers/home_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 2 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 3 | import 'package:blog_app/app/models/blog_model.dart'; 4 | import 'package:flutter/cupertino.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | class HomeController extends GetxController { 8 | final FirebaseFunctions _functions = FirebaseFunctions(); 9 | final ScrollController controller = ScrollController(); 10 | List blogs = []; 11 | List favouriteList = []; 12 | var isLoading = false.obs; 13 | 14 | void getData() async { 15 | blogs.addAll(await _functions.getBlogs()); 16 | 17 | update(); 18 | } 19 | 20 | @override 21 | void onReady() { 22 | // ignore: todo 23 | // TODO: implement onReady 24 | super.onReady(); 25 | Indicator.showLoading(); 26 | } 27 | 28 | Future getFavouriteList() async { 29 | favouriteList = await _functions.getFavouriteList(); 30 | } 31 | 32 | @override 33 | void onInit() { 34 | super.onInit(); 35 | getData(); 36 | getFavouriteList(); 37 | _functions.isLoading.listen((p) { 38 | isLoading.value = p; 39 | }); 40 | controller.addListener(() { 41 | double maxScrollPoint = controller.position.maxScrollExtent; 42 | double currentPosition = controller.position.pixels; 43 | double height20 = Get.size.height * 0.20; 44 | 45 | if (maxScrollPoint - currentPosition <= height20) { 46 | getData(); 47 | } 48 | }); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/app/modules/home/views/home_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/post.dart'; 2 | import 'package:blog_app/app/routes/app_pages.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | 6 | import 'package:get/get.dart'; 7 | 8 | import '../controllers/home_controller.dart'; 9 | 10 | class HomeView extends GetView { 11 | 12 | Future _refresh() async { 13 | controller.getData(); 14 | } 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | return SafeArea( 19 | child: Scaffold( 20 | body: Column( 21 | mainAxisSize: MainAxisSize.max, 22 | children: [ 23 | SizedBox( 24 | height: 20.h, 25 | ), 26 | Container( 27 | width: double.infinity, 28 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 29 | child: Row( 30 | mainAxisAlignment: MainAxisAlignment.spaceBetween, 31 | children: [ 32 | Row( 33 | mainAxisAlignment: MainAxisAlignment.center, 34 | children: [ 35 | Text( 36 | "B", 37 | style: TextStyle( 38 | fontSize: 20.sp, 39 | color: Colors.blue, 40 | fontWeight: FontWeight.w500, 41 | ), 42 | ), 43 | Text( 44 | "l", 45 | style: TextStyle( 46 | fontSize: 20.sp, 47 | color: Colors.lime, 48 | fontWeight: FontWeight.w500, 49 | ), 50 | ), 51 | Text( 52 | "o", 53 | style: TextStyle( 54 | fontSize: 20.sp, 55 | color: Colors.orange, 56 | fontWeight: FontWeight.w500, 57 | ), 58 | ), 59 | Text( 60 | "g", 61 | style: TextStyle( 62 | fontSize: 20.sp, 63 | color: Colors.green, 64 | fontWeight: FontWeight.w500, 65 | ), 66 | ), 67 | Text( 68 | " A", 69 | style: TextStyle( 70 | fontSize: 20.sp, 71 | color: Colors.black, 72 | fontWeight: FontWeight.w400, 73 | ), 74 | ), 75 | Text( 76 | "p", 77 | style: TextStyle( 78 | fontSize: 20.sp, 79 | color: Colors.black, 80 | fontWeight: FontWeight.w400, 81 | ), 82 | ), 83 | Text( 84 | "p", 85 | style: TextStyle( 86 | fontSize: 20.sp, 87 | color: Colors.black, 88 | fontWeight: FontWeight.w400, 89 | ), 90 | ), 91 | ], 92 | ), 93 | IconButton( 94 | onPressed: () { 95 | Get.toNamed(Routes.PROFILE); 96 | }, 97 | icon: Icon( 98 | Icons.account_box, 99 | size: 25.h, 100 | ), 101 | ), 102 | ], 103 | ), 104 | ), 105 | SizedBox( 106 | height: 20.h, 107 | ), 108 | Expanded( 109 | child: GetBuilder( 110 | builder: (value) { 111 | if (value.blogs.isNotEmpty) { 112 | return RefreshIndicator( 113 | onRefresh: _refresh, 114 | child: ListView.builder( 115 | controller: controller.controller, 116 | itemCount: value.blogs.length, 117 | itemBuilder: (context, index) { 118 | return Padding( 119 | padding: EdgeInsets.symmetric( 120 | horizontal: 10.sp, vertical: 5.sp), 121 | child: Post( 122 | isPopUpMenuEnabled: false, 123 | model: value.blogs[index], 124 | ), 125 | ); 126 | }, 127 | ), 128 | ); 129 | } else { 130 | return const Center( 131 | child: Text("No Blogs Available."), 132 | ); 133 | } 134 | }, 135 | ), 136 | ), 137 | Obx(() { 138 | if (controller.isLoading.value) { 139 | return SizedBox( 140 | height: 60.h, 141 | child: const CircularProgressIndicator.adaptive(), 142 | ); 143 | } else { 144 | return const SizedBox(); 145 | } 146 | }), 147 | ], 148 | ), 149 | floatingActionButton: FloatingActionButton.extended( 150 | backgroundColor: Colors.black, 151 | onPressed: () { 152 | Get.toNamed(Routes.UPLOAD_BLOG); 153 | }, 154 | label: Row( 155 | children: [ 156 | Icon( 157 | Icons.post_add, 158 | size: 24.sp, 159 | ), 160 | SizedBox( 161 | width: 5.w, 162 | ), 163 | Text( 164 | "Create Blog", 165 | style: TextStyle( 166 | fontSize: 15.sp, 167 | ), 168 | ) 169 | ], 170 | )), 171 | ), 172 | ); 173 | } 174 | } 175 | -------------------------------------------------------------------------------- /lib/app/modules/login/bindings/login_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/login_controller.dart'; 4 | 5 | class LoginBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => LoginController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/login/controllers/login_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/const.dart'; 2 | import 'package:blog_app/app/data/firebase/firebase_auth.dart'; 3 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 4 | import 'package:blog_app/app/routes/app_pages.dart'; 5 | import 'package:firebase_auth/firebase_auth.dart'; 6 | import 'package:flutter/cupertino.dart'; 7 | import 'package:get/get.dart'; 8 | 9 | class LoginController extends GetxController { 10 | final FirebaseAuthentication _authentication = FirebaseAuthentication(); 11 | 12 | final TextEditingController email = TextEditingController(); 13 | final TextEditingController password = TextEditingController(); 14 | 15 | void onLogin() async { 16 | if (email.text.isNotEmpty && password.text.isNotEmpty) { 17 | Indicator.showLoading(); 18 | await _authentication.login(email.text, password.text).then((value) { 19 | Indicator.closeLoading(); 20 | Get.toNamed(Routes.HOME); 21 | }); 22 | // await FirebaseAuth.instance 23 | // .signInWithEmailAndPassword( 24 | // email: email.text, 25 | // password: password.text, 26 | // ) 27 | // .then((UserCredential userCredential) { 28 | // Indicator.closeLoading(); 29 | // Get.toNamed(Routes.HOME); 30 | // }); 31 | } else { 32 | showAlert("All fields are required"); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /lib/app/modules/login/views/login_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/custom_button.dart'; 2 | import 'package:blog_app/app/data/global_widgets/title_logo.dart'; 3 | import 'package:blog_app/app/routes/app_pages.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | import 'package:get/get.dart'; 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 8 | 9 | import '../controllers/login_controller.dart'; 10 | 11 | class LoginView extends GetView { 12 | 13 | @override 14 | Widget build(BuildContext context) { 15 | return Scaffold( 16 | body: SingleChildScrollView( 17 | child: Column( 18 | mainAxisSize: MainAxisSize.max, 19 | children: [ 20 | SizedBox( 21 | height: 80.h, 22 | ), 23 | const TitleLogo(), 24 | SizedBox( 25 | height: 60.h, 26 | ), 27 | Container( 28 | width: double.infinity, 29 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 30 | child: Text( 31 | "Login", 32 | style: TextStyle( 33 | fontSize: 25.sp, 34 | color: Colors.black, 35 | fontWeight: FontWeight.w500, 36 | ), 37 | ), 38 | ), 39 | Padding( 40 | padding: const EdgeInsets.all(20.0), 41 | child: TextField( 42 | controller: controller.email, 43 | decoration: InputDecoration( 44 | labelText: 'Email', 45 | enabledBorder: OutlineInputBorder( 46 | borderSide: 47 | const BorderSide(width: 1.0, color: Colors.blue), 48 | borderRadius: BorderRadius.circular(5), 49 | ), 50 | focusedBorder: OutlineInputBorder( 51 | borderSide: 52 | const BorderSide(width: 1.0, color: Colors.blue), 53 | borderRadius: BorderRadius.circular(5), 54 | )), 55 | ), 56 | ), 57 | Padding( 58 | padding: const EdgeInsets.all(20.0), 59 | child: TextField( 60 | controller: controller.password, 61 | obscureText: true, 62 | decoration: InputDecoration( 63 | labelText: 'Password', 64 | enabledBorder: OutlineInputBorder( 65 | borderSide: 66 | const BorderSide(width: 1.0, color: Colors.blue), 67 | borderRadius: BorderRadius.circular(5), 68 | ), 69 | focusedBorder: OutlineInputBorder( 70 | borderSide: 71 | const BorderSide(width: 1.0, color: Colors.red), 72 | borderRadius: BorderRadius.circular(5), 73 | )), 74 | ), 75 | ), 76 | SizedBox( 77 | height: 20.h, 78 | ), 79 | CustomButton( 80 | function: () { 81 | controller.onLogin(); 82 | }, 83 | title: "Login", 84 | ), 85 | ], 86 | ), 87 | ), 88 | bottomNavigationBar: Container( 89 | height: 50.h, 90 | alignment: Alignment.center, 91 | child: GestureDetector( 92 | onTap: () { 93 | Get.toNamed(Routes.SIGN_UP); 94 | }, 95 | child: Text( 96 | "Don't have an account.? Register", 97 | style: TextStyle( 98 | fontSize: 15.sp, 99 | fontWeight: FontWeight.w500, 100 | ), 101 | ), 102 | ), 103 | ), 104 | ); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/app/modules/my_blogs/bindings/my_blogs_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/my_blogs_controller.dart'; 4 | 5 | class MyBlogsBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => MyBlogsController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/my_blogs/controllers/my_blogs_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 2 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 3 | import 'package:blog_app/app/models/blog_model.dart'; 4 | import 'package:blog_app/app/routes/app_pages.dart'; 5 | import 'package:get/get.dart'; 6 | 7 | class MyBlogsController extends GetxController { 8 | final FirebaseFunctions _functions = FirebaseFunctions(); 9 | List blogsId = []; 10 | List myBlogs = []; 11 | 12 | void getMyBlogData() async { 13 | blogsId = await _functions.getMyBlogs(); 14 | 15 | if (blogsId.isNotEmpty) { 16 | for (var i = 0; i < blogsId.length; i++) { 17 | BlogsModel model = await _functions.getBlogsById(blogsId[i]); 18 | 19 | myBlogs.add(model); 20 | } 21 | } 22 | 23 | update(); 24 | 25 | Indicator.closeLoading(); 26 | } 27 | 28 | void deleteBlog(String id) async { 29 | Indicator.showLoading(); 30 | 31 | await _functions.deleteBlog(id).then((value) { 32 | myBlogs = []; 33 | getMyBlogData(); 34 | }); 35 | } 36 | 37 | void editBlog(BlogsModel model) { 38 | Get.toNamed(Routes.UPLOAD_BLOG, arguments: model); 39 | } 40 | 41 | @override 42 | void onReady() { 43 | // TODO: implement onReady 44 | super.onReady(); 45 | Indicator.showLoading(); 46 | } 47 | 48 | @override 49 | void onInit() { 50 | // TODO: implement onInit 51 | super.onInit(); 52 | getMyBlogData(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/app/modules/my_blogs/views/my_blogs_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/app_bar.dart'; 2 | import 'package:blog_app/app/data/global_widgets/post.dart'; 3 | import 'package:flutter/material.dart'; 4 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 5 | 6 | import 'package:get/get.dart'; 7 | 8 | import '../controllers/my_blogs_controller.dart'; 9 | 10 | class MyBlogsView extends GetView { 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return SafeArea( 15 | child: Scaffold( 16 | body: Column( 17 | mainAxisSize: MainAxisSize.max, 18 | children: [ 19 | const CustomAppBar(title: "My Blogs"), 20 | SizedBox( 21 | height: 20.h, 22 | ), 23 | Expanded( 24 | child: GetBuilder( 25 | builder: (value) { 26 | if (value.myBlogs.isNotEmpty) { 27 | return ListView.builder( 28 | itemCount: value.myBlogs.length, 29 | itemBuilder: (context, index) { 30 | return Padding( 31 | padding: EdgeInsets.symmetric( 32 | horizontal: 15.sp, 33 | vertical: 5.sp, 34 | ), 35 | child: Post( 36 | edit: () { 37 | controller.editBlog(value.myBlogs[index]); 38 | }, 39 | delete: () { 40 | controller.deleteBlog(value.myBlogs[index].id); 41 | }, 42 | isPopUpMenuEnabled: true, 43 | model: value.myBlogs[index], 44 | ), 45 | ); 46 | }, 47 | ); 48 | } else { 49 | return const Center( 50 | child: Text("No Blogs Available"), 51 | ); 52 | } 53 | }, 54 | ), 55 | ), 56 | ], 57 | ), 58 | ), 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /lib/app/modules/profile/bindings/profile_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/profile_controller.dart'; 4 | 5 | class ProfileBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => ProfileController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/profile/controllers/profile_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class ProfileController extends GetxController { 4 | //TODO: Implement ProfileController 5 | 6 | final count = 0.obs; 7 | 8 | @override 9 | void onInit() { 10 | super.onInit(); 11 | } 12 | 13 | @override 14 | void onReady() { 15 | super.onReady(); 16 | } 17 | 18 | @override 19 | void onClose() {} 20 | void increment() => count.value++; 21 | } 22 | -------------------------------------------------------------------------------- /lib/app/modules/profile/views/profile_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/const.dart'; 2 | import 'package:blog_app/app/data/firebase/firebase_auth.dart'; 3 | import 'package:blog_app/app/data/global_widgets/tiles.dart'; 4 | import 'package:blog_app/app/data/global_widgets/title_logo.dart'; 5 | import 'package:blog_app/app/routes/app_pages.dart'; 6 | import 'package:flutter/material.dart'; 7 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 8 | 9 | import 'package:get/get.dart'; 10 | import 'package:url_launcher/url_launcher.dart'; 11 | 12 | import '../controllers/profile_controller.dart'; 13 | 14 | class ProfileView extends GetView { 15 | final FirebaseAuthentication _authentication = FirebaseAuthentication(); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | return SafeArea( 20 | child: Scaffold( 21 | body: SingleChildScrollView( 22 | child: Padding( 23 | padding: const EdgeInsets.all(20), 24 | child: Column( 25 | mainAxisSize: MainAxisSize.max, 26 | children: [ 27 | SizedBox( 28 | height: 40.h, 29 | ), 30 | const TitleLogo(), 31 | SizedBox( 32 | height: 20.h, 33 | ), 34 | Icon( 35 | Icons.account_box_rounded, 36 | size: 80.h, 37 | ), 38 | SizedBox( 39 | height: 20.h, 40 | ), 41 | SizedBox( 42 | height: 25.h, 43 | ), 44 | Tile( 45 | title: "My Blogs", 46 | icon: Icons.edit_note, 47 | function: () { 48 | Get.toNamed(Routes.MY_BLOGS); 49 | }, 50 | ), 51 | Tile( 52 | title: "Favourite", 53 | icon: Icons.favorite_border_sharp, 54 | function: () { 55 | Get.toNamed(Routes.FAVOURITE); 56 | }, 57 | ), 58 | Tile( 59 | title: "Log Out", 60 | icon: Icons.logout_sharp, 61 | function: () { 62 | _authentication.logOut(); 63 | }, 64 | ), 65 | SizedBox( 66 | height: 60.h, 67 | ), 68 | Center( 69 | child: GestureDetector( 70 | onDoubleTap: () async { 71 | try { 72 | final Uri _url = 73 | Uri.parse('https://linktr.ee/mdabdullahibnaharun'); 74 | if (false == (await launchUrl(_url))) { 75 | showAlert('Could not launch $_url'); 76 | } 77 | } catch (e) { 78 | print(e.toString()); 79 | } 80 | }, 81 | child: Center( 82 | child: Column( 83 | children: [ 84 | const Icon(Icons.engineering), 85 | Text( 86 | "Developer.", 87 | style: TextStyle( 88 | fontSize: 14.sp, 89 | fontWeight: FontWeight.w500, 90 | ), 91 | ), 92 | Text( 93 | "Md. Abdullah Ibna Harun", 94 | style: TextStyle( 95 | fontSize: 14.sp, 96 | fontWeight: FontWeight.w500, 97 | ), 98 | ), 99 | ], 100 | ), 101 | ), 102 | ), 103 | ), 104 | ], 105 | ), 106 | ), 107 | ), 108 | ), 109 | ); 110 | } 111 | } 112 | -------------------------------------------------------------------------------- /lib/app/modules/sign_up/bindings/sign_up_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/sign_up_controller.dart'; 4 | 5 | class SignUpBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => SignUpController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/sign_up/controllers/sign_up_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/const.dart'; 2 | import 'package:blog_app/app/data/firebase/firebase_auth.dart'; 3 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 4 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 5 | import 'package:flutter/cupertino.dart'; 6 | import 'package:get/get.dart'; 7 | 8 | class SignUpController extends GetxController { 9 | final FirebaseAuthentication _authentication = FirebaseAuthentication(); 10 | final FirebaseFunctions _functions = FirebaseFunctions(); 11 | final TextEditingController fullName = TextEditingController(); 12 | final TextEditingController email = TextEditingController(); 13 | final TextEditingController password = TextEditingController(); 14 | 15 | void onCreateAccount() async { 16 | if (fullName.text.isNotEmpty && 17 | email.text.isNotEmpty && 18 | password.text.isNotEmpty) { 19 | Indicator.showLoading(); 20 | 21 | await _authentication 22 | .createAccount(email.text, password.text) 23 | .then((value) { 24 | _functions.createUserCredential(fullName.text, email.text); 25 | }); 26 | } else { 27 | showAlert("All Feilds are required"); 28 | print("All fields are required"); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/app/modules/sign_up/views/sign_up_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/custom_button.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | import 'package:get/get.dart'; 5 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 6 | 7 | import '../../../data/global_widgets/title_logo.dart'; 8 | import '../controllers/sign_up_controller.dart'; 9 | 10 | class SignUpView extends GetView { 11 | @override 12 | Widget build(BuildContext context) { 13 | return Scaffold( 14 | body: SingleChildScrollView( 15 | child: Column( 16 | mainAxisSize: MainAxisSize.max, 17 | children: [ 18 | SizedBox( 19 | height: 80.h, 20 | ), 21 | const TitleLogo(), 22 | SizedBox( 23 | height: 60.h, 24 | ), 25 | Container( 26 | width: double.infinity, 27 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 28 | child: Text( 29 | "Sign Up", 30 | style: TextStyle( 31 | fontSize: 25.sp, 32 | color: Colors.black, 33 | fontWeight: FontWeight.w500, 34 | ), 35 | ), 36 | ), 37 | Padding( 38 | padding: const EdgeInsets.all(20.0), 39 | child: TextField( 40 | controller: controller.fullName, 41 | decoration: InputDecoration( 42 | labelText: 'Full Name', 43 | enabledBorder: OutlineInputBorder( 44 | borderSide: 45 | const BorderSide(width: 1.0, color: Colors.blue), 46 | borderRadius: BorderRadius.circular(5), 47 | ), 48 | focusedBorder: OutlineInputBorder( 49 | borderSide: 50 | const BorderSide(width: 1.0, color: Colors.blue), 51 | borderRadius: BorderRadius.circular(5), 52 | )), 53 | ), 54 | ), 55 | Padding( 56 | padding: const EdgeInsets.all(20.0), 57 | child: TextField( 58 | controller: controller.email, 59 | decoration: InputDecoration( 60 | labelText: 'Email', 61 | enabledBorder: OutlineInputBorder( 62 | borderSide: 63 | const BorderSide(width: 1.0, color: Colors.blue), 64 | borderRadius: BorderRadius.circular(5), 65 | ), 66 | focusedBorder: OutlineInputBorder( 67 | borderSide: 68 | const BorderSide(width: 1.0, color: Colors.blue), 69 | borderRadius: BorderRadius.circular(5), 70 | )), 71 | ), 72 | ), 73 | Padding( 74 | padding: const EdgeInsets.all(20.0), 75 | child: TextField( 76 | controller: controller.password, 77 | obscureText: true, 78 | decoration: InputDecoration( 79 | labelText: 'Password', 80 | enabledBorder: OutlineInputBorder( 81 | borderSide: 82 | const BorderSide(width: 1.0, color: Colors.blue), 83 | borderRadius: BorderRadius.circular(5), 84 | ), 85 | focusedBorder: OutlineInputBorder( 86 | borderSide: 87 | const BorderSide(width: 1.0, color: Colors.red), 88 | borderRadius: BorderRadius.circular(5), 89 | )), 90 | ), 91 | ), 92 | SizedBox( 93 | height: 20.h, 94 | ), 95 | CustomButton( 96 | function: () { 97 | controller.onCreateAccount(); 98 | }, 99 | title: "Create Account"), 100 | ], 101 | ), 102 | ), 103 | bottomNavigationBar: Container( 104 | height: 50.h, 105 | alignment: Alignment.center, 106 | child: GestureDetector( 107 | onTap: () { 108 | Get.back(); 109 | }, 110 | child: Text( 111 | "Already have an account.? Login", 112 | style: TextStyle( 113 | fontSize: 15.sp, 114 | fontWeight: FontWeight.w500, 115 | ), 116 | ), 117 | ), 118 | ), 119 | ); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /lib/app/modules/title/bindings/title_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/title_controller.dart'; 4 | 5 | class TitleBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => TitleController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/title/controllers/title_controller.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | class TitleController extends GetxController { 4 | // ignore: todo 5 | //TODO: Implement TitleController 6 | 7 | final count = 0.obs; 8 | @override 9 | void onInit() { 10 | super.onInit(); 11 | } 12 | 13 | @override 14 | void onReady() { 15 | super.onReady(); 16 | } 17 | 18 | @override 19 | void onClose() { 20 | super.onClose(); 21 | } 22 | 23 | void increment() => count.value++; 24 | } 25 | -------------------------------------------------------------------------------- /lib/app/modules/title/views/title_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 3 | 4 | import 'package:get/get.dart'; 5 | 6 | import '../controllers/title_controller.dart'; 7 | 8 | class TitleView extends GetView { 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Container( 13 | width: double.infinity, 14 | padding: EdgeInsets.symmetric(horizontal: 20.sp), 15 | child: Center( 16 | child: Row( 17 | mainAxisAlignment: MainAxisAlignment.center, 18 | children: [ 19 | Text( 20 | "B", 21 | style: TextStyle( 22 | fontSize: 40.sp, 23 | color: Colors.blue, 24 | fontWeight: FontWeight.w500, 25 | ), 26 | ), 27 | Text( 28 | "l", 29 | style: TextStyle( 30 | fontSize: 40.sp, 31 | color: Colors.lime, 32 | fontWeight: FontWeight.w500, 33 | ), 34 | ), 35 | Text( 36 | "o", 37 | style: TextStyle( 38 | fontSize: 40.sp, 39 | color: Colors.orange, 40 | fontWeight: FontWeight.w500, 41 | ), 42 | ), 43 | Text( 44 | "g", 45 | style: TextStyle( 46 | fontSize: 40.sp, 47 | color: Colors.green, 48 | fontWeight: FontWeight.w500, 49 | ), 50 | ), 51 | Text( 52 | "-", 53 | style: TextStyle( 54 | fontSize: 40.sp, 55 | color: Colors.white30, 56 | fontWeight: FontWeight.w500, 57 | ), 58 | ), 59 | Text( 60 | " A", 61 | style: TextStyle( 62 | fontSize: 40.sp, 63 | color: Colors.black, 64 | fontWeight: FontWeight.w400, 65 | ), 66 | ), 67 | Text( 68 | "p", 69 | style: TextStyle( 70 | fontSize: 40.sp, 71 | color: Colors.black, 72 | fontWeight: FontWeight.w400, 73 | ), 74 | ), 75 | Text( 76 | "p", 77 | style: TextStyle( 78 | fontSize: 40.sp, 79 | color: Colors.black, 80 | fontWeight: FontWeight.w400, 81 | ), 82 | ), 83 | ], 84 | ), 85 | ), 86 | ); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /lib/app/modules/upload_blog/bindings/upload_blog_binding.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../controllers/upload_blog_controller.dart'; 4 | 5 | class UploadBlogBinding extends Bindings { 6 | @override 7 | void dependencies() { 8 | Get.lazyPut( 9 | () => UploadBlogController(), 10 | ); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /lib/app/modules/upload_blog/controllers/upload_blog_controller.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:blog_app/app/data/const.dart'; 4 | import 'package:blog_app/app/data/firebase/firebase_functions.dart'; 5 | import 'package:blog_app/app/data/global_widgets/indicator.dart'; 6 | import 'package:blog_app/app/models/blog_model.dart'; 7 | import 'package:blog_app/app/modules/my_blogs/controllers/my_blogs_controller.dart'; 8 | import 'package:blog_app/app/routes/app_pages.dart'; 9 | import 'package:flutter/cupertino.dart'; 10 | import 'package:get/get.dart'; 11 | import 'package:image_picker/image_picker.dart'; 12 | 13 | class UploadBlogController extends GetxController { 14 | TextEditingController title = TextEditingController(); 15 | TextEditingController description = TextEditingController(); 16 | final FirebaseFunctions _functions = FirebaseFunctions(); 17 | File? imageFile; 18 | 19 | Future pickImage() async { 20 | try { 21 | ImagePicker _picker = ImagePicker(); 22 | 23 | await _picker.pickImage(source: ImageSource.gallery).then((value) { 24 | if (value != null) { 25 | imageFile = File(value.path); 26 | update(); 27 | } 28 | }); 29 | } catch (e) { 30 | showAlert("$e"); 31 | } 32 | } 33 | 34 | void createBlog() async { 35 | if (title.text.isNotEmpty && description.text.isNotEmpty) { 36 | if (imageFile != null) { 37 | Indicator.showLoading(); 38 | 39 | await _functions 40 | .uploadBlog(title.text, description.text, imageFile!) 41 | .then((value) { 42 | Indicator.closeLoading(); 43 | showAlert("Blog created sucessfully"); 44 | // Get.back(); 45 | Get.toNamed(Routes.HOME); 46 | }); 47 | } else { 48 | showAlert("Image is required"); 49 | } 50 | } else { 51 | showAlert("All fields are required"); 52 | } 53 | } 54 | 55 | void editBlog(BlogsModel model) async { 56 | Indicator.showLoading(); 57 | 58 | if (title.text.isNotEmpty && description.text.isNotEmpty) { 59 | if (imageFile == null) { 60 | Map map = { 61 | 'title': title.text, 62 | 'description': description.text, 63 | }; 64 | 65 | await _functions.editBlog(model.id, map).then((value) { 66 | Get.toNamed(Routes.HOME); 67 | showAlert("Blog Updated Sucessfully"); 68 | }); 69 | } else { 70 | String imageUrl = await _functions.uploadImage(imageFile!); 71 | 72 | Map map = { 73 | 'title': title.text, 74 | 'description': description.text, 75 | 'img': imageUrl, 76 | }; 77 | 78 | await _functions.editBlog(model.id, map).then((value) { 79 | Get.toNamed(Routes.HOME); 80 | showAlert("Blog Updated Sucessfully"); 81 | }); 82 | } 83 | } else { 84 | showAlert("All fields are required"); 85 | } 86 | 87 | Indicator.closeLoading(); 88 | updateData(); 89 | } 90 | 91 | void updateData() { 92 | Get.back(); 93 | Get.toNamed(Routes.HOME); 94 | if (Get.isRegistered()) { 95 | final controller = Get.find(); 96 | 97 | controller.myBlogs = []; 98 | Indicator.showLoading(); 99 | controller.getMyBlogData(); 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /lib/app/modules/upload_blog/views/upload_blog_view.dart: -------------------------------------------------------------------------------- 1 | import 'package:blog_app/app/data/global_widgets/app_bar.dart'; 2 | import 'package:blog_app/app/data/global_widgets/custom_button.dart'; 3 | import 'package:blog_app/app/data/global_widgets/text_field.dart'; 4 | import 'package:blog_app/app/models/blog_model.dart'; 5 | import 'package:flutter/material.dart'; 6 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 7 | 8 | import 'package:get/get.dart'; 9 | 10 | import '../controllers/upload_blog_controller.dart'; 11 | 12 | // ignore: must_be_immutable 13 | class UploadBlogView extends GetView { 14 | BlogsModel? model = Get.arguments; 15 | 16 | @override 17 | Widget build(BuildContext context) { 18 | if (model != null) { 19 | controller.title = TextEditingController(text: model!.title); 20 | controller.description = TextEditingController(text: model!.description); 21 | } 22 | 23 | return SafeArea( 24 | child: Scaffold( 25 | body: SingleChildScrollView( 26 | child: Column( 27 | mainAxisSize: MainAxisSize.max, 28 | children: [ 29 | CustomAppBar( 30 | title: model == null ? "Create Blog" : "Update Blog", 31 | ), 32 | SizedBox( 33 | height: 20.h, 34 | ), 35 | Container( 36 | height: 200.h, 37 | width: 300.w, 38 | alignment: Alignment.center, 39 | color: Colors.white30, 40 | child: GetBuilder( 41 | builder: (value) { 42 | if (value.imageFile != null) { 43 | return Image.file(value.imageFile!); 44 | } else { 45 | return CustomButton( 46 | function: () { 47 | controller.pickImage(); 48 | }, 49 | title: "Select Image"); 50 | } 51 | }, 52 | ), 53 | ), 54 | SizedBox( 55 | height: 20.h, 56 | ), 57 | ReusableTextField( 58 | isMultiline: false, 59 | hintText: "Title", 60 | controller: controller.title, 61 | ), 62 | SizedBox( 63 | height: 20.h, 64 | ), 65 | ReusableTextField( 66 | hintText: "Description", 67 | controller: controller.description, 68 | isMultiline: true, 69 | ), 70 | SizedBox( 71 | height: 20.h, 72 | ), 73 | ], 74 | ), 75 | ), 76 | bottomNavigationBar: Container( 77 | height: 60.h, 78 | width: double.infinity, 79 | alignment: Alignment.topCenter, 80 | child: CustomButton( 81 | function: () { 82 | if (model == null) { 83 | controller.createBlog(); 84 | } else { 85 | controller.editBlog(model!); 86 | } 87 | }, 88 | title: model == null ? "Create Blog" : "Update Blog", 89 | ), 90 | ), 91 | ), 92 | ); 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /lib/app/routes/app_pages.dart: -------------------------------------------------------------------------------- 1 | import 'package:get/get.dart'; 2 | 3 | import '../modules/authentication/bindings/authentication_binding.dart'; 4 | import '../modules/authentication/views/authentication_view.dart'; 5 | import '../modules/blog_detail_screen/bindings/blog_detail_screen_binding.dart'; 6 | import '../modules/blog_detail_screen/views/blog_detail_screen_view.dart'; 7 | import '../modules/favourite/bindings/favourite_binding.dart'; 8 | import '../modules/favourite/views/favourite_view.dart'; 9 | import '../modules/home/bindings/home_binding.dart'; 10 | import '../modules/home/views/home_view.dart'; 11 | import '../modules/login/bindings/login_binding.dart'; 12 | import '../modules/login/views/login_view.dart'; 13 | import '../modules/my_blogs/bindings/my_blogs_binding.dart'; 14 | import '../modules/my_blogs/views/my_blogs_view.dart'; 15 | import '../modules/profile/bindings/profile_binding.dart'; 16 | import '../modules/profile/views/profile_view.dart'; 17 | import '../modules/sign_up/bindings/sign_up_binding.dart'; 18 | import '../modules/sign_up/views/sign_up_view.dart'; 19 | import '../modules/title/bindings/title_binding.dart'; 20 | import '../modules/title/views/title_view.dart'; 21 | import '../modules/upload_blog/bindings/upload_blog_binding.dart'; 22 | import '../modules/upload_blog/views/upload_blog_view.dart'; 23 | 24 | part 'app_routes.dart'; 25 | 26 | class AppPages { 27 | AppPages._(); 28 | 29 | static const INITIAL = Routes.AUTHENTICATION; 30 | 31 | static final routes = [ 32 | GetPage( 33 | name: _Paths.HOME, 34 | page: () => HomeView(), 35 | binding: HomeBinding(), 36 | ), 37 | GetPage( 38 | name: _Paths.LOGIN, 39 | page: () => LoginView(), 40 | binding: LoginBinding(), 41 | ), 42 | GetPage( 43 | name: _Paths.SIGN_UP, 44 | page: () => SignUpView(), 45 | binding: SignUpBinding(), 46 | ), 47 | GetPage( 48 | name: _Paths.AUTHENTICATION, 49 | page: () => AuthenticationView(), 50 | binding: AuthenticationBinding(), 51 | ), 52 | GetPage( 53 | name: _Paths.UPLOAD_BLOG, 54 | page: () => UploadBlogView(), 55 | binding: UploadBlogBinding(), 56 | ), 57 | GetPage( 58 | name: _Paths.BLOG_DETAIL_SCREEN, 59 | page: () => BlogDetailScreenView(), 60 | binding: BlogDetailScreenBinding(), 61 | ), 62 | GetPage( 63 | name: _Paths.PROFILE, 64 | page: () => ProfileView(), 65 | binding: ProfileBinding(), 66 | ), 67 | GetPage( 68 | name: _Paths.MY_BLOGS, 69 | page: () => MyBlogsView(), 70 | binding: MyBlogsBinding(), 71 | ), 72 | GetPage( 73 | name: _Paths.FAVOURITE, 74 | page: () => FavouriteView(), 75 | binding: FavouriteBinding(), 76 | ), 77 | GetPage( 78 | name: _Paths.TITLE, 79 | page: () => TitleView(), 80 | binding: TitleBinding(), 81 | ), 82 | ]; 83 | } 84 | -------------------------------------------------------------------------------- /lib/app/routes/app_routes.dart: -------------------------------------------------------------------------------- 1 | part of 'app_pages.dart'; 2 | // DO NOT EDIT. This is code generated via package:get_cli/get_cli.dart 3 | 4 | abstract class Routes { 5 | Routes._(); 6 | 7 | static const HOME = _Paths.HOME; 8 | static const LOGIN = _Paths.LOGIN; 9 | static const SIGN_UP = _Paths.SIGN_UP; 10 | static const AUTHENTICATION = _Paths.AUTHENTICATION; 11 | static const UPLOAD_BLOG = _Paths.UPLOAD_BLOG; 12 | static const BLOG_DETAIL_SCREEN = _Paths.BLOG_DETAIL_SCREEN; 13 | static const PROFILE = _Paths.PROFILE; 14 | static const MY_BLOGS = _Paths.MY_BLOGS; 15 | static const FAVOURITE = _Paths.FAVOURITE; 16 | static const TITLE = _Paths.TITLE; 17 | } 18 | 19 | abstract class _Paths { 20 | static const HOME = '/home'; 21 | static const LOGIN = '/login'; 22 | static const SIGN_UP = '/sign-up'; 23 | static const AUTHENTICATION = '/authentication'; 24 | static const UPLOAD_BLOG = '/upload-blog'; 25 | static const BLOG_DETAIL_SCREEN = '/blog-detail-screen'; 26 | static const PROFILE = '/profile'; 27 | static const MY_BLOGS = '/my-blogs'; 28 | static const FAVOURITE = '/favourite'; 29 | static const TITLE = '/title'; 30 | } 31 | -------------------------------------------------------------------------------- /lib/generated_plugin_registrant.dart: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // ignore_for_file: directives_ordering 6 | // ignore_for_file: lines_longer_than_80_chars 7 | // ignore_for_file: depend_on_referenced_packages 8 | 9 | import 'package:cloud_firestore_web/cloud_firestore_web.dart'; 10 | import 'package:connectivity_plus_web/connectivity_plus_web.dart'; 11 | import 'package:firebase_auth_web/firebase_auth_web.dart'; 12 | import 'package:firebase_core_web/firebase_core_web.dart'; 13 | import 'package:firebase_storage_web/firebase_storage_web.dart'; 14 | import 'package:fluttertoast/fluttertoast_web.dart'; 15 | import 'package:image_picker_for_web/image_picker_for_web.dart'; 16 | import 'package:url_launcher_web/url_launcher_web.dart'; 17 | 18 | import 'package:flutter_web_plugins/flutter_web_plugins.dart'; 19 | 20 | // ignore: public_member_api_docs 21 | void registerPlugins(Registrar registrar) { 22 | FirebaseFirestoreWeb.registerWith(registrar); 23 | ConnectivityPlusPlugin.registerWith(registrar); 24 | FirebaseAuthWeb.registerWith(registrar); 25 | FirebaseCoreWeb.registerWith(registrar); 26 | FirebaseStorageWeb.registerWith(registrar); 27 | FluttertoastWebPlugin.registerWith(registrar); 28 | ImagePickerPlugin.registerWith(registrar); 29 | UrlLauncherPlugin.registerWith(registrar); 30 | registrar.registerMessageHandler(); 31 | } 32 | -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:firebase_core/firebase_core.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_screenutil/flutter_screenutil.dart'; 4 | 5 | import 'package:get/get.dart'; 6 | 7 | import 'app/routes/app_pages.dart'; 8 | 9 | void main() async { 10 | WidgetsFlutterBinding.ensureInitialized(); 11 | await Firebase.initializeApp(); 12 | 13 | runApp( 14 | ScreenUtilInit( 15 | designSize: const Size(360, 690), 16 | builder: (BuildContext context, c) { 17 | return GetMaterialApp( 18 | debugShowCheckedModeBanner: false, 19 | title: "Blog-App", 20 | initialRoute: AppPages.INITIAL, 21 | getPages: AppPages.routes, 22 | ); 23 | }, 24 | ), 25 | ); 26 | } 27 | -------------------------------------------------------------------------------- /linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.10) 3 | project(runner 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 "blog_app") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.blog_app") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 58 | 59 | # Define the application target. To change its name, change BINARY_NAME above, 60 | # not the value here, or `flutter run` will no longer work. 61 | # 62 | # Any new source files that you add to the application should be added here. 63 | add_executable(${BINARY_NAME} 64 | "main.cc" 65 | "my_application.cc" 66 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 67 | ) 68 | 69 | # Apply the standard set of build settings. This can be removed for applications 70 | # that need different build settings. 71 | apply_standard_settings(${BINARY_NAME}) 72 | 73 | # Add dependency libraries. Add any application-specific dependencies here. 74 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 75 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 76 | 77 | # Run the Flutter tool portions of the build. This must not be removed. 78 | add_dependencies(${BINARY_NAME} flutter_assemble) 79 | 80 | # Only the install-generated bundle's copy of the executable will launch 81 | # correctly, since the resources must in the right relative locations. To avoid 82 | # people trying to run the unbundled copy, put it in a subdirectory instead of 83 | # the default top-level location. 84 | set_target_properties(${BINARY_NAME} 85 | PROPERTIES 86 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 87 | ) 88 | 89 | # Generated plugin build rules, which manage building the plugins and adding 90 | # them to the application. 91 | include(flutter/generated_plugins.cmake) 92 | 93 | 94 | # === Installation === 95 | # By default, "installing" just makes a relocatable bundle in the build 96 | # directory. 97 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 98 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 99 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 100 | endif() 101 | 102 | # Start with a clean build bundle directory every time. 103 | install(CODE " 104 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 105 | " COMPONENT Runtime) 106 | 107 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 108 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 109 | 110 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 111 | COMPONENT Runtime) 112 | 113 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 114 | COMPONENT Runtime) 115 | 116 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 117 | COMPONENT Runtime) 118 | 119 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 120 | install(FILES "${bundled_library}" 121 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 122 | COMPONENT Runtime) 123 | endforeach(bundled_library) 124 | 125 | # Fully re-copy the assets directory on each build to avoid having stale files 126 | # from a previous install. 127 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 128 | install(CODE " 129 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 130 | " COMPONENT Runtime) 131 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 132 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 133 | 134 | # Install the AOT library on non-Debug builds only. 135 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 136 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 137 | COMPONENT Runtime) 138 | endif() 139 | -------------------------------------------------------------------------------- /linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 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 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /linux/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 fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /linux/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 fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 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}/linux 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}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /linux/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /linux/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "blog_app"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "blog_app"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /linux/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import cloud_firestore 9 | import connectivity_plus_macos 10 | import firebase_auth 11 | import firebase_core 12 | import firebase_storage 13 | import url_launcher_macos 14 | 15 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 16 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin")) 17 | ConnectivityPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlugin")) 18 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin")) 19 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin")) 20 | FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin")) 21 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 22 | } 23 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = blog_app 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.blogApp 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2022 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: blog_app 2 | version: 1.0.0+1 3 | publish_to: none 4 | description: A new Flutter project. 5 | environment: 6 | sdk: '>=2.15.0 <3.0.0' 7 | 8 | dependencies: 9 | cupertino_icons: 10 | get: 11 | obx: 12 | flutter_screenutil: 13 | firebase_auth: 14 | cloud_firestore: 15 | firebase_core: 16 | fluttertoast: 17 | firebase_storage: 18 | image_picker: 19 | uuid: 20 | image: 21 | url_launcher: 22 | auto_reload: 23 | file: 24 | flutter: 25 | sdk: flutter 26 | 27 | 28 | 29 | dev_dependencies: 30 | flutter_lints: ^1.0.0 31 | lints: 1.0.1 32 | flutter_test: 33 | sdk: flutter 34 | 35 | flutter: 36 | uses-material-design: true 37 | 38 | assets: 39 | - assets/images/logo.png 40 | -------------------------------------------------------------------------------- /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:blog_app/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 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | blog_app 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog_app", 3 | "short_name": "blog_app", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "A new Flutter project.", 9 | "orientation": "portrait-primary", 10 | "prefer_related_applications": false, 11 | "icons": [ 12 | { 13 | "src": "icons/Icon-192.png", 14 | "sizes": "192x192", 15 | "type": "image/png" 16 | }, 17 | { 18 | "src": "icons/Icon-512.png", 19 | "sizes": "512x512", 20 | "type": "image/png" 21 | }, 22 | { 23 | "src": "icons/Icon-maskable-192.png", 24 | "sizes": "192x192", 25 | "type": "image/png", 26 | "purpose": "maskable" 27 | }, 28 | { 29 | "src": "icons/Icon-maskable-512.png", 30 | "sizes": "512x512", 31 | "type": "image/png", 32 | "purpose": "maskable" 33 | } 34 | ] 35 | } 36 | -------------------------------------------------------------------------------- /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(blog_app 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 "blog_app") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(SET CMP0063 NEW) 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 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /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 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /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 | #include 11 | 12 | void RegisterPlugins(flutter::PluginRegistry* registry) { 13 | ConnectivityPlusWindowsPluginRegisterWithRegistrar( 14 | registry->GetRegistrarForPlugin("ConnectivityPlusWindowsPlugin")); 15 | UrlLauncherWindowsRegisterWithRegistrar( 16 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 17 | } 18 | -------------------------------------------------------------------------------- /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 | connectivity_plus_windows 7 | url_launcher_windows 8 | ) 9 | 10 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /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 | # Disable Windows macros that collide with C++ standard library functions. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 25 | 26 | # Add dependency libraries and include directories. Add any application-specific 27 | # dependencies here. 28 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 29 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 30 | 31 | # Run the Flutter tool portions of the build. This must not be removed. 32 | add_dependencies(${BINARY_NAME} flutter_assemble) 33 | -------------------------------------------------------------------------------- /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 | #ifdef FLUTTER_BUILD_NUMBER 64 | #define VERSION_AS_NUMBER FLUTTER_BUILD_NUMBER 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0 67 | #endif 68 | 69 | #ifdef FLUTTER_BUILD_NAME 70 | #define VERSION_AS_STRING #FLUTTER_BUILD_NAME 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.example" "\0" 93 | VALUE "FileDescription", "blog_app" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "blog_app" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2022 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "blog_app.exe" "\0" 98 | VALUE "ProductName", "blog_app" "\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 | return true; 30 | } 31 | 32 | void FlutterWindow::OnDestroy() { 33 | if (flutter_controller_) { 34 | flutter_controller_ = nullptr; 35 | } 36 | 37 | Win32Window::OnDestroy(); 38 | } 39 | 40 | LRESULT 41 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 42 | WPARAM const wparam, 43 | LPARAM const lparam) noexcept { 44 | // Give Flutter, including plugins, an opportunity to handle window messages. 45 | if (flutter_controller_) { 46 | std::optional result = 47 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 48 | lparam); 49 | if (result) { 50 | return *result; 51 | } 52 | } 53 | 54 | switch (message) { 55 | case WM_FONTCHANGE: 56 | flutter_controller_->engine()->ReloadSystemFonts(); 57 | break; 58 | } 59 | 60 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 61 | } 62 | -------------------------------------------------------------------------------- /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.CreateAndShow(L"blog_app", 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/mdabdullahibnaharun/BlogApp/264279824e40d87f5945c5285fb44b53c7f945dd/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 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /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 | 5 | #include "resource.h" 6 | 7 | namespace { 8 | 9 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 10 | 11 | // The number of Win32Window objects that currently exist. 12 | static int g_active_window_count = 0; 13 | 14 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 15 | 16 | // Scale helper to convert logical scaler values to physical using passed in 17 | // scale factor 18 | int Scale(int source, double scale_factor) { 19 | return static_cast(source * scale_factor); 20 | } 21 | 22 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 23 | // This API is only needed for PerMonitor V1 awareness mode. 24 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 25 | HMODULE user32_module = LoadLibraryA("User32.dll"); 26 | if (!user32_module) { 27 | return; 28 | } 29 | auto enable_non_client_dpi_scaling = 30 | reinterpret_cast( 31 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 32 | if (enable_non_client_dpi_scaling != nullptr) { 33 | enable_non_client_dpi_scaling(hwnd); 34 | FreeLibrary(user32_module); 35 | } 36 | } 37 | 38 | } // namespace 39 | 40 | // Manages the Win32Window's window class registration. 41 | class WindowClassRegistrar { 42 | public: 43 | ~WindowClassRegistrar() = default; 44 | 45 | // Returns the singleton registar instance. 46 | static WindowClassRegistrar* GetInstance() { 47 | if (!instance_) { 48 | instance_ = new WindowClassRegistrar(); 49 | } 50 | return instance_; 51 | } 52 | 53 | // Returns the name of the window class, registering the class if it hasn't 54 | // previously been registered. 55 | const wchar_t* GetWindowClass(); 56 | 57 | // Unregisters the window class. Should only be called if there are no 58 | // instances of the window. 59 | void UnregisterWindowClass(); 60 | 61 | private: 62 | WindowClassRegistrar() = default; 63 | 64 | static WindowClassRegistrar* instance_; 65 | 66 | bool class_registered_ = false; 67 | }; 68 | 69 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 70 | 71 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 72 | if (!class_registered_) { 73 | WNDCLASS window_class{}; 74 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 75 | window_class.lpszClassName = kWindowClassName; 76 | window_class.style = CS_HREDRAW | CS_VREDRAW; 77 | window_class.cbClsExtra = 0; 78 | window_class.cbWndExtra = 0; 79 | window_class.hInstance = GetModuleHandle(nullptr); 80 | window_class.hIcon = 81 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 82 | window_class.hbrBackground = 0; 83 | window_class.lpszMenuName = nullptr; 84 | window_class.lpfnWndProc = Win32Window::WndProc; 85 | RegisterClass(&window_class); 86 | class_registered_ = true; 87 | } 88 | return kWindowClassName; 89 | } 90 | 91 | void WindowClassRegistrar::UnregisterWindowClass() { 92 | UnregisterClass(kWindowClassName, nullptr); 93 | class_registered_ = false; 94 | } 95 | 96 | Win32Window::Win32Window() { 97 | ++g_active_window_count; 98 | } 99 | 100 | Win32Window::~Win32Window() { 101 | --g_active_window_count; 102 | Destroy(); 103 | } 104 | 105 | bool Win32Window::CreateAndShow(const std::wstring& title, 106 | const Point& origin, 107 | const Size& size) { 108 | Destroy(); 109 | 110 | const wchar_t* window_class = 111 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 112 | 113 | const POINT target_point = {static_cast(origin.x), 114 | static_cast(origin.y)}; 115 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 116 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 117 | double scale_factor = dpi / 96.0; 118 | 119 | HWND window = CreateWindow( 120 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW | WS_VISIBLE, 121 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 122 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 123 | nullptr, nullptr, GetModuleHandle(nullptr), this); 124 | 125 | if (!window) { 126 | return false; 127 | } 128 | 129 | return OnCreate(); 130 | } 131 | 132 | // static 133 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 134 | UINT const message, 135 | WPARAM const wparam, 136 | LPARAM const lparam) noexcept { 137 | if (message == WM_NCCREATE) { 138 | auto window_struct = reinterpret_cast(lparam); 139 | SetWindowLongPtr(window, GWLP_USERDATA, 140 | reinterpret_cast(window_struct->lpCreateParams)); 141 | 142 | auto that = static_cast(window_struct->lpCreateParams); 143 | EnableFullDpiSupportIfAvailable(window); 144 | that->window_handle_ = window; 145 | } else if (Win32Window* that = GetThisFromHandle(window)) { 146 | return that->MessageHandler(window, message, wparam, lparam); 147 | } 148 | 149 | return DefWindowProc(window, message, wparam, lparam); 150 | } 151 | 152 | LRESULT 153 | Win32Window::MessageHandler(HWND hwnd, 154 | UINT const message, 155 | WPARAM const wparam, 156 | LPARAM const lparam) noexcept { 157 | switch (message) { 158 | case WM_DESTROY: 159 | window_handle_ = nullptr; 160 | Destroy(); 161 | if (quit_on_close_) { 162 | PostQuitMessage(0); 163 | } 164 | return 0; 165 | 166 | case WM_DPICHANGED: { 167 | auto newRectSize = reinterpret_cast(lparam); 168 | LONG newWidth = newRectSize->right - newRectSize->left; 169 | LONG newHeight = newRectSize->bottom - newRectSize->top; 170 | 171 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 172 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 173 | 174 | return 0; 175 | } 176 | case WM_SIZE: { 177 | RECT rect = GetClientArea(); 178 | if (child_content_ != nullptr) { 179 | // Size and position the child window. 180 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 181 | rect.bottom - rect.top, TRUE); 182 | } 183 | return 0; 184 | } 185 | 186 | case WM_ACTIVATE: 187 | if (child_content_ != nullptr) { 188 | SetFocus(child_content_); 189 | } 190 | return 0; 191 | } 192 | 193 | return DefWindowProc(window_handle_, message, wparam, lparam); 194 | } 195 | 196 | void Win32Window::Destroy() { 197 | OnDestroy(); 198 | 199 | if (window_handle_) { 200 | DestroyWindow(window_handle_); 201 | window_handle_ = nullptr; 202 | } 203 | if (g_active_window_count == 0) { 204 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 205 | } 206 | } 207 | 208 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 209 | return reinterpret_cast( 210 | GetWindowLongPtr(window, GWLP_USERDATA)); 211 | } 212 | 213 | void Win32Window::SetChildContent(HWND content) { 214 | child_content_ = content; 215 | SetParent(content, window_handle_); 216 | RECT frame = GetClientArea(); 217 | 218 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 219 | frame.bottom - frame.top, true); 220 | 221 | SetFocus(child_content_); 222 | } 223 | 224 | RECT Win32Window::GetClientArea() { 225 | RECT frame; 226 | GetClientRect(window_handle_, &frame); 227 | return frame; 228 | } 229 | 230 | HWND Win32Window::GetHandle() { 231 | return window_handle_; 232 | } 233 | 234 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 235 | quit_on_close_ = quit_on_close; 236 | } 237 | 238 | bool Win32Window::OnCreate() { 239 | // No-op; provided for subclasses. 240 | return true; 241 | } 242 | 243 | void Win32Window::OnDestroy() { 244 | // No-op; provided for subclasses. 245 | } 246 | -------------------------------------------------------------------------------- /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 and shows a win32 window with |title| and position and size 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 to will treat the width height passed in to this function 35 | // as logical pixels and scale to appropriate for the default monitor. Returns 36 | // true if the window was created successfully. 37 | bool CreateAndShow(const std::wstring& title, 38 | const Point& origin, 39 | const Size& size); 40 | 41 | // Release OS resources associated with window. 42 | void Destroy(); 43 | 44 | // Inserts |content| into the window tree. 45 | void SetChildContent(HWND content); 46 | 47 | // Returns the backing Window handle to enable clients to set icon and other 48 | // window properties. Returns nullptr if the window has been destroyed. 49 | HWND GetHandle(); 50 | 51 | // If true, closing this window will quit the application. 52 | void SetQuitOnClose(bool quit_on_close); 53 | 54 | // Return a RECT representing the bounds of the current client area. 55 | RECT GetClientArea(); 56 | 57 | protected: 58 | // Processes and route salient window messages for mouse handling, 59 | // size change and DPI. Delegates handling of these to member overloads that 60 | // inheriting classes can handle. 61 | virtual LRESULT MessageHandler(HWND window, 62 | UINT const message, 63 | WPARAM const wparam, 64 | LPARAM const lparam) noexcept; 65 | 66 | // Called when CreateAndShow is called, allowing subclass window-related 67 | // setup. Subclasses should return false if setup fails. 68 | virtual bool OnCreate(); 69 | 70 | // Called when Destroy is called. 71 | virtual void OnDestroy(); 72 | 73 | private: 74 | friend class WindowClassRegistrar; 75 | 76 | // OS callback called by message pump. Handles the WM_NCCREATE message which 77 | // is passed when the non-client area is being created and enables automatic 78 | // non-client DPI scaling so that the non-client area automatically 79 | // responsponds to changes in DPI. All other messages are handled by 80 | // MessageHandler. 81 | static LRESULT CALLBACK WndProc(HWND const window, 82 | UINT const message, 83 | WPARAM const wparam, 84 | LPARAM const lparam) noexcept; 85 | 86 | // Retrieves a class instance pointer for |window| 87 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 88 | 89 | bool quit_on_close_ = false; 90 | 91 | // window handle for top level window. 92 | HWND window_handle_ = nullptr; 93 | 94 | // window handle for hosted content. 95 | HWND child_content_ = nullptr; 96 | }; 97 | 98 | #endif // RUNNER_WIN32_WINDOW_H_ 99 | --------------------------------------------------------------------------------