├── .gitignore
├── .metadata
├── README.md
├── analysis_options.yaml
├── android
├── .gitignore
├── app
│ ├── build.gradle
│ ├── google-services.json
│ └── src
│ │ ├── debug
│ │ └── AndroidManifest.xml
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── java
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── instagram_flutter
│ │ │ │ └── MainActivity.java
│ │ └── 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
└── ic_instagram.svg
├── 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.h
│ ├── AppDelegate.m
│ ├── 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
│ ├── GoogleService-Info.plist
│ ├── Info.plist
│ └── main.m
├── lib
├── filereader.dart
├── main.dart
├── models
│ ├── post.dart
│ └── user.dart
├── providers
│ └── user_provider.dart
├── resources
│ ├── auth_methods.dart
│ ├── firestore_methods.dart
│ └── storage_methods.dart
├── responsive
│ ├── mobile_screen_layout.dart
│ ├── responsive_layout_screen.dart
│ └── web_screen_layout.dart
├── screens
│ ├── add_post_screen.dart
│ ├── comments_screen.dart
│ ├── feed_screen.dart
│ ├── home_screen.dart
│ ├── login_screen.dart
│ ├── profile_screen.dart
│ ├── search_screen.dart
│ └── signup_screen.dart
├── utils
│ ├── colors.dart
│ ├── global_variables.dart
│ └── utils.dart
└── widgets
│ ├── comment_card.dart
│ ├── follow_button.dart
│ ├── like_animation.dart
│ ├── post_card.dart
│ └── text_field_input.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 | # Symbolication related
36 | app.*.symbols
37 |
38 | # Obfuscation related
39 | app.*.map.json
40 |
41 | # Android Studio will place build artifacts here
42 | /android/app/debug
43 | /android/app/profile
44 | /android/app/release
45 |
--------------------------------------------------------------------------------
/.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: 135454af32477f815a7525073027a3ff9eff1bfd
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: 135454af32477f815a7525073027a3ff9eff1bfd
17 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
18 | - platform: android
19 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
20 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
21 | - platform: ios
22 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
23 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
24 | - platform: linux
25 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
26 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
27 | - platform: macos
28 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
29 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
30 | - platform: web
31 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
32 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
33 | - platform: windows
34 | create_revision: 135454af32477f815a7525073027a3ff9eff1bfd
35 | base_revision: 135454af32477f815a7525073027a3ff9eff1bfd
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # Instagram Clone
3 |
4 | This project is a responsive Instagram clone built using Flutter and Firebase. It utilizes various Firebase services such as Firestore for data storage, Firebase Auth for user authentication, and Firebase Storage for storing user posts' images. The app features a responsive user interface, implemented using Flutter's layout widgets, and utilizes the Provider package for state management. The main functionalities of the Instagram clone include user login and registration, user profile pages, posting images, liking posts, commenting on posts, and searching for other users..
5 |
6 |
7 | ## Features
8 |
9 | - User login: Users can log in to the app using their credentials or via third-party authentication methods.
10 | - Profile page: Users can view and edit their profile information, including a profile picture and personal details.
11 | - Sign up: New users can create an account to access the app's features.
12 | - Add post: Users can upload and share images with other users by creating posts.
13 | - Like post: Users can like posts from other users to show their appreciation.
14 | - Comment on post: Users can leave comments on posts to engage in discussions.
15 | - Search user: Users can search for other users by their usernames or display names.
16 |
17 | ## Prerequisites
18 |
19 | Before running the Instagram Clone, make sure you have the following:
20 |
21 | - Flutter SDK (latest version)
22 | - Dart programming language
23 | - Firebase account with Firestore, Firebase Auth, and Firebase Storage enabled
24 | - Flutter packages: firebase_core, cloud_firestore, firebase_auth, firebase_storage, provider
25 |
26 | ## ScreenShot
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | ## Acknowledgements
40 |
41 | - This project was inspired by the need to replicate the popular features of the Instagram app using Flutter and Firebase.
42 | - Thanks to the open-source community for providing libraries and resources that made this project possible.
43 |
44 | ## License
45 |
46 | The Instagram Clone project is licensed under the MIT License.
47 |
48 |
--------------------------------------------------------------------------------
/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 | android {
29 | compileSdkVersion flutter.compileSdkVersion
30 | ndkVersion flutter.ndkVersion
31 |
32 | compileOptions {
33 | sourceCompatibility JavaVersion.VERSION_1_8
34 | targetCompatibility JavaVersion.VERSION_1_8
35 | }
36 |
37 | defaultConfig {
38 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
39 | applicationId "com.example.instagram_flutter"
40 | // You can update the following values to match your application needs.
41 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
42 | minSdkVersion 19
43 | targetSdkVersion flutter.targetSdkVersion
44 | versionCode flutterVersionCode.toInteger()
45 | versionName flutterVersionName
46 | multiDexEnabled true
47 | }
48 |
49 | buildTypes {
50 | release {
51 | // TODO: Add your own signing config for the release build.
52 | // Signing with the debug keys for now, so `flutter run --release` works.
53 | signingConfig signingConfigs.debug
54 | }
55 | }
56 | }
57 |
58 | flutter {
59 | source '../..'
60 | }
61 |
--------------------------------------------------------------------------------
/android/app/google-services.json:
--------------------------------------------------------------------------------
1 | {
2 | "project_info": {
3 | "project_number": "627562025097",
4 | "project_id": "instagram-clone-f4dd2",
5 | "storage_bucket": "instagram-clone-f4dd2.appspot.com"
6 | },
7 | "client": [
8 | {
9 | "client_info": {
10 | "mobilesdk_app_id": "1:627562025097:android:f4a465f22e4dc70e2bf658",
11 | "android_client_info": {
12 | "package_name": "com.example.instagram_flutter"
13 | }
14 | },
15 | "oauth_client": [
16 | {
17 | "client_id": "627562025097-c6il7gl77p2i3p63fs8qi6cgijv2ecvv.apps.googleusercontent.com",
18 | "client_type": 3
19 | }
20 | ],
21 | "api_key": [
22 | {
23 | "current_key": "AIzaSyBtMyS3G5bLRIlVFTauLYyhr7BgvoZmt9Q"
24 | }
25 | ],
26 | "services": {
27 | "appinvite_service": {
28 | "other_platform_oauth_client": [
29 | {
30 | "client_id": "627562025097-c6il7gl77p2i3p63fs8qi6cgijv2ecvv.apps.googleusercontent.com",
31 | "client_type": 3
32 | },
33 | {
34 | "client_id": "627562025097-qcjnqb5vkbq3hstejbe2tun7ni2cmj21.apps.googleusercontent.com",
35 | "client_type": 2,
36 | "ios_info": {
37 | "bundle_id": "com.example.instagramFlutter"
38 | }
39 | }
40 | ]
41 | }
42 | }
43 | }
44 | ],
45 | "configuration_version": "1"
46 | }
--------------------------------------------------------------------------------
/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/com/example/instagram_flutter/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.example.instagram_flutter;
2 |
3 | import io.flutter.embedding.android.FlutterActivity;
4 |
5 | public class MainActivity extends 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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | classpath 'com.google.gms:google-services:4.3.15'
12 | }
13 | }
14 |
15 | allprojects {
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.buildDir = '../build'
23 | subprojects {
24 | project.buildDir = "${rootProject.buildDir}/${project.name}"
25 | }
26 | subprojects {
27 | project.evaluationDependsOn(':app')
28 | }
29 |
30 | tasks.register("clean", Delete) {
31 | delete rootProject.buildDir
32 | }
33 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | zipStoreBase=GRADLE_USER_HOME
4 | zipStorePath=wrapper/dists
5 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
6 |
--------------------------------------------------------------------------------
/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/ic_instagram.svg:
--------------------------------------------------------------------------------
1 |
5 |
--------------------------------------------------------------------------------
/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 | 11.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.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #import "AppDelegate.h"
2 | #import "GeneratedPluginRegistrant.h"
3 |
4 | @implementation AppDelegate
5 |
6 | - (BOOL)application:(UIApplication *)application
7 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
8 | [GeneratedPluginRegistrant registerWithRegistry:self];
9 | // Override point for customization after application launch.
10 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
11 | }
12 |
13 | @end
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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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/GoogleService-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CLIENT_ID
6 | 627562025097-qcjnqb5vkbq3hstejbe2tun7ni2cmj21.apps.googleusercontent.com
7 | REVERSED_CLIENT_ID
8 | com.googleusercontent.apps.627562025097-qcjnqb5vkbq3hstejbe2tun7ni2cmj21
9 | API_KEY
10 | AIzaSyBjGDkMJNNkF7NH_Sajg54LkwlKZ0m88v4
11 | GCM_SENDER_ID
12 | 627562025097
13 | PLIST_VERSION
14 | 1
15 | BUNDLE_ID
16 | com.example.instagramFlutter
17 | PROJECT_ID
18 | instagram-clone-f4dd2
19 | STORAGE_BUCKET
20 | instagram-clone-f4dd2.appspot.com
21 | IS_ADS_ENABLED
22 |
23 | IS_ANALYTICS_ENABLED
24 |
25 | IS_APPINVITE_ENABLED
26 |
27 | IS_GCM_ENABLED
28 |
29 | IS_SIGNIN_ENABLED
30 |
31 | GOOGLE_APP_ID
32 | 1:627562025097:ios:012cdaf2c287243b2bf658
33 |
34 |
--------------------------------------------------------------------------------
/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | Instagram Flutter
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | instagram_flutter
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 | UIApplicationSupportsIndirectInputEvents
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/lib/filereader.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | void printFileNames(Directory directory, {String parent = ''}) {
4 | String folderName = directory.path.split(Platform.pathSeparator).last;
5 |
6 | if (parent.isNotEmpty) {
7 | folderName = parent + ' - ' + folderName;
8 |
9 | }
10 |
11 |
12 |
13 | directory.listSync().forEach((entity) {
14 | if (entity is Directory) {
15 | printFileNames(entity, parent: folderName);
16 | } else if (entity is File) {
17 | print(folderName + ' - ' + entity.path.split(Platform.pathSeparator).last);
18 | }
19 | });
20 | }
21 |
22 | void main() {
23 | // Provide the root directory path here
24 | String rootDirectoryPath = 'lib';
25 |
26 | Directory rootDirectory = Directory(rootDirectoryPath);
27 | printFileNames(rootDirectory);
28 | }
29 |
--------------------------------------------------------------------------------
/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:firebase_auth/firebase_auth.dart';
2 | import 'package:firebase_core/firebase_core.dart';
3 | import 'package:flutter/foundation.dart';
4 | import 'package:flutter/material.dart';
5 | import 'package:instagram_flutter/providers/user_provider.dart';
6 | import 'package:instagram_flutter/responsive/mobile_screen_layout.dart';
7 | import 'package:instagram_flutter/responsive/responsive_layout_screen.dart';
8 | import 'package:instagram_flutter/responsive/web_screen_layout.dart';
9 | import 'package:instagram_flutter/screens/login_screen.dart';
10 | import 'package:instagram_flutter/screens/signup_screen.dart';
11 | import 'package:instagram_flutter/utils/colors.dart';
12 | import 'package:provider/provider.dart';
13 |
14 | Future main() async {
15 | WidgetsFlutterBinding.ensureInitialized();
16 | if (kIsWeb) {
17 | await Firebase.initializeApp(
18 | options: const FirebaseOptions(
19 | apiKey: 'AIzaSyC3GR-jm1aYvtHVagG2YZJUJzerZzqFCbA',
20 | appId: '1:627562025097:web:324f25ac5e4d34412bf658',
21 | messagingSenderId: '627562025097',
22 | projectId: 'instagram-clone-f4dd2',
23 | storageBucket: "instagram-clone-f4dd2.appspot.com",
24 | ),
25 | );
26 | } else {
27 | await Firebase.initializeApp();
28 | }
29 | runApp(const MyApp());
30 | }
31 |
32 | class MyApp extends StatelessWidget {
33 | const MyApp({super.key});
34 |
35 | // This widget is the root of your application.
36 | @override
37 | Widget build(BuildContext context) {
38 | return MultiProvider(
39 | providers: [
40 | ChangeNotifierProvider(
41 | create: (_) => UserProvider(),
42 | ),
43 | ],
44 | child: MaterialApp(
45 | debugShowCheckedModeBanner: false,
46 | title: 'Instagram_clone',
47 | theme: ThemeData.dark()
48 | .copyWith(scaffoldBackgroundColor: mobileBackgroundColor),
49 | home: StreamBuilder(
50 | stream: FirebaseAuth.instance.authStateChanges(),
51 | builder: (context, snapshot) {
52 | if (snapshot.connectionState == ConnectionState.active) {
53 | if (snapshot.hasData) {
54 | return const ResponsiveLayout(
55 | webScreenLayout: WebScreenLayout(),
56 | mobileScreenLayout: MobileScreenLayout(),
57 | );
58 | } else if (snapshot.hasError) {
59 | return Center(
60 | child: Text('${snapshot.error}'),
61 | );
62 | }
63 | }
64 | if (snapshot.connectionState == ConnectionState.waiting) {
65 | return const Center(
66 | child: CircularProgressIndicator(
67 | color: primaryColor,
68 | ),
69 | );
70 | }
71 | return const LoginScreen();
72 | },
73 | ),
74 | ),
75 | );
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/lib/models/post.dart:
--------------------------------------------------------------------------------
1 |
2 |
3 | import 'package:cloud_firestore/cloud_firestore.dart';
4 |
5 | class Post{
6 | final String username;
7 | final String uid;
8 | final String description;
9 | final String postId;
10 | final String postUrl;
11 | final String profImage;
12 | final datePublished;
13 | final likes;
14 |
15 | const Post({
16 | required this.username,
17 | required this.description,
18 | required this.uid,
19 | required this.postId,
20 | required this.postUrl,
21 | required this.profImage,
22 | required this.likes,
23 | required this.datePublished,
24 | });
25 |
26 | Map toJson()=>{
27 | 'username':username,
28 | 'uid': uid,
29 | 'description':description,
30 | 'postId':postId,
31 | 'datePublished': datePublished,
32 | 'profImage':profImage,
33 | 'likes':likes,
34 | "postUrl":postUrl,
35 | };
36 |
37 | static Post fromSnap(DocumentSnapshot snap){
38 | var snapshot= snap.data() as Map;
39 | return Post(username: snapshot[' username'], description: snapshot['description']
40 | , uid: snapshot['uid'], postId: snapshot['postId'],
41 | postUrl: snapshot['postUrl'], profImage: snapshot['profImage'],
42 | likes: snapshot['likes'], datePublished: snapshot['datePublished']);
43 | }
44 |
45 | }
--------------------------------------------------------------------------------
/lib/models/user.dart:
--------------------------------------------------------------------------------
1 |
2 |
3 | import 'package:cloud_firestore/cloud_firestore.dart';
4 |
5 | class User{
6 | final String username;
7 | final String uid;
8 | final String email;
9 | final String bio;
10 | final List followers;
11 | final List following;
12 | final String photoUrl;
13 |
14 | const User({
15 | required this.email,
16 | required this.photoUrl,
17 | required this.uid,
18 | required this.bio,
19 | required this.username,
20 | required this.followers,
21 | required this.following,
22 | });
23 |
24 | Map toJson()=>{
25 | 'username':username,
26 | 'uid': uid,
27 | 'email':email,
28 | 'bio':bio,
29 | 'followers': followers,
30 | 'following':following,
31 | 'photoUrl':photoUrl,
32 | };
33 |
34 | static User fromSnap(DocumentSnapshot snap){
35 | var snapshot= snap.data() as Map;
36 | return User(email: snapshot['email'], photoUrl: snapshot['photoUrl'], uid: snapshot['uid'],
37 | bio: snapshot['bio'],
38 | username: snapshot['username'], followers: snapshot['followers'],
39 | following: snapshot['following']);
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/lib/providers/user_provider.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/cupertino.dart';
2 | import 'package:instagram_flutter/models/user.dart';
3 | import 'package:instagram_flutter/resources/auth_methods.dart';
4 |
5 | class UserProvider with ChangeNotifier{
6 | User? _user;
7 | final AuthMethods _authMethods=AuthMethods();
8 | User get getUser=>_user!;
9 | Future refreshUser() async{
10 |
11 | User user=await _authMethods.getUserDetails();
12 | _user=user;
13 |
14 | notifyListeners();
15 |
16 | }
17 | }
--------------------------------------------------------------------------------
/lib/resources/auth_methods.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | import 'package:cloud_firestore/cloud_firestore.dart';
4 | import 'package:firebase_auth/firebase_auth.dart';
5 | import 'package:flutter/material.dart';
6 | import 'package:instagram_flutter/models/user.dart' as model;
7 | import 'package:instagram_flutter/resources/storage_methods.dart';
8 |
9 | class AuthMethods{
10 | final FirebaseAuth _auth= FirebaseAuth.instance;
11 | final FirebaseFirestore _firestore =FirebaseFirestore.instance;
12 |
13 | Future getUserDetails() async{
14 | User currentUser=_auth.currentUser!;
15 |
16 | DocumentSnapshot snap=await _firestore.collection('users').doc(currentUser.uid).get();
17 |
18 | return model.User.fromSnap(snap);
19 |
20 | }
21 |
22 | //sign up the user
23 | Future signUpUser({
24 | required String email,
25 | required String password,
26 | required String username,
27 | required String bio,
28 | required Uint8List file,
29 | }) async {
30 | String res="Some error occured";
31 | try{
32 | if(email.isNotEmpty || password.isNotEmpty ||username.isNotEmpty || bio.isNotEmpty || file!=null){
33 | //register user
34 | UserCredential cred= await _auth.createUserWithEmailAndPassword(email: email, password: password);
35 | print(cred.user!.uid);
36 |
37 | String photoUrl= await StorageMethods().uploadImageToStorage('profilePics', file, false);
38 | //add user to our database
39 |
40 | model.User user= model.User(email: email, photoUrl: photoUrl, uid: cred.user!.uid
41 | , bio: bio, username: username, followers: [], following: []);
42 |
43 | await _firestore.collection('users').doc(cred.user!.uid).set(user.toJson(),);
44 | // await _firestore.collection('users').add({
45 | // 'username':username,
46 | // 'uid':cred.user!.uid,
47 | // 'email':email,
48 | // 'bio':bio,
49 | // 'followers':[],
50 | // 'following':[],
51 | // });
52 | res ="success";
53 |
54 | }
55 | }
56 | catch(err){
57 | res= err.toString();
58 | }
59 | return res;
60 | }
61 |
62 | Future loginUser({
63 | required String email,
64 | required String password
65 | }) async {
66 | String res="Some error occured";
67 | try{
68 | if(email.isNotEmpty || password.isNotEmpty){
69 | await _auth.signInWithEmailAndPassword(email: email, password: password);
70 | res="success";
71 | }else{
72 | res="Please enter alll the field";
73 | }
74 |
75 | }
76 | catch(err){
77 | res=err.toString();
78 | }
79 | return res;
80 | }
81 |
82 | Future signout()async{
83 | await _auth.signOut();
84 | }
85 |
86 | }
--------------------------------------------------------------------------------
/lib/resources/firestore_methods.dart:
--------------------------------------------------------------------------------
1 |
2 |
3 | import 'dart:typed_data';
4 |
5 | import 'package:cloud_firestore/cloud_firestore.dart';
6 | import 'package:instagram_flutter/models/post.dart';
7 | import 'package:instagram_flutter/resources/storage_methods.dart';
8 | import 'package:uuid/uuid.dart';
9 |
10 | class FirestoreMethods{
11 | final FirebaseFirestore _firestore=FirebaseFirestore.instance;
12 |
13 | //upload post
14 | Future uploadPost(
15 | String description,
16 | Uint8List file,
17 | String uid,
18 | String username,
19 | String profImage,
20 | )async{
21 | String res="some error occurred";
22 | try{
23 | String photoUrl=await StorageMethods().uploadImageToStorage('posts', file, true);
24 | String postId= const Uuid().v1();
25 |
26 | Post post=Post(username: username, description: description, uid: uid,
27 | postId: postId, postUrl: photoUrl, profImage: profImage,
28 | likes: [], datePublished: DateTime.now());
29 |
30 | _firestore.collection('posts').doc(postId).set(post.toJson());
31 | res="success";
32 |
33 | }catch(err){
34 | res=err.toString();
35 | }
36 | return res;
37 | }
38 |
39 | Future likepost(String postId,String uid,List likes)async{
40 | try{
41 | if(likes.contains(uid)){
42 | await _firestore.collection('posts').doc(postId).update({
43 | 'likes':FieldValue.arrayRemove([uid]),
44 | });
45 | }else{
46 | await _firestore.collection('posts').doc(postId).update({
47 | 'likes':FieldValue.arrayUnion([uid]),
48 | });
49 | }
50 | }catch(e){
51 | print(e.toString());
52 | }
53 | }
54 |
55 | Future postComment(String postId,String text,String uid,String name,String profilePic)async{
56 | try{
57 | if(text.isNotEmpty){
58 | String commentId = Uuid().v1();
59 | await _firestore.collection('posts').doc(postId).collection('comments').doc(commentId).set({
60 | 'profilePic':profilePic,
61 | 'name':name,
62 | 'uid':uid,
63 | 'text':text,
64 | 'commentId':commentId,
65 | 'datePublished': DateTime.now(),
66 |
67 | });
68 | }
69 | else{
70 | print('Text is empty');
71 | }
72 | }catch(e){
73 | print(e.toString());
74 | }
75 | }
76 |
77 | Future deletePost(String postId) async {
78 | try{
79 | await _firestore.collection('posts').doc(postId).delete();
80 | }catch(err){
81 | print(err.toString());
82 | }
83 | }
84 |
85 | Future followUser(String uid,String followId)async{
86 | try{
87 | DocumentSnapshot snap= await _firestore.collection('users').doc(uid).get();
88 | List following =(snap.data()! as dynamic)['following'];
89 |
90 | if(following.contains(followId)){
91 | await _firestore.collection('users').doc(followId).update({
92 | 'followers': FieldValue.arrayRemove([uid])
93 | });
94 |
95 | await _firestore.collection('users').doc(uid).update({
96 | 'following': FieldValue.arrayRemove([followId])
97 | });
98 | }else{
99 | await _firestore.collection('users').doc(followId).update({
100 | 'followers': FieldValue.arrayUnion([uid])
101 | });
102 |
103 | await _firestore.collection('users').doc(uid).update({
104 | 'following': FieldValue.arrayUnion([followId])
105 | });
106 | }
107 |
108 |
109 | }catch(e){
110 | print(e.toString());
111 | }
112 | }
113 |
114 | }
--------------------------------------------------------------------------------
/lib/resources/storage_methods.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | import 'package:firebase_auth/firebase_auth.dart';
4 | import 'package:firebase_storage/firebase_storage.dart';
5 | import 'package:flutter/material.dart';
6 | import 'package:uuid/uuid.dart';
7 |
8 | class StorageMethods{
9 | final FirebaseStorage _storage = FirebaseStorage.instance;
10 | final FirebaseAuth _auth=FirebaseAuth.instance;
11 |
12 | Future uploadImageToStorage(String childName,Uint8List file,bool isPost) async {
13 | Reference ref= _storage.ref().child(childName).child(_auth.currentUser!.uid);
14 |
15 | if(isPost){
16 | String id=const Uuid().v1();
17 | ref=ref.child(id);
18 | }
19 |
20 |
21 | UploadTask uploadTask= ref.putData(file);
22 |
23 | TaskSnapshot snap= await uploadTask;
24 | String downloadUrl= await snap.ref.getDownloadURL();
25 | return downloadUrl;
26 |
27 | }
28 | }
--------------------------------------------------------------------------------
/lib/responsive/mobile_screen_layout.dart:
--------------------------------------------------------------------------------
1 |
2 | import 'package:flutter/cupertino.dart';
3 | import 'package:flutter/material.dart';
4 | import 'package:instagram_flutter/utils/colors.dart';
5 | import 'package:instagram_flutter/utils/global_variables.dart';
6 |
7 |
8 | class MobileScreenLayout extends StatefulWidget{
9 | const MobileScreenLayout({Key? key}):super(key:key);
10 |
11 |
12 |
13 |
14 |
15 | @override
16 | State createState() {
17 |
18 | return _MobileScreenLayoutState();
19 |
20 |
21 | }
22 |
23 | }
24 |
25 | class _MobileScreenLayoutState extends State {
26 | int _page=0;
27 | late PageController pageController;
28 |
29 | @override
30 | void initState() {
31 | // TODO: implement initState
32 | super.initState();
33 | pageController= PageController();
34 |
35 |
36 | }
37 |
38 | @override
39 | void dispose() {
40 | // TODO: implement dispose
41 | super.dispose();
42 | pageController.dispose();
43 | }
44 |
45 | void navigationTapped(int page){
46 | pageController.jumpToPage(page);
47 | }
48 |
49 | void onPageChanged(int page){
50 | setState(() {
51 | _page=page;
52 | });
53 | }
54 |
55 | @override
56 | Widget build(BuildContext context) {
57 |
58 | // TODO: implement build
59 | return Scaffold(
60 | body:PageView(
61 | children: homeScreenItems,
62 | physics: const NeverScrollableScrollPhysics(),
63 | controller: pageController,
64 | onPageChanged: onPageChanged,
65 | ),
66 | bottomNavigationBar: CupertinoTabBar(
67 | backgroundColor: mobileBackgroundColor,
68 | items: [
69 | BottomNavigationBarItem(icon: Icon(Icons.home,
70 | color: _page==0? primaryColor: secondaryColor,),
71 | label: '',
72 | backgroundColor: primaryColor,
73 | ),
74 | BottomNavigationBarItem(icon: Icon(Icons.search,
75 | color: _page==1? primaryColor: secondaryColor,),
76 | label: '',
77 | backgroundColor: primaryColor,
78 | ),
79 | BottomNavigationBarItem(icon: Icon(Icons.add_circle,
80 | color: _page==2? primaryColor: secondaryColor,),
81 | label: '',
82 | backgroundColor: primaryColor,
83 | ),
84 | BottomNavigationBarItem(icon: Icon(Icons.favorite,
85 | color: _page==3? primaryColor: secondaryColor,),
86 | label: '',
87 | backgroundColor: primaryColor,
88 | ),
89 | BottomNavigationBarItem(icon: Icon(Icons.person
90 | ,color: _page==4? primaryColor: secondaryColor,),
91 | label: '',
92 | backgroundColor: primaryColor,
93 | ),
94 | ],
95 | onTap: navigationTapped,
96 | ),
97 | );
98 | }
99 |
100 | }
--------------------------------------------------------------------------------
/lib/responsive/responsive_layout_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:instagram_flutter/providers/user_provider.dart';
3 | import 'package:instagram_flutter/utils/global_variables.dart';
4 | import 'package:provider/provider.dart';
5 |
6 |
7 |
8 | class ResponsiveLayout extends StatefulWidget{
9 | final Widget webScreenLayout;
10 | final Widget mobileScreenLayout;
11 | const ResponsiveLayout({Key? key,
12 | required this.webScreenLayout,
13 | required this.mobileScreenLayout,
14 | }):super(key:key);
15 |
16 | @override
17 | State createState() => _ResponsiveLayoutState();
18 | }
19 |
20 | class _ResponsiveLayoutState extends State {
21 | @override
22 | void initState() {
23 | // TODO: implement initState
24 | super.initState();
25 | addData();
26 | }
27 | addData() async{
28 | UserProvider _userProvider= Provider.of(context,listen:false);
29 | await _userProvider.refreshUser();
30 |
31 | }
32 |
33 | @override
34 | Widget build(BuildContext context) {
35 | // TODO: implement build
36 | return LayoutBuilder(
37 | builder: (context,constraints){
38 | if(constraints.maxWidth>webScreenSize){
39 | return widget.webScreenLayout;
40 | }
41 | return widget.mobileScreenLayout;
42 | },
43 | );
44 | }
45 | }
--------------------------------------------------------------------------------
/lib/responsive/web_screen_layout.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_svg/flutter_svg.dart';
3 | import 'package:instagram_flutter/utils/colors.dart';
4 | import 'package:instagram_flutter/utils/global_variables.dart';
5 |
6 | class WebScreenLayout extends StatefulWidget {
7 | const WebScreenLayout({Key? key}) : super(key: key);
8 |
9 | @override
10 | State createState() => _WebScreenLayoutState();
11 | }
12 |
13 | class _WebScreenLayoutState extends State {
14 | int _page=0;
15 | late PageController pageController;
16 |
17 | @override
18 | void initState() {
19 | // TODO: implement initState
20 | super.initState();
21 | pageController= PageController();
22 |
23 |
24 | }
25 |
26 | @override
27 | void dispose() {
28 | // TODO: implement dispose
29 | super.dispose();
30 | pageController.dispose();
31 | }
32 |
33 | void navigationTapped(int page){
34 | pageController.jumpToPage(page);
35 | setState(() {
36 | _page=page;
37 | });
38 | }
39 |
40 | void onPageChanged(int page){
41 | setState(() {
42 | _page=page;
43 | });
44 | }
45 |
46 | @override
47 | Widget build(BuildContext context) {
48 | // TODO: implement build
49 | return Scaffold(
50 | appBar: AppBar(
51 | backgroundColor: mobileBackgroundColor,
52 | centerTitle: false,
53 | title: SvgPicture.asset(
54 | 'assets/ic_instagram.svg',
55 | color: primaryColor,
56 | height: 32,
57 | ),
58 | actions: [
59 | IconButton(
60 | onPressed: ()=>navigationTapped(0),
61 | icon: Icon(Icons.home,
62 | color: _page == 0? primaryColor:secondaryColor,
63 | ),
64 | ),
65 | IconButton(
66 | onPressed: () =>navigationTapped(1),
67 | icon: Icon(Icons.search,
68 | color: _page == 1? primaryColor:secondaryColor,),
69 | ),
70 | IconButton(
71 | onPressed: ()=>navigationTapped(2),
72 | icon: Icon(Icons.add_a_photo,
73 | color: _page == 2? primaryColor:secondaryColor,),
74 | ),
75 | IconButton(
76 | onPressed: ()=>navigationTapped(3),
77 | icon: Icon(Icons.favorite,
78 | color: _page == 3? primaryColor:secondaryColor,),
79 | ),
80 | IconButton(
81 | onPressed: ()=>navigationTapped(4),
82 | icon: Icon(Icons.person,
83 | color: _page == 4? primaryColor:secondaryColor,),
84 | ),
85 | ],
86 | ),
87 | body: PageView(
88 | physics: const NeverScrollableScrollPhysics(),
89 | children: homeScreenItems,
90 | controller: pageController,
91 | onPageChanged: onPageChanged,
92 | )
93 | );
94 | }
95 | }
96 |
--------------------------------------------------------------------------------
/lib/screens/add_post_screen.dart:
--------------------------------------------------------------------------------
1 |
2 |
3 | import 'package:cloud_firestore/cloud_firestore.dart';
4 | import 'package:flutter/foundation.dart';
5 | import 'package:flutter/material.dart';
6 | import 'package:image_picker/image_picker.dart';
7 | import 'package:instagram_flutter/models/user.dart';
8 | import 'package:instagram_flutter/providers/user_provider.dart';
9 | import 'package:instagram_flutter/resources/firestore_methods.dart';
10 | import 'package:instagram_flutter/utils/colors.dart';
11 | import 'package:instagram_flutter/utils/utils.dart';
12 | import 'package:provider/provider.dart';
13 |
14 | class AddPostScreen extends StatefulWidget {
15 | const AddPostScreen({Key? key}) : super(key: key);
16 |
17 | @override
18 | State createState() => _AddPostScreenState();
19 | }
20 |
21 | class _AddPostScreenState extends State {
22 | Uint8List? _file;
23 | final TextEditingController _descriptionController = TextEditingController();
24 | bool _isLoading=false;
25 |
26 | void postImage(
27 | String uid,
28 | String username,
29 | String profImage,
30 | ) async {
31 | setState(() {
32 | _isLoading=true;
33 | });
34 | try {
35 | String res = await FirestoreMethods().uploadPost(
36 | _descriptionController.text, _file!, uid, username, profImage);
37 | if (res == 'success') {
38 | setState(() {
39 | _isLoading=false;
40 | });
41 |
42 | showSnackBar('Posted!', context);
43 | clearImage();
44 | } else {
45 | setState(() {
46 | _isLoading=false;
47 | });
48 | showSnackBar(res, context);
49 | }
50 | } catch (e) {
51 | showSnackBar(e.toString(), context);
52 | }
53 | }
54 |
55 | _selectImage(BuildContext context) async {
56 | return showDialog(
57 | context: context,
58 | builder: (context) {
59 | return SimpleDialog(
60 | title: Text("Create a post"),
61 | children: [
62 | SimpleDialogOption(
63 | padding: EdgeInsets.all(20),
64 | child: Text('Take a photo'),
65 | onPressed: () async {
66 | Navigator.of(context).pop();
67 | Uint8List file = await pickImage(ImageSource.camera);
68 | setState(() {
69 | _file = file;
70 | });
71 | },
72 | ),
73 | SimpleDialogOption(
74 | padding: EdgeInsets.all(20),
75 | child: Text('Choose from gallery'),
76 | onPressed: () async {
77 | Navigator.of(context).pop();
78 | Uint8List file = await pickImage(ImageSource.gallery);
79 | setState(() {
80 | _file = file;
81 | });
82 | },
83 | ),
84 | SimpleDialogOption(
85 | padding: EdgeInsets.all(20),
86 | child: Text('Cancel'),
87 | onPressed: () {
88 | Navigator.of(context).pop();
89 | },
90 | ),
91 | ],
92 | );
93 | });
94 | }
95 | void clearImage(){
96 | setState(() {
97 | _file=null;
98 | });
99 | }
100 |
101 | @override
102 | void dispose() {
103 | // TODO: implement dispose
104 | super.dispose();
105 | _descriptionController.dispose();
106 | }
107 |
108 | @override
109 | Widget build(BuildContext context) {
110 | final User user = Provider.of(context).getUser;
111 |
112 | return _file == null
113 | ? Center(
114 | child: IconButton(
115 | icon: Icon(Icons.upload),
116 | onPressed: () {
117 | return _selectImage(context);
118 | },
119 | ),
120 | )
121 | : Scaffold(
122 | appBar: AppBar(
123 | backgroundColor: mobileBackgroundColor,
124 | leading: IconButton(
125 | onPressed: clearImage,
126 | icon: const Icon(Icons.arrow_back),
127 | ),
128 | title: const Text("Post to"),
129 | centerTitle: false,
130 | actions: [
131 | TextButton(
132 | onPressed: ()=>postImage(user.uid, user.username, user.photoUrl),
133 | child: const Text(
134 | "Post",
135 | style: TextStyle(
136 | color: Colors.blueAccent,
137 | fontWeight: FontWeight.bold,
138 | fontSize: 16,
139 | ),
140 | ))
141 | ],
142 | ),
143 | body: Column(
144 | children: [
145 | _isLoading? const LinearProgressIndicator(): const Padding(
146 | padding:EdgeInsets.only(top:0) ),
147 | const Divider(),
148 | Row(
149 | mainAxisAlignment: MainAxisAlignment.spaceAround,
150 | crossAxisAlignment: CrossAxisAlignment.start,
151 | children: [
152 | CircleAvatar(
153 | backgroundImage: NetworkImage(user.photoUrl),
154 | ),
155 | SizedBox(
156 | width: MediaQuery.of(context).size.width * 0.45,
157 | child: TextField(
158 | controller: _descriptionController,
159 | decoration: InputDecoration(
160 | hintText: 'Write a caption',
161 | border: InputBorder.none,
162 | ),
163 | maxLines: 8,
164 | ),
165 | ),
166 | SizedBox(
167 | height: 45,
168 | width: 45,
169 | child: AspectRatio(
170 | aspectRatio: 487 / 451,
171 | child: Container(
172 | decoration: BoxDecoration(
173 | image: DecorationImage(
174 | image: MemoryImage(_file!),
175 | fit: BoxFit.fill,
176 | alignment: FractionalOffset.topCenter,
177 | ),
178 | ),
179 | ),
180 | ),
181 | ),
182 | const Divider(),
183 | ],
184 | ),
185 | ],
186 | ),
187 | );
188 | }
189 | }
190 |
--------------------------------------------------------------------------------
/lib/screens/comments_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:instagram_flutter/models/user.dart';
4 | import 'package:instagram_flutter/providers/user_provider.dart';
5 | import 'package:instagram_flutter/resources/firestore_methods.dart';
6 | import 'package:instagram_flutter/utils/colors.dart';
7 | import 'package:instagram_flutter/widgets/comment_card.dart';
8 | import 'package:provider/provider.dart';
9 |
10 | class CommentsScreen extends StatefulWidget {
11 | final snap;
12 | const CommentsScreen({Key? key, required this.snap}) : super(key: key);
13 |
14 | @override
15 | State createState() => _CommentsScreenState();
16 | }
17 |
18 | class _CommentsScreenState extends State {
19 | final TextEditingController _commentController = TextEditingController();
20 |
21 | @override
22 | void dispose() {
23 | // TODO: implement dispose
24 | super.dispose();
25 | _commentController.dispose();
26 | }
27 |
28 | @override
29 | Widget build(BuildContext context) {
30 | final User user = Provider.of(context).getUser;
31 | return Scaffold(
32 | appBar: AppBar(
33 | backgroundColor: mobileBackgroundColor,
34 | title: const Text('Comments'),
35 | centerTitle: false,
36 | ),
37 | body: StreamBuilder(
38 | stream: FirebaseFirestore.instance
39 | .collection('posts').doc(widget.snap['postId'])
40 | .collection('comments')
41 | .orderBy('datePublished',descending: true,)
42 | .snapshots(),
43 | builder: (context, snapshot){
44 | if(snapshot.connectionState==ConnectionState.waiting){
45 | return const Center(
46 | child: CircularProgressIndicator(),
47 | );
48 | }
49 | return ListView.builder(
50 | itemCount: (snapshot.data! as dynamic).docs.length,
51 | itemBuilder: (context,index)=>
52 | CommentCard(
53 | snap: (snapshot.data! as dynamic).docs[index].data(),
54 | )
55 | );
56 | },
57 | ),
58 | bottomNavigationBar: SafeArea(
59 | child: Container(
60 | height: kToolbarHeight,
61 | margin:
62 | EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
63 | padding: EdgeInsets.only(left: 16, right: 8),
64 | child: Row(
65 | children: [
66 | CircleAvatar(
67 | backgroundImage: NetworkImage(
68 | user.photoUrl,
69 | ),
70 | radius: 18,
71 | ),
72 | Expanded(
73 | child: Padding(
74 | padding: const EdgeInsets.only(left: 16, right: 8),
75 | child: TextField(
76 | controller: _commentController,
77 | decoration: InputDecoration(
78 | hintText: 'Comment as ${user.username}',
79 | border: InputBorder.none,
80 | ),
81 | ),
82 | ),
83 | ),
84 | InkWell(
85 | onTap: () async {
86 | await FirestoreMethods().postComment(
87 | widget.snap['postId'],
88 | _commentController.text,
89 | user.uid,
90 | user.username,
91 | user.photoUrl);
92 | setState(() {
93 | _commentController.text="";
94 |
95 | });
96 | },
97 |
98 | child: Container(
99 | padding:
100 | const EdgeInsets.symmetric(vertical: 8, horizontal: 8),
101 | child: Text(
102 | 'Post',
103 | style: TextStyle(
104 | color: Colors.blueAccent,
105 | ),
106 | ),
107 | ),
108 | )
109 | ],
110 | ),
111 | ),
112 | ),
113 | );
114 | }
115 | }
116 |
--------------------------------------------------------------------------------
/lib/screens/feed_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_svg/flutter_svg.dart';
4 | import 'package:instagram_flutter/utils/colors.dart';
5 | import 'package:instagram_flutter/utils/global_variables.dart';
6 | import 'package:instagram_flutter/widgets/post_card.dart';
7 |
8 | class FeedScreen extends StatelessWidget {
9 | const FeedScreen({Key? key}) : super(key: key);
10 |
11 | @override
12 | Widget build(BuildContext context) {
13 | final width=MediaQuery.of(context).size.width;
14 | return Scaffold(
15 | backgroundColor: width>webScreenSize? webBackgroundColor:mobileBackgroundColor,
16 | appBar: width >webScreenSize?null: AppBar(
17 | backgroundColor: mobileBackgroundColor,
18 | centerTitle: false,
19 | title: SvgPicture.asset(
20 | 'assets/ic_instagram.svg',
21 | color: primaryColor,
22 | height: 32,
23 | ),
24 | actions: [
25 | IconButton(onPressed: (){
26 |
27 | },
28 | icon: Icon(Icons.messenger_outline),
29 | ),
30 | ],
31 | ),
32 | body: StreamBuilder(
33 | stream: FirebaseFirestore.instance.collection('posts').snapshots(),
34 | builder: (context,AsyncSnapshot>> snapshot){
35 | if(snapshot.connectionState==ConnectionState.waiting){
36 | return const Center(
37 | child: CircularProgressIndicator(),
38 | );
39 | }
40 | return ListView.builder(
41 | itemCount: snapshot.data!.docs.length,
42 | itemBuilder: (context,index)=>Container(
43 | margin: EdgeInsets.symmetric(
44 | horizontal: width>webScreenSize?width*0.3:0,
45 | vertical: width>webScreenSize?15:0,
46 | ),
47 | child: PostCard(
48 | snap:snapshot.data!.docs[index].data(),
49 | ),
50 | ));
51 |
52 | },
53 | ),
54 | );
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/lib/screens/home_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class HomeScreen extends StatelessWidget{
4 | const HomeScreen({Key? key}):super(key:key);
5 |
6 | @override
7 | Widget build(BuildContext context) {
8 | // TODO: implement build
9 | return Scaffold(
10 | body: Center(
11 | child: Text('Home Screen'),
12 | ),
13 | );
14 | }
15 |
16 | }
--------------------------------------------------------------------------------
/lib/screens/login_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_svg/flutter_svg.dart';
3 | import 'package:instagram_flutter/resources/auth_methods.dart';
4 | import 'package:instagram_flutter/responsive/mobile_screen_layout.dart';
5 | import 'package:instagram_flutter/responsive/responsive_layout_screen.dart';
6 | import 'package:instagram_flutter/responsive/web_screen_layout.dart';
7 | import 'package:instagram_flutter/screens/signup_screen.dart';
8 | import 'package:instagram_flutter/utils/colors.dart';
9 | import 'package:instagram_flutter/utils/global_variables.dart';
10 | import 'package:instagram_flutter/utils/utils.dart';
11 | import 'package:instagram_flutter/widgets/text_field_input.dart';
12 |
13 | class LoginScreen extends StatefulWidget {
14 | const LoginScreen({Key? key}) : super(key: key);
15 |
16 | @override
17 | _LoginScreenState createState() {
18 | // TODO: implement createState
19 | return _LoginScreenState();
20 | }
21 | }
22 |
23 | class _LoginScreenState extends State {
24 | final TextEditingController _emailController = TextEditingController();
25 | final TextEditingController _passwordController = TextEditingController();
26 | bool _isLoading=false;
27 | @override
28 | void dispose() {
29 | // TODO: implement dispose
30 | super.dispose();
31 | _emailController.dispose();
32 | _passwordController.dispose();
33 | }
34 | Future loginUser() async {
35 | setState(() {
36 | _isLoading=true;
37 | });
38 | String res=await AuthMethods().loginUser(email: _emailController.text
39 | , password: _passwordController.text);
40 | if(res=='success'){
41 | Navigator.of(context).pushReplacement(MaterialPageRoute(builder:
42 | (context)=>const ResponsiveLayout(webScreenLayout: WebScreenLayout()
43 | , mobileScreenLayout: MobileScreenLayout(),),
44 | ),
45 | );
46 | }else{
47 | showSnackBar(res, context);
48 | }
49 | setState(() {
50 | _isLoading=false;
51 | });
52 | }
53 | void navigateToSignup(){
54 | Navigator.of(context).push(MaterialPageRoute(builder: (context)=>SignupScreen()));
55 | }
56 |
57 | @override
58 | Widget build(BuildContext context) {
59 | // TODO: implement build
60 | return Scaffold(
61 | body: SafeArea(
62 | child: Container(
63 | padding: MediaQuery.of(context).size.width>webScreenSize? EdgeInsets.symmetric(
64 | horizontal:MediaQuery.of(context).size.width /3)
65 | :
66 | EdgeInsets.symmetric(horizontal: 32),
67 | width: double.infinity,
68 | child: Column(
69 | crossAxisAlignment: CrossAxisAlignment.center,
70 | children: [
71 | Flexible(
72 | child: Container(),
73 | flex: 2,
74 | ),
75 | SvgPicture.asset(
76 | 'assets/ic_instagram.svg',
77 | color: primaryColor,
78 | height: 64,
79 | ),
80 | const SizedBox(height: 64),
81 | TextFieldInput(
82 | textEditingController: _emailController,
83 | textInputType: TextInputType.emailAddress,
84 | hintText: "Enter Your email"),
85 | const SizedBox(
86 | height: 24,
87 | ),
88 | TextFieldInput(
89 | textEditingController: _passwordController,
90 | textInputType: TextInputType.text,
91 | hintText: "Enter Your password",
92 | isPass: true,
93 | ),
94 | const SizedBox(
95 | height: 24,
96 | ),
97 | InkWell(
98 | onTap: loginUser,
99 | child: Container(
100 | child: _isLoading? Center(child: CircularProgressIndicator(
101 | color: primaryColor,
102 | ),): const Text("Login"),
103 | width: double.infinity,
104 | alignment: Alignment.center,
105 | padding: const EdgeInsets.symmetric(vertical: 12),
106 | decoration: ShapeDecoration(
107 | shape: RoundedRectangleBorder(
108 | borderRadius: BorderRadius.all(
109 | Radius.circular(4),
110 | ),
111 | ),
112 | color: blueColor),
113 | ),
114 | ),
115 | const SizedBox(
116 |
117 | height: 24,
118 | ),
119 | Flexible(
120 | child: Container(),
121 | flex: 2,
122 | ),
123 | Row(
124 | mainAxisAlignment: MainAxisAlignment.center,
125 | children: [
126 | Container(
127 | child: const Text("Don't have an account?"),
128 | padding: const EdgeInsets.symmetric(vertical: 8,),
129 | ),
130 | GestureDetector(
131 | onTap: navigateToSignup,
132 | child: Container(
133 | child: const Text("Sign up",
134 | style: TextStyle(
135 | fontWeight: FontWeight.bold
136 | ),
137 | ),
138 | padding: const EdgeInsets.symmetric(vertical: 8,),
139 | ),
140 | )
141 | ],
142 | ),
143 | ],
144 | ),
145 | ),
146 | ),
147 | );
148 | }
149 | }
150 |
--------------------------------------------------------------------------------
/lib/screens/profile_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:firebase_auth/firebase_auth.dart';
3 | import 'package:flutter/material.dart';
4 | import 'package:instagram_flutter/resources/auth_methods.dart';
5 | import 'package:instagram_flutter/resources/firestore_methods.dart';
6 | import 'package:instagram_flutter/screens/login_screen.dart';
7 | import 'package:instagram_flutter/utils/colors.dart';
8 | import 'package:instagram_flutter/utils/utils.dart';
9 | import 'package:instagram_flutter/widgets/follow_button.dart';
10 |
11 | class ProfileScreen extends StatefulWidget {
12 | final String uid;
13 |
14 | const ProfileScreen({Key? key, required this.uid}) : super(key: key);
15 |
16 | @override
17 | State createState() => _ProfileScreenState();
18 | }
19 |
20 | class _ProfileScreenState extends State {
21 | var userData = {};
22 | int postLen = 0;
23 | int followers = 0;
24 | int following = 0;
25 | bool isFollowing = false;
26 | bool isLoading = false;
27 | @override
28 | void initState() {
29 | // TODO: implement initState
30 | super.initState();
31 | getData();
32 | }
33 |
34 | getData() async {
35 | setState(() {
36 | isLoading = true;
37 | });
38 | try {
39 | var userSnap = await FirebaseFirestore.instance
40 | .collection('users')
41 | .doc(widget.uid)
42 | .get();
43 | var postSnap = await FirebaseFirestore.instance
44 | .collection('posts')
45 | .where('uid', isEqualTo: FirebaseAuth.instance.currentUser!.uid)
46 | .get();
47 |
48 | postLen = postSnap.docs.length;
49 | userData = userSnap.data()!;
50 | followers = userSnap.data()!['followers'].length;
51 | following = userSnap.data()!['following'].length;
52 | isFollowing = userSnap
53 | .data()!['followers']
54 | .contains(FirebaseAuth.instance.currentUser!.uid);
55 | setState(() {});
56 | } catch (e) {
57 | showSnackBar(e.toString(), context);
58 | }
59 | setState(() {
60 | isLoading = false;
61 | });
62 | }
63 |
64 | @override
65 | Widget build(BuildContext context) {
66 | return isLoading
67 | ? const Center(
68 | child: CircularProgressIndicator(),
69 | )
70 | : Scaffold(
71 | appBar: AppBar(
72 | backgroundColor: mobileBackgroundColor,
73 | title: Text(userData['username']),
74 | centerTitle: false,
75 | ),
76 | body: ListView(
77 | children: [
78 | Padding(
79 | padding: const EdgeInsets.all(16.0),
80 | child: Column(
81 | children: [
82 | Row(
83 | children: [
84 | CircleAvatar(
85 | backgroundColor: Colors.grey,
86 | radius: 40,
87 | backgroundImage: NetworkImage(userData['photoUrl']),
88 | ),
89 | Expanded(
90 | flex: 1,
91 | child: Column(
92 | children: [
93 | Row(
94 | mainAxisSize: MainAxisSize.max,
95 | mainAxisAlignment:
96 | MainAxisAlignment.spaceEvenly,
97 | children: [
98 | buildStatColumn(postLen, 'posts'),
99 | buildStatColumn(followers, 'followers'),
100 | buildStatColumn(following, 'following'),
101 | ],
102 | ),
103 | Row(
104 | mainAxisAlignment:
105 | MainAxisAlignment.spaceEvenly,
106 | children: [
107 | FirebaseAuth.instance.currentUser!.uid ==
108 | widget.uid
109 | ? FollowButton(
110 | backgroundColor:
111 | mobileBackgroundColor,
112 | borderColor: Colors.grey,
113 | text: 'Sign Out',
114 | textColor: primaryColor,
115 | function: () async {
116 | await AuthMethods().signout();
117 | Navigator.of(context)
118 | .pushReplacement(
119 | MaterialPageRoute(
120 | builder: (context) =>
121 | const LoginScreen(),
122 | ),
123 | );
124 | },
125 | )
126 | : isFollowing
127 | ? FollowButton(
128 | backgroundColor: Colors.white,
129 | borderColor: Colors.grey,
130 | text: 'Unfollow',
131 | textColor: Colors.black,
132 | function: () async {
133 | await FirestoreMethods()
134 | .followUser(
135 | FirebaseAuth.instance
136 | .currentUser!.uid,
137 | userData['uid']);
138 | setState(() {
139 | isFollowing = false;
140 | followers--;
141 | });
142 | },
143 | )
144 | : FollowButton(
145 | backgroundColor: Colors.blue,
146 | borderColor: Colors.blue,
147 | text: 'Follow',
148 | textColor: Colors.white,
149 | function: () async {
150 | await FirestoreMethods()
151 | .followUser(
152 | FirebaseAuth.instance
153 | .currentUser!.uid,
154 | userData['uid']);
155 | setState(() {
156 | isFollowing = true;
157 | followers++;
158 | });
159 | },
160 | )
161 | ],
162 | )
163 | ],
164 | ),
165 | ),
166 | ],
167 | ),
168 | Container(
169 | alignment: Alignment.centerLeft,
170 | padding: const EdgeInsets.only(top: 15),
171 | child: Text(
172 | userData['username'],
173 | style: TextStyle(
174 | fontWeight: FontWeight.bold,
175 | ),
176 | ),
177 | ),
178 | Container(
179 | alignment: Alignment.centerLeft,
180 | padding: const EdgeInsets.only(top: 1),
181 | child: Text(
182 | userData['bio'],
183 | ),
184 | ),
185 | ],
186 | ),
187 | ),
188 | const Divider(),
189 | FutureBuilder(
190 | future: FirebaseFirestore.instance
191 | .collection('posts')
192 | .where('uid', isEqualTo: widget.uid)
193 | .get(),
194 | builder: (context, snapshot) {
195 | if (snapshot.connectionState == ConnectionState.waiting) {
196 | return const Center(
197 | child: CircularProgressIndicator(),
198 | );
199 | }
200 | return GridView.builder(
201 | shrinkWrap: true,
202 | itemCount: (snapshot.data! as dynamic).docs.length,
203 | gridDelegate:
204 | SliverGridDelegateWithFixedCrossAxisCount(
205 | crossAxisCount: 3,
206 | crossAxisSpacing: 5,
207 | mainAxisSpacing: 1.5,
208 | childAspectRatio: 1),
209 | itemBuilder: (context, index) {
210 | DocumentSnapshot snap =
211 | (snapshot.data! as dynamic).docs[index];
212 | return Container(
213 | child: Image(
214 | image: NetworkImage(
215 | (snap.data()! as dynamic)['postUrl'],
216 | ),
217 | fit: BoxFit.cover,
218 | ),
219 | );
220 | });
221 | }),
222 | ],
223 | ),
224 | );
225 | }
226 |
227 | Column buildStatColumn(int num, String label) {
228 | return Column(
229 | mainAxisSize: MainAxisSize.min,
230 | mainAxisAlignment: MainAxisAlignment.center,
231 | children: [
232 | Text(
233 | num.toString(),
234 | style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
235 | ),
236 | Container(
237 | margin: EdgeInsets.only(top: 4),
238 | child: Text(
239 | label.toString(),
240 | style: const TextStyle(
241 | fontSize: 15, fontWeight: FontWeight.w400, color: Colors.grey),
242 | ),
243 | ),
244 | ],
245 | );
246 | }
247 | }
248 |
--------------------------------------------------------------------------------
/lib/screens/search_screen.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
4 | import 'package:instagram_flutter/screens/profile_screen.dart';
5 | import 'package:instagram_flutter/utils/colors.dart';
6 | import 'package:instagram_flutter/utils/global_variables.dart';
7 |
8 | class SearchScreen extends StatefulWidget {
9 | const SearchScreen({Key? key}) : super(key: key);
10 |
11 | @override
12 | State createState() => _SearchScreenState();
13 | }
14 |
15 | class _SearchScreenState extends State {
16 | final TextEditingController searchController = TextEditingController();
17 | bool isShowUsers = false;
18 | @override
19 | void dispose() {
20 | // TODO: implement dispose
21 | super.dispose();
22 | searchController.dispose();
23 | }
24 |
25 | @override
26 | Widget build(BuildContext context) {
27 | return Scaffold(
28 | appBar: AppBar(
29 | backgroundColor: mobileBackgroundColor,
30 | title: TextFormField(
31 | controller: searchController,
32 | decoration: InputDecoration(
33 | labelText: 'Search for a user',
34 | ),
35 | onFieldSubmitted: (String _) {
36 | setState(() {
37 | isShowUsers = true;
38 | });
39 | },
40 | ),
41 | ),
42 | body: isShowUsers
43 | ? FutureBuilder(
44 | future: FirebaseFirestore.instance
45 | .collection('users')
46 | .where('username',
47 | isGreaterThanOrEqualTo: searchController.text)
48 | .get(),
49 | builder: (context, snapshot) {
50 | if (!snapshot.hasData) {
51 | return const Center(
52 | child: CircularProgressIndicator(),
53 | );
54 | }
55 | return ListView.builder(
56 | itemCount: (snapshot.data! as dynamic).docs.length,
57 | itemBuilder: (context, index) {
58 | return InkWell(
59 | onTap: () => Navigator.of(context).push(
60 | MaterialPageRoute(
61 | builder: (context) => ProfileScreen(
62 | uid: (snapshot.data! as dynamic)
63 | .docs[index]['uid']))),
64 | child: ListTile(
65 | leading: CircleAvatar(
66 | backgroundImage: NetworkImage(
67 | (snapshot.data! as dynamic).docs[index]
68 | ['photoUrl']),
69 | ),
70 | title: Text((snapshot.data! as dynamic).docs[index]
71 | ['username']),
72 | ),
73 | );
74 | });
75 | },
76 | )
77 | : FutureBuilder(
78 | future: FirebaseFirestore.instance.collection('posts').get(),
79 | builder: (context, snapshot) {
80 | if (!snapshot.hasData) {
81 | return const Center(child: CircularProgressIndicator());
82 | }
83 | return StaggeredGridView.countBuilder(
84 | crossAxisCount: 3,
85 | itemCount: (snapshot.data! as dynamic).docs.length,
86 | itemBuilder: (context, index) => Image.network(
87 | (snapshot.data! as dynamic).docs[index]['postUrl']),
88 | staggeredTileBuilder: (index) => MediaQuery.of(context)
89 | .size.width>webScreenSize? StaggeredTile.count(
90 | (index % 7 == 0) ? 1 : 1, (index % 7 == 0) ? 1 : 1): StaggeredTile.count(
91 | (index % 7 == 0) ? 2 : 1, (index % 7 == 0) ? 2 : 1),
92 | mainAxisSpacing: 8,
93 | crossAxisSpacing: 8,
94 | );
95 | }));
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/lib/screens/signup_screen.dart:
--------------------------------------------------------------------------------
1 | import 'dart:typed_data';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_svg/flutter_svg.dart';
5 | import 'package:image_picker/image_picker.dart';
6 | import 'package:instagram_flutter/resources/auth_methods.dart';
7 | import 'package:instagram_flutter/responsive/mobile_screen_layout.dart';
8 | import 'package:instagram_flutter/responsive/responsive_layout_screen.dart';
9 | import 'package:instagram_flutter/responsive/web_screen_layout.dart';
10 | import 'package:instagram_flutter/utils/colors.dart';
11 | import 'package:instagram_flutter/utils/utils.dart';
12 | import 'package:instagram_flutter/widgets/text_field_input.dart';
13 | Uint8List? _image;
14 | bool _isLoading=false;
15 | class SignupScreen extends StatefulWidget {
16 | const SignupScreen({Key? key}) : super(key: key);
17 |
18 | @override
19 | _SignupScreenState createState() {
20 | // TODO: implement createState
21 | return _SignupScreenState();
22 | }
23 | }
24 |
25 | class _SignupScreenState extends State {
26 | final TextEditingController _emailController = TextEditingController();
27 | final TextEditingController _passwordController = TextEditingController();
28 | final TextEditingController _bioController = TextEditingController();
29 | final TextEditingController _usernameController = TextEditingController();
30 |
31 |
32 | @override
33 | void dispose() {
34 | // TODO: implement dispose
35 | super.dispose();
36 | _emailController.dispose();
37 | _passwordController.dispose();
38 | _bioController.dispose();
39 | _usernameController.dispose();
40 | }
41 | Future selectImage() async {
42 | Uint8List im= await pickImage(ImageSource.gallery);
43 | setState(() {
44 | _image=im;
45 | });
46 | }
47 |
48 | Future signUpUser() async {
49 | setState(() {
50 | _isLoading=true;
51 | });
52 | String res= await AuthMethods().signUpUser(email: _emailController.text,
53 | password: _passwordController.text,
54 | username: _usernameController.text,
55 | bio: _bioController.text,
56 | file: _image!,);
57 | setState(() {
58 | _isLoading=false;
59 | });
60 | if(res!='success'){
61 | showSnackBar(res , context);
62 | }else{
63 | Navigator.of(context).pushReplacement(MaterialPageRoute(builder:
64 | (context)=>const ResponsiveLayout(webScreenLayout: WebScreenLayout()
65 | , mobileScreenLayout: MobileScreenLayout(),),
66 | ),
67 | );
68 | }
69 | }
70 | void navigateToLogin(){
71 | Navigator.of(context).push(MaterialPageRoute(builder: (context)=>SignupScreen()));
72 |
73 | }
74 |
75 | @override
76 | Widget build(BuildContext context) {
77 | // TODO: implement build
78 | return Scaffold(
79 |
80 | body: SafeArea(
81 | child: SingleChildScrollView(
82 | child: Container(
83 |
84 | padding: EdgeInsets.symmetric(horizontal: 32),
85 | width: double.infinity,
86 | child: Column(
87 | crossAxisAlignment: CrossAxisAlignment.center,
88 | children: [
89 | const SizedBox(height: 64),
90 | SvgPicture.asset(
91 | 'assets/ic_instagram.svg',
92 | color: primaryColor,
93 | height: 64,
94 | ),
95 | const SizedBox(height: 64),
96 | Stack(
97 | children: [
98 | _image!=null?CircleAvatar(
99 | radius: 64,
100 | backgroundImage: MemoryImage(_image!),
101 | ):
102 | CircleAvatar(
103 | radius: 64,
104 | backgroundImage:
105 | NetworkImage('https://t3.ftcdn.net/jpg/00/64/67/80/360_F_64678017_zUpiZFjj04cnLri7oADnyMH0XBYyQghG.jpg'),
106 | ),
107 | Positioned(
108 | bottom: -10,
109 | left: 80,
110 | child:
111 | IconButton(onPressed: selectImage,
112 | icon: Icon(Icons.add_a_photo),))
113 | ],
114 | ),
115 | const SizedBox(height: 24),
116 | TextFieldInput(
117 | textEditingController: _usernameController,
118 | textInputType: TextInputType.text,
119 | hintText: "Enter Your username"),
120 | const SizedBox(
121 | height: 24,
122 | ),
123 | TextFieldInput(
124 | textEditingController: _emailController,
125 | textInputType: TextInputType.emailAddress,
126 | hintText: "Enter Your email"),
127 | const SizedBox(
128 | height: 24,
129 | ),
130 | TextFieldInput(
131 | textEditingController: _passwordController,
132 | textInputType: TextInputType.text,
133 | hintText: "Enter Your password",
134 | isPass: true,
135 | ),
136 | const SizedBox(
137 | height: 24,
138 | ),
139 | TextFieldInput(
140 | textEditingController: _bioController,
141 | textInputType: TextInputType.text,
142 | hintText: "Enter Your bio"),
143 | const SizedBox(
144 | height: 24,
145 | ),
146 |
147 | InkWell(
148 | onTap:signUpUser,
149 | child: Container(
150 | child: _isLoading? const Center(child: CircularProgressIndicator(
151 | color: primaryColor,
152 | ),) :const Text("Sign up"),
153 | width: double.infinity,
154 | alignment: Alignment.center,
155 | padding: const EdgeInsets.symmetric(vertical: 12),
156 | decoration: ShapeDecoration(
157 | shape: RoundedRectangleBorder(
158 | borderRadius: BorderRadius.all(
159 | Radius.circular(4),
160 | ),
161 | ),
162 | color: blueColor),
163 | ),
164 | ),
165 | const SizedBox(
166 |
167 | height: 24,
168 | ),
169 | const SizedBox(height: 64),
170 | Row(
171 | mainAxisAlignment: MainAxisAlignment.center,
172 | children: [
173 | Container(
174 | child: const Text("Already have an account?"),
175 | padding: const EdgeInsets.symmetric(vertical: 8,),
176 | ),
177 | GestureDetector(
178 | onTap: navigateToLogin,
179 | child: Container(
180 | child: const Text("Login",
181 | style: TextStyle(
182 | fontWeight: FontWeight.bold
183 | ),
184 | ),
185 | padding: const EdgeInsets.symmetric(vertical: 8,),
186 | ),
187 | )
188 | ],
189 | ),
190 | ],
191 | ),
192 | ),
193 | ),
194 | ),
195 | );
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/lib/utils/colors.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | const mobileBackgroundColor = Color.fromRGBO(0, 0, 0, 1);
4 | const webBackgroundColor = Color.fromRGBO(18, 18, 18, 1);
5 | const mobileSearchColor = Color.fromRGBO(38, 38, 38, 1);
6 | const blueColor = Color.fromRGBO(0, 149, 246, 1);
7 | const primaryColor = Colors.white;
8 | const secondaryColor = Colors.grey;
--------------------------------------------------------------------------------
/lib/utils/global_variables.dart:
--------------------------------------------------------------------------------
1 | import 'package:firebase_auth/firebase_auth.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:instagram_flutter/screens/add_post_screen.dart';
4 | import 'package:instagram_flutter/screens/feed_screen.dart';
5 | import 'package:instagram_flutter/screens/profile_screen.dart';
6 | import 'package:instagram_flutter/screens/search_screen.dart';
7 |
8 | const webScreenSize=600;
9 |
10 | List homeScreenItems=[
11 | FeedScreen(),
12 | SearchScreen(),
13 | AddPostScreen(),
14 | Text("notification"),
15 | ProfileScreen(uid: FirebaseAuth.instance.currentUser!.uid,),
16 | ];
--------------------------------------------------------------------------------
/lib/utils/utils.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:image_picker/image_picker.dart';
3 |
4 | pickImage(ImageSource source) async {
5 | final ImagePicker _imagePicker=ImagePicker();
6 | XFile? _file= await _imagePicker.pickImage(source: source);
7 | if(_file!=null){
8 | return await _file.readAsBytes();
9 | }
10 | print('No image selected');
11 | }
12 |
13 | showSnackBar(String content,BuildContext context){
14 | ScaffoldMessenger.of(context).showSnackBar(SnackBar(content:
15 | Text(content),
16 | ),);
17 | }
--------------------------------------------------------------------------------
/lib/widgets/comment_card.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:intl/intl.dart';
3 |
4 | class CommentCard extends StatefulWidget {
5 | final snap;
6 | const CommentCard({Key? key,
7 | required this.snap}) : super(key: key);
8 |
9 | @override
10 | State createState() => _CommentCardState();
11 | }
12 |
13 | class _CommentCardState extends State {
14 | @override
15 | Widget build(BuildContext context) {
16 | return Container(
17 | padding: const EdgeInsets.symmetric(vertical: 18, horizontal: 16),
18 | child: Row(
19 | children: [
20 | CircleAvatar(
21 | backgroundImage: NetworkImage(
22 | widget.snap['profilePic']
23 | ),
24 | radius: 18,
25 |
26 | ),
27 | Expanded(
28 | child: Padding(
29 | padding:EdgeInsets.only(left: 16),
30 | child: Column(
31 | mainAxisAlignment: MainAxisAlignment.center,
32 | crossAxisAlignment: CrossAxisAlignment.start,
33 | children: [
34 | RichText(text: TextSpan(
35 | children:[ TextSpan(
36 | text: widget.snap['name'],
37 | style: TextStyle(
38 | fontWeight: FontWeight.bold,
39 | ),
40 | ),
41 | TextSpan(
42 | text: ' ${widget.snap['text']}',
43 |
44 | ),
45 | ],
46 | ),
47 | ),
48 | Padding(
49 | padding:const EdgeInsets.only(top: 4),
50 | child: Text(
51 | DateFormat.yMMMd().format(
52 | widget.snap['datePublished'].toDate()
53 | ),
54 | style: TextStyle(
55 | fontSize: 12,
56 | fontWeight: FontWeight.w400,
57 | ),
58 | ),
59 | ),
60 |
61 | ],
62 | ),
63 | ),
64 | ),
65 | Container(
66 | padding: const EdgeInsets.all(8),
67 | child: const Icon(Icons.favorite,
68 | size:16 ,),
69 | )
70 | ],
71 | ),
72 | );
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/lib/widgets/follow_button.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class FollowButton extends StatelessWidget {
4 | final Function()? function;
5 | final Color backgroundColor;
6 | final Color borderColor;
7 | final String text;
8 | final Color textColor;
9 | const FollowButton({Key? key,
10 | required this.backgroundColor,
11 | required this.borderColor,
12 | required this.text,
13 | required this.textColor,
14 | this.function}) : super(key: key);
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | return Container(
19 | padding: EdgeInsets.only(top: 2),
20 | child: TextButton(
21 | onPressed: function,
22 | child: Container(
23 | decoration: BoxDecoration(
24 | color: backgroundColor,
25 | border: Border.all(color: borderColor),
26 | borderRadius: BorderRadius.circular(5)),
27 | alignment: Alignment.center,
28 | child: Text(
29 | text,
30 | style: TextStyle(
31 | color: textColor,
32 | fontWeight: FontWeight.bold,
33 | ),
34 | ),
35 | width: 250,
36 | height: 27,
37 | ),
38 | ),
39 | );
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/lib/widgets/like_animation.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class LikeAnimation extends StatefulWidget {
4 | final Widget child;
5 | final bool isAnimating;
6 | final Duration duration;
7 | final VoidCallback? onEnd;
8 | final bool smallLike;
9 | const LikeAnimation({Key? key,
10 | required this.child,
11 | required this.isAnimating,
12 | this.duration= const Duration(milliseconds: 150),
13 | this.onEnd,
14 | this.smallLike = false,
15 | }) : super(key: key);
16 |
17 | @override
18 | State createState() => _LikeAnimationState();
19 | }
20 |
21 | class _LikeAnimationState extends State with SingleTickerProviderStateMixin{
22 | late AnimationController controller;
23 | late Animation scale;
24 |
25 | @override
26 | void initState() {
27 | // TODO: implement initState
28 | super.initState();
29 | controller=AnimationController(vsync: this,duration: Duration(
30 | milliseconds: widget.duration.inMilliseconds ~/2,
31 | ),
32 | );
33 | scale= Tween(begin: 1,end: 1.2).animate(controller);
34 |
35 | }
36 |
37 | @override
38 | void didUpdateWidget(covariant LikeAnimation oldWidget) {
39 | // TODO: implement didUpdateWidget
40 | super.didUpdateWidget(oldWidget);
41 | if(widget.isAnimating!=oldWidget.isAnimating){
42 | startAnimation();
43 | }
44 | }
45 |
46 | startAnimation()async{
47 | if(widget.isAnimating || widget.smallLike){
48 | await controller.forward();
49 | await controller.reverse();
50 | await Future.delayed(const Duration(milliseconds: 200,),);
51 |
52 | if(widget.onEnd!=null){
53 | widget.onEnd!();
54 | }
55 |
56 | }
57 | }
58 |
59 | @override
60 | void dispose() {
61 | // TODO: implement dispose
62 | super.dispose();
63 | controller.dispose();
64 | }
65 |
66 | @override
67 | Widget build(BuildContext context) {
68 | return ScaleTransition(scale: scale,
69 | child: widget.child,
70 | );
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/lib/widgets/post_card.dart:
--------------------------------------------------------------------------------
1 | import 'package:cloud_firestore/cloud_firestore.dart';
2 | import 'package:flutter/material.dart';
3 | import 'package:instagram_flutter/models/user.dart';
4 | import 'package:instagram_flutter/providers/user_provider.dart';
5 | import 'package:instagram_flutter/resources/firestore_methods.dart';
6 | import 'package:instagram_flutter/screens/comments_screen.dart';
7 | import 'package:instagram_flutter/utils/colors.dart';
8 | import 'package:instagram_flutter/utils/global_variables.dart';
9 | import 'package:instagram_flutter/utils/utils.dart';
10 | import 'package:instagram_flutter/widgets/like_animation.dart';
11 | import 'package:intl/intl.dart';
12 | import 'package:provider/provider.dart';
13 |
14 | class PostCard extends StatefulWidget {
15 | final snap;
16 |
17 |
18 | const PostCard({Key? key, required this.snap}) : super(key: key);
19 |
20 | @override
21 | State createState() => _PostCardState();
22 | }
23 |
24 | class _PostCardState extends State {
25 | bool isLikeAnimating = false;
26 | var commentLen ;
27 |
28 | @override
29 | void initState() {
30 | // TODO: implement initState
31 | super.initState();
32 |
33 | getComments();
34 |
35 | }
36 | void getComments() async {
37 | try {
38 |
39 | QuerySnapshot snap = await FirebaseFirestore.instance.collection('posts').doc(
40 | widget.snap['postId'])
41 | .collection('comments').get();
42 | commentLen = snap.docs.length;
43 |
44 | }catch(e){
45 | showSnackBar(e.toString(), context);
46 | }
47 |
48 | setState(() {
49 |
50 |
51 | });
52 |
53 | }
54 |
55 |
56 | @override
57 | Widget build(BuildContext context) {
58 | final User user = Provider.of(context).getUser;
59 | final width=MediaQuery.of(context).size.width;
60 | return Container(
61 | decoration: BoxDecoration(
62 | border: Border.all(
63 | color: width>webScreenSize? secondaryColor:mobileBackgroundColor,
64 | )
65 | ),
66 |
67 | padding: const EdgeInsets.symmetric(vertical: 10),
68 | child: Column(
69 | children: [
70 | Container(
71 | padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 16)
72 | .copyWith(right: 0),
73 | child: Row(
74 | children: [
75 | CircleAvatar(
76 | radius: 16,
77 | backgroundImage: NetworkImage(
78 | widget.snap['profImage'],
79 | ),
80 | ),
81 | Expanded(
82 | child: Padding(
83 | padding: EdgeInsets.only(left: 8),
84 | child: Column(
85 | mainAxisSize: MainAxisSize.min,
86 | crossAxisAlignment: CrossAxisAlignment.start,
87 | children: [
88 | Text(
89 | widget.snap['username'],
90 | style: TextStyle(
91 | fontWeight: FontWeight.bold,
92 | ),
93 | ),
94 | ],
95 | ),
96 | ),
97 | ),
98 | IconButton(
99 | onPressed: () {
100 | showDialog(
101 | context: context,
102 | builder: (context) => Dialog(
103 | child: ListView(
104 | padding: EdgeInsets.symmetric(vertical: 16),
105 | shrinkWrap: true,
106 | children: ['Delete']
107 | .map(
108 | (e) => InkWell(
109 | onTap: () async {
110 | await FirestoreMethods().deletePost(widget.snap['postId']);
111 | Navigator.of(context).pop();
112 | },
113 | child: Container(
114 | padding: EdgeInsets.symmetric(
115 | vertical: 12, horizontal: 16),
116 | child: Text(e),
117 | ),
118 | ),
119 | )
120 | .toList()),
121 | ),
122 | );
123 | },
124 | icon: const Icon(Icons.more_vert),
125 | ),
126 | ],
127 | ),
128 | ),
129 | GestureDetector(
130 | onDoubleTap: () async {
131 | await FirestoreMethods().likepost(
132 | widget.snap['postId'], user.uid, widget.snap['likes']);
133 | setState(() {
134 | isLikeAnimating = true;
135 | });
136 | },
137 | child: Stack(
138 | alignment: Alignment.center,
139 | children: [
140 | SizedBox(
141 | height: MediaQuery.of(context).size.height * 0.35,
142 | width: double.infinity,
143 | child: Image.network(
144 | widget.snap['postUrl'],
145 | fit: BoxFit.cover,
146 | ),
147 | ),
148 | AnimatedOpacity(
149 | duration: const Duration(milliseconds: 200),
150 | opacity: isLikeAnimating ? 1 : 0,
151 | child: LikeAnimation(
152 | child: const Icon(
153 | Icons.favorite,
154 | color: Colors.white,
155 | size: 120,
156 | ),
157 | isAnimating: isLikeAnimating,
158 | duration: const Duration(milliseconds: 400),
159 | onEnd: () {
160 | setState(() {
161 | isLikeAnimating = false;
162 | });
163 | },
164 | ),
165 | )
166 | ],
167 | ),
168 | ),
169 | Row(
170 | children: [
171 | LikeAnimation(
172 | isAnimating: widget.snap['likes'].contains(user.uid),
173 | smallLike: true,
174 | child: IconButton(
175 | onPressed: () async {
176 | await FirestoreMethods().likepost(
177 | widget.snap['postId'], user.uid, widget.snap['likes']);
178 | },
179 | icon: widget.snap['likes'].contains(user.uid)
180 | ? const Icon(
181 | Icons.favorite,
182 | color: Colors.red,
183 | )
184 | : const Icon(Icons.favorite_border),
185 | ),
186 | ),
187 | IconButton(
188 | onPressed: () => Navigator.of(context).push(
189 | MaterialPageRoute(
190 | builder: (context) => CommentsScreen(
191 | snap: widget.snap,
192 | ),
193 | ),
194 | ),
195 | icon: const Icon(
196 | Icons.comment_outlined,
197 | ),
198 | ),
199 | IconButton(
200 | onPressed: () {},
201 | icon: const Icon(
202 | Icons.send,
203 | ),
204 | ),
205 | Expanded(
206 | child: Align(
207 | alignment: Alignment.bottomRight,
208 | child: IconButton(
209 | onPressed: () {},
210 | icon: const Icon(
211 | Icons.bookmark_border,
212 | ),
213 | ),
214 | ),
215 | ),
216 | ],
217 | ),
218 | //Description and no of comment
219 | Container(
220 | padding: const EdgeInsets.symmetric(horizontal: 16),
221 | child: Column(
222 | mainAxisSize: MainAxisSize.min,
223 | crossAxisAlignment: CrossAxisAlignment.start,
224 | children: [
225 | DefaultTextStyle(
226 | style: Theme.of(context)
227 | .textTheme
228 | .subtitle2!
229 | .copyWith(fontWeight: FontWeight.w800),
230 | child: Text(
231 | '${widget.snap['likes'].length} likes',
232 | style: Theme.of(context).textTheme.bodyText2,
233 | ),
234 | ),
235 | Container(
236 | width: double.infinity,
237 | padding: const EdgeInsets.only(top: 8),
238 | child: RichText(
239 | text: TextSpan(
240 | style: const TextStyle(
241 | color: primaryColor,
242 | ),
243 | children: [
244 | TextSpan(
245 | text: widget.snap['username'],
246 | style:
247 | const TextStyle(fontWeight: FontWeight.bold)),
248 | TextSpan(text: ' ${widget.snap['description']}'),
249 | ]),
250 | ),
251 | ),
252 | InkWell(
253 | onTap: () {},
254 | child: Container(
255 | padding: EdgeInsets.symmetric(vertical: 4),
256 | child: Text(
257 | 'View all ${commentLen} comments',
258 | style: const TextStyle(
259 | fontSize: 16,
260 | color: secondaryColor,
261 | ),
262 | ),
263 | ),
264 | ),
265 | Container(
266 | padding: EdgeInsets.symmetric(vertical: 4),
267 | child: Text(
268 | DateFormat.yMMMd().format(
269 | widget.snap['datePublished'].toDate(),
270 | ),
271 | style: const TextStyle(
272 | fontSize: 16,
273 | color: secondaryColor,
274 | ),
275 | ),
276 | ),
277 | ],
278 | ),
279 | )
280 | ],
281 | ),
282 | );
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/lib/widgets/text_field_input.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 |
3 | class TextFieldInput extends StatelessWidget {
4 | final TextEditingController textEditingController;
5 | final bool isPass;
6 | final String hintText;
7 | final TextInputType textInputType;
8 | const TextFieldInput({
9 | Key? key,
10 | required this.textEditingController,
11 | required this.textInputType,
12 | required this.hintText,
13 | this.isPass=false,
14 | }) : super(key: key);
15 |
16 | @override
17 | Widget build(BuildContext context) {
18 | final inputBorder =
19 | OutlineInputBorder(borderSide: Divider.createBorderSide(context));
20 | // TODO: implement build
21 | return TextField(
22 | controller: textEditingController,
23 | decoration: InputDecoration(
24 | hintText: hintText,
25 | border: inputBorder,
26 | focusedBorder: inputBorder,
27 | enabledBorder: inputBorder,
28 | filled: true,
29 | contentPadding: const EdgeInsets.all(8),
30 | ),
31 | keyboardType: textInputType,
32 | obscureText: isPass,
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/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 "instagram_flutter")
8 | # The unique GTK application identifier for this application. See:
9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID
10 | set(APPLICATION_ID "com.example.instagram_flutter")
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) file_selector_linux_registrar =
13 | fl_plugin_registry_get_registrar_for_plugin(registry, "FileSelectorPlugin");
14 | file_selector_plugin_register_with_registrar(file_selector_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 | file_selector_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, "instagram_flutter");
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, "instagram_flutter");
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 file_selector_macos
10 | import firebase_auth
11 | import firebase_core
12 | import firebase_storage
13 |
14 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
15 | FLTFirebaseFirestorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseFirestorePlugin"))
16 | FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin"))
17 | FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
18 | FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
19 | FLTFirebaseStoragePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseStoragePlugin"))
20 | }
21 |
--------------------------------------------------------------------------------
/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png
--------------------------------------------------------------------------------
/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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 = instagram_flutter
9 |
10 | // The application's bundle identifier
11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.instagramFlutter
12 |
13 | // The copyright displayed in application information
14 | PRODUCT_COPYRIGHT = Copyright © 2023 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: instagram_flutter
2 | description: A new Flutter project.
3 |
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7 |
8 | # The following defines the version and build number for your application.
9 | # A version number is three numbers separated by dots, like 1.2.43
10 | # followed by an optional build number separated by a +.
11 | # Both the version and the builder number may be overridden in flutter
12 | # build by specifying --build-name and --build-number, respectively.
13 | # In Android, build-name is used as versionName while build-number used as versionCode.
14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion.
16 | # Read more about iOS versioning at
17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18 | # In Windows, build-name is used as the major, minor, and patch parts
19 | # of the product and file versions while build-number is used as the build suffix.
20 | version: 1.0.0+1
21 |
22 | environment:
23 | sdk: '>=2.18.6 <3.0.0'
24 |
25 | # Dependencies specify other packages that your package needs in order to work.
26 | # To automatically upgrade your package dependencies to the latest versions
27 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
28 | # dependencies can be manually updated by changing the version numbers below to
29 | # the latest version available on pub.dev. To see which dependencies have newer
30 | # versions available, run `flutter pub outdated`.
31 | dependencies:
32 | cloud_firestore: ^4.8.1
33 | firebase_auth: ^4.6.3
34 | firebase_core: ^2.14.0
35 | firebase_storage: ^11.2.3
36 | flutter_svg: ^2.0.7
37 | image_picker: ^1.0.0
38 | provider: ^6.0.5
39 | uuid: ^3.0.7
40 | intl: ^0.18.1
41 | flutter_staggered_grid_view: ^0.4.0
42 | flutter:
43 | sdk: flutter
44 |
45 |
46 | # The following adds the Cupertino Icons font to your application.
47 | # Use with the CupertinoIcons class for iOS style icons.
48 | cupertino_icons: ^1.0.2
49 |
50 | dev_dependencies:
51 | flutter_test:
52 | sdk: flutter
53 |
54 | # The "flutter_lints" package below contains a set of recommended lints to
55 | # encourage good coding practices. The lint set provided by the package is
56 | # activated in the `analysis_options.yaml` file located at the root of your
57 | # package. See that file for information about deactivating specific lint
58 | # rules and activating additional ones.
59 | flutter_lints: ^2.0.0
60 |
61 | # For information on the generic Dart part of this file, see the
62 | # following page: https://dart.dev/tools/pub/pubspec
63 |
64 | # The following section is specific to Flutter packages.
65 | flutter:
66 |
67 | # The following line ensures that the Material Icons font is
68 | # included with your application, so that you can use the icons in
69 | # the material Icons class.
70 | uses-material-design: true
71 |
72 | # To add assets to your application, add an assets section, like this:
73 | assets:
74 | - assets/ic_instagram.svg
75 | # - images/a_dot_ham.jpeg
76 |
77 | # An image asset can refer to one or more resolution-specific "variants", see
78 | # https://flutter.dev/assets-and-images/#resolution-aware
79 |
80 | # For details regarding adding assets from package dependencies, see
81 | # https://flutter.dev/assets-and-images/#from-packages
82 |
83 | # To add custom fonts to your application, add a fonts section here,
84 | # in this "flutter" section. Each entry in this list should have a
85 | # "family" key with the font family name, and a "fonts" key with a
86 | # list giving the asset and other descriptors for the font. For
87 | # example:
88 | # fonts:
89 | # - family: Schyler
90 | # fonts:
91 | # - asset: fonts/Schyler-Regular.ttf
92 | # - asset: fonts/Schyler-Italic.ttf
93 | # style: italic
94 | # - family: Trajan Pro
95 | # fonts:
96 | # - asset: fonts/TrajanPro.ttf
97 | # - asset: fonts/TrajanPro_Bold.ttf
98 | # weight: 700
99 | #
100 | # For details regarding fonts from package dependencies,
101 | # see https://flutter.dev/custom-fonts/#from-packages
102 |
--------------------------------------------------------------------------------
/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:instagram_flutter/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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/web/favicon.png
--------------------------------------------------------------------------------
/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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 | instagram_flutter
33 |
34 |
35 |
39 |
40 |
41 |
42 |
43 |
57 |
58 |
59 |
--------------------------------------------------------------------------------
/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "instagram_flutter",
3 | "short_name": "instagram_flutter",
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(instagram_flutter 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 "instagram_flutter")
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 | FileSelectorWindowsRegisterWithRegistrar(
14 | registry->GetRegistrarForPlugin("FileSelectorWindows"));
15 | FirebaseCorePluginCApiRegisterWithRegistrar(
16 | registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
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 | file_selector_windows
7 | firebase_core
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 | # Add preprocessor definitions for the build version.
24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"")
25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}")
26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}")
27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}")
28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}")
29 |
30 | # Disable Windows macros that collide with C++ standard library functions.
31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX")
32 |
33 | # Add dependency libraries and include directories. Add any application-specific
34 | # dependencies here.
35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app)
36 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
37 |
38 | # Run the Flutter tool portions of the build. This must not be removed.
39 | add_dependencies(${BINARY_NAME} flutter_assemble)
40 |
--------------------------------------------------------------------------------
/windows/runner/Runner.rc:
--------------------------------------------------------------------------------
1 | // Microsoft Visual C++ generated resource script.
2 | //
3 | #pragma code_page(65001)
4 | #include "resource.h"
5 |
6 | #define APSTUDIO_READONLY_SYMBOLS
7 | /////////////////////////////////////////////////////////////////////////////
8 | //
9 | // Generated from the TEXTINCLUDE 2 resource.
10 | //
11 | #include "winres.h"
12 |
13 | /////////////////////////////////////////////////////////////////////////////
14 | #undef APSTUDIO_READONLY_SYMBOLS
15 |
16 | /////////////////////////////////////////////////////////////////////////////
17 | // English (United States) resources
18 |
19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
21 |
22 | #ifdef APSTUDIO_INVOKED
23 | /////////////////////////////////////////////////////////////////////////////
24 | //
25 | // TEXTINCLUDE
26 | //
27 |
28 | 1 TEXTINCLUDE
29 | BEGIN
30 | "resource.h\0"
31 | END
32 |
33 | 2 TEXTINCLUDE
34 | BEGIN
35 | "#include ""winres.h""\r\n"
36 | "\0"
37 | END
38 |
39 | 3 TEXTINCLUDE
40 | BEGIN
41 | "\r\n"
42 | "\0"
43 | END
44 |
45 | #endif // APSTUDIO_INVOKED
46 |
47 |
48 | /////////////////////////////////////////////////////////////////////////////
49 | //
50 | // Icon
51 | //
52 |
53 | // Icon with lowest ID value placed first to ensure application icon
54 | // remains consistent on all systems.
55 | IDI_APP_ICON ICON "resources\\app_icon.ico"
56 |
57 |
58 | /////////////////////////////////////////////////////////////////////////////
59 | //
60 | // Version
61 | //
62 |
63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD)
64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD
65 | #else
66 | #define VERSION_AS_NUMBER 1,0,0,0
67 | #endif
68 |
69 | #if defined(FLUTTER_VERSION)
70 | #define VERSION_AS_STRING FLUTTER_VERSION
71 | #else
72 | #define VERSION_AS_STRING "1.0.0"
73 | #endif
74 |
75 | VS_VERSION_INFO VERSIONINFO
76 | FILEVERSION VERSION_AS_NUMBER
77 | PRODUCTVERSION VERSION_AS_NUMBER
78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
79 | #ifdef _DEBUG
80 | FILEFLAGS VS_FF_DEBUG
81 | #else
82 | FILEFLAGS 0x0L
83 | #endif
84 | FILEOS VOS__WINDOWS32
85 | FILETYPE VFT_APP
86 | FILESUBTYPE 0x0L
87 | BEGIN
88 | BLOCK "StringFileInfo"
89 | BEGIN
90 | BLOCK "040904e4"
91 | BEGIN
92 | VALUE "CompanyName", "com.example" "\0"
93 | VALUE "FileDescription", "instagram_flutter" "\0"
94 | VALUE "FileVersion", VERSION_AS_STRING "\0"
95 | VALUE "InternalName", "instagram_flutter" "\0"
96 | VALUE "LegalCopyright", "Copyright (C) 2023 com.example. All rights reserved." "\0"
97 | VALUE "OriginalFilename", "instagram_flutter.exe" "\0"
98 | VALUE "ProductName", "instagram_flutter" "\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"instagram_flutter", 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/Pankaj0405/Instagram-clone-flutter/751d6c0bacce3de18527ab7e272231705437dc7c/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 |
--------------------------------------------------------------------------------