├── .gitattributes ├── .gitignore ├── .metadata ├── LICENSE ├── README.md ├── analysis_options.yaml ├── android ├── .gitignore ├── app │ ├── build.gradle │ └── src │ │ ├── debug │ │ └── AndroidManifest.xml │ │ ├── main │ │ ├── AndroidManifest.xml │ │ ├── kotlin │ │ │ └── dev │ │ │ │ └── usama │ │ │ │ └── flutter_trading_app │ │ │ │ └── MainActivity.kt │ │ └── res │ │ │ ├── drawable-v21 │ │ │ └── launch_background.xml │ │ │ ├── drawable │ │ │ └── launch_background.xml │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ └── ic_launcher.png │ │ │ ├── values-night │ │ │ └── styles.xml │ │ │ └── values │ │ │ └── styles.xml │ │ └── profile │ │ └── AndroidManifest.xml ├── build.gradle ├── gradle.properties ├── gradle │ └── wrapper │ │ └── gradle-wrapper.properties └── settings.gradle ├── build.sh ├── docs ├── .last_build_id ├── assets │ ├── AssetManifest.json │ ├── FontManifest.json │ ├── NOTICES │ ├── fonts │ │ └── MaterialIcons-Regular.otf │ ├── packages │ │ └── cupertino_icons │ │ │ └── assets │ │ │ └── CupertinoIcons.ttf │ └── shaders │ │ └── ink_sparkle.frag ├── canvaskit │ ├── canvaskit.js │ ├── canvaskit.wasm │ └── profiling │ │ ├── canvaskit.js │ │ └── canvaskit.wasm ├── favicon.png ├── flutter.js ├── flutter_service_worker.js ├── icons │ ├── Icon-192.png │ ├── Icon-512.png │ ├── Icon-maskable-192.png │ └── Icon-maskable-512.png ├── index.html ├── main.dart.js ├── manifest.json └── version.json ├── ios ├── .gitignore ├── Flutter │ ├── AppFrameworkInfo.plist │ ├── Debug.xcconfig │ └── Release.xcconfig ├── Runner.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ └── xcshareddata │ │ └── xcschemes │ │ └── Runner.xcscheme ├── Runner.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ ├── IDEWorkspaceChecks.plist │ │ └── WorkspaceSettings.xcsettings └── Runner │ ├── AppDelegate.swift │ ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-App-1024x1024@1x.png │ │ ├── Icon-App-20x20@1x.png │ │ ├── Icon-App-20x20@2x.png │ │ ├── Icon-App-20x20@3x.png │ │ ├── Icon-App-29x29@1x.png │ │ ├── Icon-App-29x29@2x.png │ │ ├── Icon-App-29x29@3x.png │ │ ├── Icon-App-40x40@1x.png │ │ ├── Icon-App-40x40@2x.png │ │ ├── Icon-App-40x40@3x.png │ │ ├── Icon-App-60x60@2x.png │ │ ├── Icon-App-60x60@3x.png │ │ ├── Icon-App-76x76@1x.png │ │ ├── Icon-App-76x76@2x.png │ │ └── Icon-App-83.5x83.5@2x.png │ └── LaunchImage.imageset │ │ ├── Contents.json │ │ ├── LaunchImage.png │ │ ├── LaunchImage@2x.png │ │ ├── LaunchImage@3x.png │ │ └── README.md │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ └── Runner-Bridging-Header.h ├── lib ├── candle_ticker_model.dart ├── candlestick │ ├── candlesticks.dart │ ├── constant │ │ └── view_constants.dart │ ├── models │ │ ├── candle.dart │ │ ├── candle_sticks_style.dart │ │ ├── indicator.dart │ │ └── main_window_indicator.dart │ ├── utils │ │ ├── helper_functions.dart │ │ └── indicators │ │ │ ├── bollinger_bands_indicator.dart │ │ │ ├── moving_average_indicator.dart │ │ │ └── weighted_moving_average.dart │ └── widgets │ │ ├── candle_info_text.dart │ │ ├── candle_stick_widget.dart │ │ ├── dash_line.dart │ │ ├── desktop_chart.dart │ │ ├── mainwindow_indicator_widget.dart │ │ ├── mobile_chart.dart │ │ ├── price_column.dart │ │ ├── time_row.dart │ │ ├── toolbar.dart │ │ ├── toolbar_action.dart │ │ ├── top_panel.dart │ │ └── volume_widget.dart ├── data.dart ├── main.dart └── repository.dart ├── pubspec.lock ├── pubspec.yaml ├── tempCodeRunnerFile.sh ├── 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 /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.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: e3c29ec00c9c825c891d75054c63fcc46454dca1 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: e3c29ec00c9c825c891d75054c63fcc46454dca1 17 | base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 18 | - platform: android 19 | create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 20 | base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 21 | - platform: ios 22 | create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 23 | base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 24 | - platform: web 25 | create_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 26 | base_revision: e3c29ec00c9c825c891d75054c63fcc46454dca1 27 | 28 | # User provided section 29 | 30 | # List of Local paths (relative to this file) that should be 31 | # ignored by the migrate tool. 32 | # 33 | # Files that are not part of the templates will be ignored by default. 34 | unmanaged_files: 35 | - 'lib/main.dart' 36 | - 'ios/Runner.xcodeproj/project.pbxproj' 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Usama Sarwar 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Flutter Trading App `v1.0.0` 2 | 3 | 🔗 Visit [Live Web App](https://usamasarwar.github.io/flutter-trading-app) 4 | 5 | ## Screenshoots 6 | 7 | 8 | 9 | > Tip: You can switch currencies by tapping on the currency Symbols. 10 | 11 | 12 | 13 | > Tip: You can change your desired duration. i.e. 1m, 3m or 1d etc. 14 | 15 | 16 | 17 | > Tip: You can scroll up and down to zoom-in and zoom-out. 18 | 19 | ## Documentation 20 | 21 | ### Establishing Connection with Binance via Web Sockets 22 | ```dart 23 | WebSocketChannel establishConnection(String symbol, String interval) { 24 | final channel = WebSocketChannel.connect( 25 | Uri.parse('wss://stream.binance.com:9443/ws'), 26 | ); 27 | channel.sink.add( 28 | jsonEncode( 29 | { 30 | "method": "SUBSCRIBE", 31 | "params": ["$symbol@kline_$interval"], 32 | "id": 1 33 | }, 34 | ), 35 | ); 36 | return channel; 37 | } 38 | ``` 39 | 40 | ### API Call for fetching Candles 41 | ```dart 42 | Future> fetchCandles( 43 | {required String symbol, required String interval, int? endTime}) async { 44 | final uri = Uri.parse( 45 | "https://api.binance.com/api/v3/klines?symbol=$symbol&interval=$interval${endTime != null ? "&endTime=$endTime" : ""}"); 46 | final res = await http.get(uri); 47 | return (jsonDecode(res.body) as List) 48 | .map((e) => Candle.fromJson(e)) 49 | .toList() 50 | .reversed 51 | .toList(); 52 | } 53 | ``` 54 | 55 | ### API Calls for fetching Symbols 56 | ```dart 57 | Future> fetchSymbols() async { 58 | final uri = Uri.parse("https://api.binance.com/api/v3/ticker/price"); 59 | final res = await http.get(uri); 60 | return (jsonDecode(res.body) as List) 61 | .map((e) => e["symbol"] as String) 62 | .toList(); 63 | } 64 | ``` 65 | 66 | ### Dependencies 67 | ```yaml 68 | dependencies: 69 | # Flutter SDK 70 | flutter: 71 | sdk: flutter 72 | # Dependency for Icons 73 | cupertino_icons: ^1.0.2 74 | # Dependency for HTTP Calls 75 | http: ^0.13.3 76 | # Dependency for Web Socket Channels 77 | web_socket_channel: ^2.1.0 78 | ``` 79 | 80 | ## Developer 81 | [Usama Sarwar](https://github.com/UsamaSarwar) -------------------------------------------------------------------------------- /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 | 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 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "dev.usama.flutter_trading_app" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /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/kotlin/dev/usama/flutter_trading_app/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package dev.usama.flutter_trading_app 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | flutter clean 2 | flutter pub get 3 | flutter build web --web-renderer html 4 | 5 | # Remove old docs 6 | rm -rf docs/* 7 | 8 | # Move build/web/ files to docs/ 9 | cp -rf build/web/* docs/ 10 | 11 | # Remove build/web/ 12 | # rm -rf build/web 13 | 14 | # Remove build/ 15 | # rm -rf build 16 | 17 | 18 | # cp -r lib/ docs/ -------------------------------------------------------------------------------- /docs/.last_build_id: -------------------------------------------------------------------------------- 1 | ae4e347ea81f31d1ae78ef66cf016a58 -------------------------------------------------------------------------------- /docs/assets/AssetManifest.json: -------------------------------------------------------------------------------- 1 | {"packages/cupertino_icons/assets/CupertinoIcons.ttf":["packages/cupertino_icons/assets/CupertinoIcons.ttf"]} -------------------------------------------------------------------------------- /docs/assets/FontManifest.json: -------------------------------------------------------------------------------- 1 | [{"family":"MaterialIcons","fonts":[{"asset":"fonts/MaterialIcons-Regular.otf"}]},{"family":"packages/cupertino_icons/CupertinoIcons","fonts":[{"asset":"packages/cupertino_icons/assets/CupertinoIcons.ttf"}]}] -------------------------------------------------------------------------------- /docs/assets/fonts/MaterialIcons-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/assets/fonts/MaterialIcons-Regular.otf -------------------------------------------------------------------------------- /docs/assets/packages/cupertino_icons/assets/CupertinoIcons.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/assets/packages/cupertino_icons/assets/CupertinoIcons.ttf -------------------------------------------------------------------------------- /docs/assets/shaders/ink_sparkle.frag: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/assets/shaders/ink_sparkle.frag -------------------------------------------------------------------------------- /docs/canvaskit/canvaskit.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/canvaskit/canvaskit.wasm -------------------------------------------------------------------------------- /docs/canvaskit/profiling/canvaskit.wasm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/canvaskit/profiling/canvaskit.wasm -------------------------------------------------------------------------------- /docs/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/docs/favicon.png -------------------------------------------------------------------------------- /docs/flutter.js: -------------------------------------------------------------------------------- 1 | // Copyright 2014 The Flutter Authors. All rights reserved. 2 | // Use of this source code is governed by a BSD-style license that can be 3 | // found in the LICENSE file. 4 | 5 | /** 6 | * This script installs service_worker.js to provide PWA functionality to 7 | * application. For more information, see: 8 | * https://developers.google.com/web/fundamentals/primers/service-workers 9 | */ 10 | 11 | if (!_flutter) { 12 | var _flutter = {}; 13 | } 14 | _flutter.loader = null; 15 | 16 | (function() { 17 | "use strict"; 18 | class FlutterLoader { 19 | /** 20 | * Creates a FlutterLoader, and initializes its instance methods. 21 | */ 22 | constructor() { 23 | // TODO: Move the below methods to "#private" once supported by all the browsers 24 | // we support. In the meantime, we use the "revealing module" pattern. 25 | 26 | // Watchdog to prevent injecting the main entrypoint multiple times. 27 | this._scriptLoaded = null; 28 | 29 | // Resolver for the pending promise returned by loadEntrypoint. 30 | this._didCreateEngineInitializerResolve = null; 31 | 32 | // Called by Flutter web. 33 | // Bound to `this` now, so "this" is preserved across JS <-> Flutter jumps. 34 | this.didCreateEngineInitializer = this._didCreateEngineInitializer.bind(this); 35 | } 36 | 37 | /** 38 | * Initializes the main.dart.js with/without serviceWorker. 39 | * @param {*} options 40 | * @returns a Promise that will eventually resolve with an EngineInitializer, 41 | * or will be rejected with the error caused by the loader. 42 | */ 43 | loadEntrypoint(options) { 44 | const { 45 | entrypointUrl = "main.dart.js", 46 | serviceWorker, 47 | } = (options || {}); 48 | return this._loadWithServiceWorker(entrypointUrl, serviceWorker); 49 | } 50 | 51 | /** 52 | * Resolves the promise created by loadEntrypoint. 53 | * Called by Flutter through the public `didCreateEngineInitializer` method, 54 | * which is bound to the correct instance of the FlutterLoader on the page. 55 | * @param {*} engineInitializer 56 | */ 57 | _didCreateEngineInitializer(engineInitializer) { 58 | if (typeof this._didCreateEngineInitializerResolve != "function") { 59 | console.warn("Do not call didCreateEngineInitializer by hand. Start with loadEntrypoint instead."); 60 | } 61 | this._didCreateEngineInitializerResolve(engineInitializer); 62 | // Remove the public method after it's done, so Flutter Web can hot restart. 63 | delete this.didCreateEngineInitializer; 64 | } 65 | 66 | _loadEntrypoint(entrypointUrl) { 67 | if (!this._scriptLoaded) { 68 | console.debug("Injecting 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /docs/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Trading App", 3 | "short_name": "Trading App", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#000000", 7 | "theme_color": "#000000", 8 | "description": "Trading App", 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 | -------------------------------------------------------------------------------- /docs/version.json: -------------------------------------------------------------------------------- 1 | {"app_name":"flutter_trading_app","version":"1.0.0","build_number":"1","package_name":"flutter_trading_app"} -------------------------------------------------------------------------------- /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.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1300; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | INFOPLIST_FILE = Runner/Info.plist; 293 | LD_RUNPATH_SEARCH_PATHS = ( 294 | "$(inherited)", 295 | "@executable_path/Frameworks", 296 | ); 297 | PRODUCT_BUNDLE_IDENTIFIER = dev.usama.flutterTradingApp; 298 | PRODUCT_NAME = "$(TARGET_NAME)"; 299 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 300 | SWIFT_VERSION = 5.0; 301 | VERSIONING_SYSTEM = "apple-generic"; 302 | }; 303 | name = Profile; 304 | }; 305 | 97C147031CF9000F007C117D /* Debug */ = { 306 | isa = XCBuildConfiguration; 307 | buildSettings = { 308 | ALWAYS_SEARCH_USER_PATHS = NO; 309 | CLANG_ANALYZER_NONNULL = YES; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 315 | CLANG_WARN_BOOL_CONVERSION = YES; 316 | CLANG_WARN_COMMA = YES; 317 | CLANG_WARN_CONSTANT_CONVERSION = YES; 318 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 319 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 320 | CLANG_WARN_EMPTY_BODY = YES; 321 | CLANG_WARN_ENUM_CONVERSION = YES; 322 | CLANG_WARN_INFINITE_RECURSION = YES; 323 | CLANG_WARN_INT_CONVERSION = YES; 324 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 325 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 326 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 327 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 328 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 329 | CLANG_WARN_STRICT_PROTOTYPES = YES; 330 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 331 | CLANG_WARN_UNREACHABLE_CODE = YES; 332 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 333 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 334 | COPY_PHASE_STRIP = NO; 335 | DEBUG_INFORMATION_FORMAT = dwarf; 336 | ENABLE_STRICT_OBJC_MSGSEND = YES; 337 | ENABLE_TESTABILITY = YES; 338 | GCC_C_LANGUAGE_STANDARD = gnu99; 339 | GCC_DYNAMIC_NO_PIC = NO; 340 | GCC_NO_COMMON_BLOCKS = YES; 341 | GCC_OPTIMIZATION_LEVEL = 0; 342 | GCC_PREPROCESSOR_DEFINITIONS = ( 343 | "DEBUG=1", 344 | "$(inherited)", 345 | ); 346 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 347 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 348 | GCC_WARN_UNDECLARED_SELECTOR = YES; 349 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 350 | GCC_WARN_UNUSED_FUNCTION = YES; 351 | GCC_WARN_UNUSED_VARIABLE = YES; 352 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 353 | MTL_ENABLE_DEBUG_INFO = YES; 354 | ONLY_ACTIVE_ARCH = YES; 355 | SDKROOT = iphoneos; 356 | TARGETED_DEVICE_FAMILY = "1,2"; 357 | }; 358 | name = Debug; 359 | }; 360 | 97C147041CF9000F007C117D /* Release */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | ALWAYS_SEARCH_USER_PATHS = NO; 364 | CLANG_ANALYZER_NONNULL = YES; 365 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 366 | CLANG_CXX_LIBRARY = "libc++"; 367 | CLANG_ENABLE_MODULES = YES; 368 | CLANG_ENABLE_OBJC_ARC = YES; 369 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 370 | CLANG_WARN_BOOL_CONVERSION = YES; 371 | CLANG_WARN_COMMA = YES; 372 | CLANG_WARN_CONSTANT_CONVERSION = YES; 373 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 374 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 375 | CLANG_WARN_EMPTY_BODY = YES; 376 | CLANG_WARN_ENUM_CONVERSION = YES; 377 | CLANG_WARN_INFINITE_RECURSION = YES; 378 | CLANG_WARN_INT_CONVERSION = YES; 379 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 380 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 381 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 382 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 383 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 384 | CLANG_WARN_STRICT_PROTOTYPES = YES; 385 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 386 | CLANG_WARN_UNREACHABLE_CODE = YES; 387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 388 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 389 | COPY_PHASE_STRIP = NO; 390 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 391 | ENABLE_NS_ASSERTIONS = NO; 392 | ENABLE_STRICT_OBJC_MSGSEND = YES; 393 | GCC_C_LANGUAGE_STANDARD = gnu99; 394 | GCC_NO_COMMON_BLOCKS = YES; 395 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 396 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 397 | GCC_WARN_UNDECLARED_SELECTOR = YES; 398 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 399 | GCC_WARN_UNUSED_FUNCTION = YES; 400 | GCC_WARN_UNUSED_VARIABLE = YES; 401 | IPHONEOS_DEPLOYMENT_TARGET = 11.0; 402 | MTL_ENABLE_DEBUG_INFO = NO; 403 | SDKROOT = iphoneos; 404 | SUPPORTED_PLATFORMS = iphoneos; 405 | SWIFT_COMPILATION_MODE = wholemodule; 406 | SWIFT_OPTIMIZATION_LEVEL = "-O"; 407 | TARGETED_DEVICE_FAMILY = "1,2"; 408 | VALIDATE_PRODUCT = YES; 409 | }; 410 | name = Release; 411 | }; 412 | 97C147061CF9000F007C117D /* Debug */ = { 413 | isa = XCBuildConfiguration; 414 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 415 | buildSettings = { 416 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 417 | CLANG_ENABLE_MODULES = YES; 418 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 419 | ENABLE_BITCODE = NO; 420 | INFOPLIST_FILE = Runner/Info.plist; 421 | LD_RUNPATH_SEARCH_PATHS = ( 422 | "$(inherited)", 423 | "@executable_path/Frameworks", 424 | ); 425 | PRODUCT_BUNDLE_IDENTIFIER = dev.usama.flutterTradingApp; 426 | PRODUCT_NAME = "$(TARGET_NAME)"; 427 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 428 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 429 | SWIFT_VERSION = 5.0; 430 | VERSIONING_SYSTEM = "apple-generic"; 431 | }; 432 | name = Debug; 433 | }; 434 | 97C147071CF9000F007C117D /* Release */ = { 435 | isa = XCBuildConfiguration; 436 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 437 | buildSettings = { 438 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 439 | CLANG_ENABLE_MODULES = YES; 440 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 441 | ENABLE_BITCODE = NO; 442 | INFOPLIST_FILE = Runner/Info.plist; 443 | LD_RUNPATH_SEARCH_PATHS = ( 444 | "$(inherited)", 445 | "@executable_path/Frameworks", 446 | ); 447 | PRODUCT_BUNDLE_IDENTIFIER = dev.usama.flutterTradingApp; 448 | PRODUCT_NAME = "$(TARGET_NAME)"; 449 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 450 | SWIFT_VERSION = 5.0; 451 | VERSIONING_SYSTEM = "apple-generic"; 452 | }; 453 | name = Release; 454 | }; 455 | /* End XCBuildConfiguration section */ 456 | 457 | /* Begin XCConfigurationList section */ 458 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 459 | isa = XCConfigurationList; 460 | buildConfigurations = ( 461 | 97C147031CF9000F007C117D /* Debug */, 462 | 97C147041CF9000F007C117D /* Release */, 463 | 249021D3217E4FDB00AE95B9 /* Profile */, 464 | ); 465 | defaultConfigurationIsVisible = 0; 466 | defaultConfigurationName = Release; 467 | }; 468 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 469 | isa = XCConfigurationList; 470 | buildConfigurations = ( 471 | 97C147061CF9000F007C117D /* Debug */, 472 | 97C147071CF9000F007C117D /* Release */, 473 | 249021D4217E4FDB00AE95B9 /* Profile */, 474 | ); 475 | defaultConfigurationIsVisible = 0; 476 | defaultConfigurationName = Release; 477 | }; 478 | /* End XCConfigurationList section */ 479 | }; 480 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 481 | } 482 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Flutter Trading App 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | flutter_trading_app 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/candle_ticker_model.dart: -------------------------------------------------------------------------------- 1 | import 'candlestick/models/candle.dart'; 2 | 3 | class CandleTickerModel { 4 | final int eventTime; 5 | final String symbol; 6 | final Candle candle; 7 | 8 | const CandleTickerModel( 9 | {required this.eventTime, required this.symbol, required this.candle}); 10 | 11 | factory CandleTickerModel.fromJson(Map json) { 12 | return CandleTickerModel( 13 | eventTime: json['E'] as int, 14 | symbol: json['s'] as String, 15 | candle: Candle( 16 | date: DateTime.fromMillisecondsSinceEpoch(json["k"]["t"]), 17 | high: double.parse(json["k"]["h"]), 18 | low: double.parse(json["k"]["l"]), 19 | open: double.parse(json["k"]["o"]), 20 | close: double.parse(json["k"]["c"]), 21 | volume: double.parse(json["k"]["v"]))); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/candlestick/candlesticks.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: library_private_types_in_public_api 2 | 3 | import 'dart:io' show Platform; 4 | import 'dart:math'; 5 | 6 | import 'package:flutter/foundation.dart'; 7 | import 'package:flutter/material.dart'; 8 | 9 | import 'models/candle.dart'; 10 | import 'models/candle_sticks_style.dart'; 11 | import 'models/indicator.dart'; 12 | import 'models/main_window_indicator.dart'; 13 | import 'widgets/desktop_chart.dart'; 14 | import 'widgets/mobile_chart.dart'; 15 | import 'widgets/toolbar.dart'; 16 | import 'widgets/toolbar_action.dart'; 17 | 18 | /// StatefulWidget that holds Chart's State (index of 19 | /// current position and candles width). 20 | class Candlesticks extends StatefulWidget { 21 | /// The arrangement of the array should be such that 22 | /// the newest item is in position 0 23 | final List candles; 24 | 25 | /// This callback calls when the last candle gets visible 26 | final Future Function()? onLoadMoreCandles; 27 | 28 | /// List of buttons you what to add on top tool bar 29 | final List actions; 30 | 31 | /// List of indicators to draw 32 | final List? indicators; 33 | 34 | /// This callback calls when ever user clicks a spcesific indicator close button (X) 35 | final void Function(String)? onRemoveIndicator; 36 | 37 | /// How chart price range will be adjusted when moving chart 38 | final ChartAdjust chartAdjust; 39 | 40 | /// Will zoom buttons be displayed in toolbar 41 | final bool displayZoomActions; 42 | 43 | /// Custom loading widget 44 | final Widget? loadingWidget; 45 | 46 | final CandleSticksStyle? style; 47 | 48 | const Candlesticks({ 49 | Key? key, 50 | required this.candles, 51 | this.onLoadMoreCandles, 52 | this.actions = const [], 53 | this.chartAdjust = ChartAdjust.visibleRange, 54 | this.displayZoomActions = true, 55 | this.loadingWidget, 56 | this.indicators, 57 | this.onRemoveIndicator, 58 | this.style, 59 | }) : assert(candles.length == 0 || candles.length > 1, 60 | "Please provide at least 2 candles"), 61 | super(key: key); 62 | 63 | @override 64 | _CandlesticksState createState() => _CandlesticksState(); 65 | } 66 | 67 | enum ChartAdjust { 68 | /// Will adjust chart size by max and min value from visible area 69 | visibleRange, 70 | 71 | /// Will adjust chart size by max and min value from the whole data 72 | fullRange 73 | } 74 | 75 | class _CandlesticksState extends State { 76 | /// index of the newest candle to be displayed 77 | /// changes when user scrolls along the chart 78 | int index = -10; 79 | double lastX = 0; 80 | int lastIndex = -10; 81 | 82 | /// candleWidth controls the width of the single candles. 83 | /// range: [2...10] 84 | double candleWidth = 6; 85 | 86 | /// true when widget.onLoadMoreCandles is fetching new candles. 87 | bool isCallingLoadMore = false; 88 | 89 | MainWindowDataContainer? mainWindowDataContainer; 90 | 91 | @override 92 | Widget build(BuildContext context) { 93 | final style = widget.style ?? 94 | (Theme.of(context).brightness == Brightness.dark 95 | ? CandleSticksStyle.dark() 96 | : CandleSticksStyle.light()); 97 | return Column( 98 | children: [ 99 | if (widget.displayZoomActions == true || widget.actions.isNotEmpty) ...[ 100 | ToolBar( 101 | color: style.toolBarColor, 102 | children: [ 103 | if (widget.displayZoomActions) ...[ 104 | ToolBarAction( 105 | onPressed: () { 106 | setState(() { 107 | candleWidth -= 2; 108 | candleWidth = max(candleWidth, 2); 109 | }); 110 | }, 111 | child: Icon( 112 | Icons.remove, 113 | color: style.borderColor, 114 | ), 115 | ), 116 | ToolBarAction( 117 | onPressed: () { 118 | setState(() { 119 | candleWidth += 2; 120 | candleWidth = min(candleWidth, 20); 121 | }); 122 | }, 123 | child: Icon( 124 | Icons.add, 125 | color: style.borderColor, 126 | ), 127 | ), 128 | ], 129 | ...widget.actions 130 | ], 131 | ), 132 | ], 133 | if (widget.candles.isEmpty || mainWindowDataContainer == null) 134 | Expanded( 135 | child: Center( 136 | child: widget.loadingWidget ?? 137 | CircularProgressIndicator(color: style.loadingColor), 138 | ), 139 | ) 140 | else 141 | Expanded( 142 | child: TweenAnimationBuilder( 143 | tween: Tween(begin: 6.toDouble(), end: candleWidth), 144 | duration: const Duration(milliseconds: 120), 145 | builder: (_, double width, __) { 146 | if (kIsWeb || 147 | Platform.isMacOS || 148 | Platform.isWindows || 149 | Platform.isLinux) { 150 | return DesktopChart( 151 | style: style, 152 | onRemoveIndicator: widget.onRemoveIndicator, 153 | mainWindowDataContainer: mainWindowDataContainer!, 154 | chartAdjust: widget.chartAdjust, 155 | onScaleUpdate: (double scale) { 156 | scale = max(0.90, scale); 157 | scale = min(1.1, scale); 158 | setState(() { 159 | candleWidth *= scale; 160 | candleWidth = min(candleWidth, 20); 161 | candleWidth = max(candleWidth, 2); 162 | }); 163 | }, 164 | onPanEnd: () { 165 | lastIndex = index; 166 | }, 167 | onHorizontalDragUpdate: (double x) { 168 | setState(() { 169 | x = x - lastX; 170 | index = lastIndex + x ~/ candleWidth; 171 | index = max(index, -10); 172 | index = min(index, widget.candles.length - 1); 173 | }); 174 | }, 175 | onPanDown: (double value) { 176 | lastX = value; 177 | lastIndex = index; 178 | }, 179 | onReachEnd: () { 180 | if (isCallingLoadMore == false && 181 | widget.onLoadMoreCandles != null) { 182 | isCallingLoadMore = true; 183 | widget.onLoadMoreCandles!().then((_) { 184 | isCallingLoadMore = false; 185 | }); 186 | } 187 | }, 188 | candleWidth: width, 189 | candles: widget.candles, 190 | index: index, 191 | ); 192 | } else { 193 | return MobileChart( 194 | style: style, 195 | onRemoveIndicator: widget.onRemoveIndicator, 196 | mainWindowDataContainer: mainWindowDataContainer!, 197 | chartAdjust: widget.chartAdjust, 198 | onScaleUpdate: (double scale) { 199 | scale = max(0.90, scale); 200 | scale = min(1.1, scale); 201 | setState(() { 202 | candleWidth *= scale; 203 | candleWidth = min(candleWidth, 20); 204 | candleWidth = max(candleWidth, 2); 205 | }); 206 | }, 207 | onPanEnd: () { 208 | lastIndex = index; 209 | }, 210 | onHorizontalDragUpdate: (double x) { 211 | setState(() { 212 | x = x - lastX; 213 | index = lastIndex + x ~/ candleWidth; 214 | index = max(index, -10); 215 | index = min(index, widget.candles.length - 1); 216 | }); 217 | }, 218 | onPanDown: (double value) { 219 | lastX = value; 220 | lastIndex = index; 221 | }, 222 | onReachEnd: () { 223 | if (isCallingLoadMore == false && 224 | widget.onLoadMoreCandles != null) { 225 | isCallingLoadMore = true; 226 | widget.onLoadMoreCandles!().then((_) { 227 | isCallingLoadMore = false; 228 | }); 229 | } 230 | }, 231 | candleWidth: width, 232 | candles: widget.candles, 233 | index: index, 234 | ); 235 | } 236 | }, 237 | ), 238 | ), 239 | ], 240 | ); 241 | } 242 | 243 | @override 244 | void didUpdateWidget(covariant Candlesticks oldWidget) { 245 | super.didUpdateWidget(oldWidget); 246 | if (widget.candles.isEmpty) { 247 | return; 248 | } 249 | if (mainWindowDataContainer == null) { 250 | mainWindowDataContainer = 251 | MainWindowDataContainer(widget.indicators ?? [], widget.candles); 252 | } else { 253 | final currentIndicators = widget.indicators ?? []; 254 | final oldIndicators = oldWidget.indicators ?? []; 255 | if (currentIndicators.length == oldIndicators.length) { 256 | for (int i = 0; i < currentIndicators.length; i++) { 257 | if (currentIndicators[i] == oldIndicators[i]) { 258 | continue; 259 | } else { 260 | mainWindowDataContainer = MainWindowDataContainer( 261 | widget.indicators ?? [], widget.candles); 262 | return; 263 | } 264 | } 265 | } else { 266 | mainWindowDataContainer = 267 | MainWindowDataContainer(widget.indicators ?? [], widget.candles); 268 | return; 269 | } 270 | try { 271 | mainWindowDataContainer!.tickUpdate(widget.candles); 272 | } catch (_) { 273 | mainWindowDataContainer = 274 | MainWindowDataContainer(widget.indicators ?? [], widget.candles); 275 | } 276 | } 277 | } 278 | 279 | @override 280 | void initState() { 281 | super.initState(); 282 | if (widget.candles.isEmpty) { 283 | return; 284 | } 285 | mainWindowDataContainer ??= 286 | MainWindowDataContainer(widget.indicators ?? [], widget.candles); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /lib/candlestick/constant/view_constants.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: constant_identifier_names 2 | 3 | const double DATE_BAR_HEIGHT = 20; 4 | const double MAIN_CHART_VERTICAL_PADDING = 10; 5 | const double MIN_PRICETILE_HEIGHT = 50; 6 | const double PRICE_BAR_WIDTH = 60; 7 | const double PRICE_INDICATOR_HEIGHT = 20; 8 | -------------------------------------------------------------------------------- /lib/candlestick/models/candle.dart: -------------------------------------------------------------------------------- 1 | /// Candle model wich holds a single candle data. 2 | /// It contains five required double variables that hold a single candle data: high, low, open, close and volume. 3 | /// It can be instantiated using its default constructor or fromJson named custructor. 4 | class Candle { 5 | /// DateTime for the candle 6 | final DateTime date; 7 | 8 | /// The highest price during this candle lifetime 9 | /// It if always more than low, open and close 10 | final double high; 11 | 12 | /// The lowest price during this candle lifetime 13 | /// It if always less than high, open and close 14 | final double low; 15 | 16 | /// Price at the beginning of the period 17 | final double open; 18 | 19 | /// Price at the end of the period 20 | final double close; 21 | 22 | /// Volume is the number of shares of a 23 | /// security traded during a given period of time. 24 | final double volume; 25 | 26 | bool get isBull => open <= close; 27 | 28 | Candle({ 29 | required this.date, 30 | required this.high, 31 | required this.low, 32 | required this.open, 33 | required this.close, 34 | required this.volume, 35 | }); 36 | 37 | Candle.fromJson(List json) 38 | : date = DateTime.fromMillisecondsSinceEpoch(json[0]), 39 | high = double.parse(json[2]), 40 | low = double.parse(json[3]), 41 | open = double.parse(json[1]), 42 | close = double.parse(json[4]), 43 | volume = double.parse(json[5]); 44 | } 45 | -------------------------------------------------------------------------------- /lib/candlestick/models/candle_sticks_style.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | class CandleSticksStyle { 4 | final Color borderColor; 5 | 6 | final Color background; 7 | 8 | final Color primaryBull; 9 | 10 | final Color secondaryBull; 11 | 12 | final Color primaryBear; 13 | 14 | final Color secondaryBear; 15 | 16 | final Color hoverIndicatorBackgroundColor; 17 | 18 | final Color mobileCandleHoverColor; 19 | 20 | final Color primaryTextColor; 21 | 22 | final Color secondaryTextColor; 23 | 24 | final Color loadingColor; 25 | 26 | final Color toolBarColor; 27 | 28 | CandleSticksStyle({ 29 | required this.borderColor, 30 | required this.background, 31 | required this.primaryBull, 32 | required this.secondaryBull, 33 | required this.primaryBear, 34 | required this.secondaryBear, 35 | required this.hoverIndicatorBackgroundColor, 36 | required this.primaryTextColor, 37 | required this.secondaryTextColor, 38 | required this.mobileCandleHoverColor, 39 | required this.loadingColor, 40 | required this.toolBarColor, 41 | }); 42 | 43 | factory CandleSticksStyle.dark({ 44 | Color? borderColor, 45 | Color? background, 46 | Color? primaryBull, 47 | Color? secondaryBull, 48 | Color? primaryBear, 49 | Color? secondaryBear, 50 | Color? hoverIndicatorBackgroundColor, 51 | Color? primaryTextColor, 52 | Color? secondaryTextColor, 53 | Color? mobileCandleHoverColor, 54 | Color? loadingColor, 55 | Color? toolBarColor, 56 | }) { 57 | return CandleSticksStyle( 58 | borderColor: borderColor ?? const Color(0xFF848E9C), 59 | background: background ?? const Color(0xFF191B20), 60 | primaryBull: primaryBull ?? const Color(0xFF26A69A), 61 | secondaryBull: secondaryBull ?? const Color(0xFF005940), 62 | primaryBear: primaryBear ?? const Color(0xFFEF5350), 63 | secondaryBear: secondaryBear ?? const Color(0xFF82122B), 64 | hoverIndicatorBackgroundColor: 65 | hoverIndicatorBackgroundColor ?? const Color(0xFF4C525E), 66 | primaryTextColor: primaryTextColor ?? const Color(0xFF848E9C), 67 | secondaryTextColor: secondaryTextColor ?? const Color(0XFFFFFFFF), 68 | mobileCandleHoverColor: 69 | mobileCandleHoverColor ?? const Color(0xFFF0B90A).withOpacity(0.2), 70 | loadingColor: loadingColor ?? const Color(0xFFF0B90A), 71 | toolBarColor: toolBarColor ?? const Color(0xFF191B20), 72 | ); 73 | } 74 | 75 | factory CandleSticksStyle.light({ 76 | Color? borderColor, 77 | Color? background, 78 | Color? primaryBull, 79 | Color? secondaryBull, 80 | Color? primaryBear, 81 | Color? secondaryBear, 82 | Color? hoverIndicatorBackgroundColor, 83 | Color? primaryTextColor, 84 | Color? secondaryTextColor, 85 | Color? mobileCandleHoverColor, 86 | Color? loadingColor, 87 | Color? toolBarColor, 88 | }) { 89 | return CandleSticksStyle( 90 | borderColor: borderColor ?? const Color(0xFF848E9C), 91 | background: background ?? const Color(0xFFFAFAFA), 92 | primaryBull: primaryBull ?? const Color(0xEF26A69A), 93 | secondaryBull: secondaryBull ?? const Color(0xFF8CCCC6), 94 | primaryBear: primaryBear ?? const Color(0xFFEF5350), 95 | secondaryBear: secondaryBear ?? const Color(0xFFF1A3A1), 96 | hoverIndicatorBackgroundColor: 97 | hoverIndicatorBackgroundColor ?? const Color(0xFF131722), 98 | primaryTextColor: primaryTextColor ?? const Color(0XFF000000), 99 | secondaryTextColor: secondaryTextColor ?? const Color(0XFFFFFFFF), 100 | mobileCandleHoverColor: 101 | mobileCandleHoverColor ?? const Color(0xFFF0B90A).withOpacity(0.2), 102 | loadingColor: loadingColor ?? const Color(0xFFF0B90A), 103 | toolBarColor: toolBarColor ?? const Color(0xFFFAFAFA), 104 | ); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/candlestick/models/indicator.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: unnecessary_overrides 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import 'candle.dart'; 6 | 7 | class Indicator { 8 | /// Indicator name. visible at top right side of chart 9 | final String name; 10 | 11 | /// Calculates indicator value for givien index. 12 | /// if your indicator has muliple lines (values) always return results in the same order. 13 | final List Function(int index, List candles) calculator; 14 | final int dependsOnNPrevCandles; 15 | 16 | /// Indicator lines style. 17 | /// the order of this should be same as calculator function results order. 18 | final List indicatorComponentsStyles; 19 | 20 | Indicator({ 21 | required this.name, 22 | required this.dependsOnNPrevCandles, 23 | required this.calculator, 24 | required this.indicatorComponentsStyles, 25 | }); 26 | 27 | @override 28 | int get hashCode => super.hashCode; 29 | 30 | @override 31 | bool operator ==(other) { 32 | if (other is Indicator) { 33 | return other.name == name; 34 | } else { 35 | return false; 36 | } 37 | } 38 | } 39 | 40 | class IndicatorStyle { 41 | final String name; 42 | final Color color; 43 | 44 | IndicatorStyle({ 45 | required this.name, 46 | required this.color, 47 | }); 48 | } 49 | -------------------------------------------------------------------------------- /lib/candlestick/models/main_window_indicator.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import '.././models/indicator.dart'; 6 | import 'candle.dart'; 7 | 8 | class IndicatorComponentData { 9 | final String name; 10 | final Color color; 11 | final List values = []; 12 | final Indicator parentIndicator; 13 | bool visible = true; 14 | IndicatorComponentData(this.parentIndicator, this.name, this.color); 15 | } 16 | 17 | class MainWindowDataContainer { 18 | List indicatorComponentData = []; 19 | List indicators; 20 | List highs = []; 21 | List lows = []; 22 | List unvisibleIndicators = []; 23 | late DateTime beginDate; 24 | late DateTime endDate; 25 | 26 | MainWindowDataContainer(this.indicators, List candles) { 27 | endDate = candles[0].date; 28 | beginDate = candles.last.date; 29 | for (var indicator in indicators) { 30 | for (var indicatorComponent in indicator.indicatorComponentsStyles) { 31 | indicatorComponentData.add(IndicatorComponentData( 32 | indicator, indicatorComponent.name, indicatorComponent.color)); 33 | } 34 | } 35 | 36 | highs = candles.map((e) => e.high).toList(); 37 | lows = candles.map((e) => e.low).toList(); 38 | 39 | for (var indicator in indicators) { 40 | final List containers = indicatorComponentData 41 | .where((element) => element.parentIndicator == indicator) 42 | .toList(); 43 | 44 | for (int i = 0; i < candles.length; i++) { 45 | double low = lows[i]; 46 | double high = highs[i]; 47 | 48 | List indicatorDatas = List.generate( 49 | indicator.indicatorComponentsStyles.length, (index) => null); 50 | 51 | if (i + indicator.dependsOnNPrevCandles < candles.length) { 52 | indicatorDatas = indicator.calculator(i, candles); 53 | } 54 | 55 | for (int i = 0; i < indicatorDatas.length; i++) { 56 | containers[i].values.add(indicatorDatas[i]); 57 | if (indicatorDatas[i] != null) { 58 | low = math.min(low, indicatorDatas[i]!); 59 | high = math.max(high, indicatorDatas[i]!); 60 | } 61 | } 62 | lows[i] = low; 63 | highs[i] = high; 64 | } 65 | } 66 | } 67 | 68 | void tickUpdate(List candles) { 69 | // update last candles 70 | for (int i = 0; candles[i].date.compareTo(endDate) > 0; i++) { 71 | highs.insert(i, candles[i].high); 72 | lows.insert(i, candles[i].low); 73 | for (var element in indicatorComponentData) { 74 | element.values.insert(i, null); 75 | } 76 | } 77 | for (var indicator in indicators) { 78 | final List containers = indicatorComponentData 79 | .where((element) => element.parentIndicator == indicator) 80 | .toList(); 81 | 82 | for (int i = 0; candles[i].date.compareTo(endDate) >= 0; i++) { 83 | double low = lows[i]; 84 | double high = highs[i]; 85 | 86 | List indicatorDatas = List.generate( 87 | indicator.indicatorComponentsStyles.length, (index) => null); 88 | 89 | if (i + indicator.dependsOnNPrevCandles < candles.length) { 90 | indicatorDatas = indicator.calculator(i, candles); 91 | } 92 | 93 | for (int j = 0; j < indicatorDatas.length; j++) { 94 | containers[j].values[i] = indicatorDatas[j]; 95 | if (indicatorDatas[j] != null) { 96 | low = math.min(low, indicatorDatas[j]!); 97 | high = math.max(high, indicatorDatas[j]!); 98 | } 99 | } 100 | lows[i] = low; 101 | highs[i] = high; 102 | } 103 | } 104 | endDate = candles[0].date; 105 | 106 | // update prev candles 107 | int firstCandleIndex = 0; 108 | for (int i = candles.length - 1; i >= 0; i--) { 109 | if (candles[i].date == beginDate) { 110 | firstCandleIndex = i; 111 | break; 112 | } 113 | } 114 | for (int i = firstCandleIndex + 1; i < candles.length; i++) { 115 | highs.add(candles[i].high); 116 | lows.add(candles[i].low); 117 | for (var element in indicatorComponentData) { 118 | element.values.add(null); 119 | } 120 | } 121 | for (var indicator in indicators) { 122 | final List containers = indicatorComponentData 123 | .where((element) => element.parentIndicator == indicator) 124 | .toList(); 125 | 126 | for (int i = firstCandleIndex - indicator.dependsOnNPrevCandles + 1; 127 | i < candles.length; 128 | i++) { 129 | double low = lows[i]; 130 | double high = highs[i]; 131 | 132 | List indicatorDatas = List.generate( 133 | indicator.indicatorComponentsStyles.length, (index) => null); 134 | 135 | if (i + indicator.dependsOnNPrevCandles < candles.length) { 136 | indicatorDatas = indicator.calculator(i, candles); 137 | } 138 | 139 | for (int j = 0; j < indicatorDatas.length; j++) { 140 | containers[j].values[i] = indicatorDatas[j]; 141 | if (indicatorDatas[j] != null) { 142 | low = math.min(low, indicatorDatas[j]!); 143 | high = math.max(high, indicatorDatas[j]!); 144 | } 145 | } 146 | lows[i] = low; 147 | highs[i] = high; 148 | } 149 | } 150 | beginDate = candles.last.date; 151 | } 152 | 153 | void toggleIndicatorVisibility(String indicatorName) { 154 | if (unvisibleIndicators.contains(indicatorName)) { 155 | unvisibleIndicators.remove(indicatorName); 156 | for (var element in indicatorComponentData) { 157 | if (element.parentIndicator.name == indicatorName) { 158 | element.visible = true; 159 | } 160 | } 161 | } else { 162 | unvisibleIndicators.add(indicatorName); 163 | for (var element in indicatorComponentData) { 164 | if (element.parentIndicator.name == indicatorName) { 165 | element.visible = false; 166 | } 167 | } 168 | } 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /lib/candlestick/utils/helper_functions.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import '.././constant/view_constants.dart'; 4 | 5 | class HelperFunctions { 6 | static String addMetricPrefix(double price) { 7 | if (price < 1) price = 1; 8 | int log = log10(price).floor(); 9 | if (log > 9) { 10 | return "${price ~/ 1000000000}B"; 11 | } else if (log > 6) { 12 | return "${price ~/ 1000000}M"; 13 | } else if (log > 3) { 14 | return "${price ~/ 1000}K"; 15 | } else { 16 | return price.toStringAsFixed(0); 17 | } 18 | } 19 | 20 | static double calculatePriceScale(double height, double high, double low) { 21 | int minTiles = (height / MIN_PRICETILE_HEIGHT).floor(); 22 | minTiles = max(2, minTiles); 23 | double sizeRange = high - low; 24 | assert(sizeRange != 0, 25 | "highest highs and lowest lows of visible candles are equal."); 26 | double minStepSize = sizeRange / minTiles; 27 | double base = 28 | pow(10, HelperFunctions.log10(minStepSize).floor()).toDouble(); 29 | 30 | if (2 * base > minStepSize) return 2 * base; 31 | if (5 * base > minStepSize) return 5 * base; 32 | return 10 * base; 33 | } 34 | 35 | static double getRoof(double number) { 36 | if (number == 0) { 37 | return 1; 38 | } 39 | int log = log10(number).floor(); 40 | return (number ~/ pow(10, log) + 1) * pow(10, log).toDouble(); 41 | } 42 | 43 | static double log10(num x) => log(x) / ln10; 44 | 45 | static String priceToString(double price) { 46 | return price.abs() > 1000 47 | ? price.toStringAsFixed(2) 48 | : price.abs() > 100 49 | ? price.toStringAsFixed(3) 50 | : price.abs() > 10 51 | ? price.toStringAsFixed(4) 52 | : price.abs() > 1 53 | ? price.toStringAsFixed(5) 54 | : price.toStringAsFixed(7); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/candlestick/utils/indicators/bollinger_bands_indicator.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | import 'dart:ui'; 3 | 4 | import '../../models/indicator.dart'; 5 | 6 | 7 | 8 | class BollingerBandsIndicator extends Indicator { 9 | BollingerBandsIndicator({ 10 | required int length, 11 | required int stdDev, 12 | required Color upperColor, 13 | required Color basisColor, 14 | required Color lowerColor, 15 | }) : super( 16 | name: "BB $length", 17 | dependsOnNPrevCandles: length, 18 | calculator: (index, candles) { 19 | double sum = 0; 20 | for (int i = index; i < index + length; i++) { 21 | sum += candles[i].close; 22 | } 23 | final average = sum / length; 24 | 25 | num sumOfSquaredDiffFromMean = 0; 26 | for (int i = index; i < index + length; i++) { 27 | final squareDiffFromMean = 28 | math.pow(candles[i].close - average, 2); 29 | sumOfSquaredDiffFromMean += squareDiffFromMean; 30 | } 31 | 32 | final variance = sumOfSquaredDiffFromMean / length; 33 | 34 | final standardDeviation = math.sqrt(variance); 35 | 36 | return [ 37 | average + standardDeviation * stdDev, 38 | average, 39 | average - standardDeviation * stdDev 40 | ]; 41 | }, 42 | indicatorComponentsStyles: [ 43 | IndicatorStyle(name: "upper", color: upperColor), 44 | IndicatorStyle(name: "basis", color: basisColor), 45 | IndicatorStyle(name: "lower", color: lowerColor) 46 | ], 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /lib/candlestick/utils/indicators/moving_average_indicator.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import '../../models/indicator.dart'; 4 | 5 | class MovingAverageIndicator extends Indicator { 6 | MovingAverageIndicator({ 7 | required int length, 8 | required Color color, 9 | }) : super( 10 | name: "MA $length", 11 | dependsOnNPrevCandles: length, 12 | calculator: (index, candles) { 13 | double sum = 0; 14 | for (int i = 0; i < length; i++) { 15 | sum += candles[i + index].close; 16 | } 17 | return [sum / length]; 18 | }, 19 | indicatorComponentsStyles: [ 20 | IndicatorStyle(name: "mv", color: color), 21 | ], 22 | ); 23 | } 24 | -------------------------------------------------------------------------------- /lib/candlestick/utils/indicators/weighted_moving_average.dart: -------------------------------------------------------------------------------- 1 | import 'dart:ui'; 2 | 3 | import '../../models/indicator.dart'; 4 | 5 | 6 | 7 | class WeightedMovingAverageIndicator extends Indicator { 8 | WeightedMovingAverageIndicator({ 9 | required int length, 10 | required Color color, 11 | }) : super( 12 | name: "WMA $length", 13 | dependsOnNPrevCandles: length, 14 | calculator: (index, candles) { 15 | double sum = 0; 16 | for (int i = 0; i < length; i++) { 17 | sum += candles[i + index].close * (length - i); 18 | } 19 | return [sum / (length * (length + 1)) * 2]; 20 | }, 21 | indicatorComponentsStyles: [ 22 | IndicatorStyle(name: "wmv", color: color), 23 | ], 24 | ); 25 | } 26 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/candle_info_text.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././models/candle.dart'; 4 | import '.././utils/helper_functions.dart'; 5 | 6 | class CandleInfoText extends StatelessWidget { 7 | final Candle candle; 8 | 9 | final Color bullColor; 10 | final Color bearColor; 11 | final TextStyle defaultStyle; 12 | const CandleInfoText({ 13 | Key? key, 14 | required this.candle, 15 | required this.bullColor, 16 | required this.bearColor, 17 | required this.defaultStyle, 18 | }) : super(key: key); 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return RichText( 23 | text: TextSpan( 24 | text: dateFormatter(candle.date), 25 | style: defaultStyle, 26 | children: [ 27 | const TextSpan(text: " O:"), 28 | TextSpan( 29 | text: HelperFunctions.priceToString(candle.open), 30 | style: TextStyle( 31 | color: candle.isBull ? bullColor : bearColor, 32 | ), 33 | ), 34 | const TextSpan(text: " H:"), 35 | TextSpan( 36 | text: HelperFunctions.priceToString(candle.high), 37 | style: TextStyle( 38 | color: candle.isBull ? bullColor : bearColor, 39 | ), 40 | ), 41 | const TextSpan(text: " L:"), 42 | TextSpan( 43 | text: HelperFunctions.priceToString(candle.low), 44 | style: TextStyle( 45 | color: candle.isBull ? bullColor : bearColor, 46 | ), 47 | ), 48 | const TextSpan(text: " C:"), 49 | TextSpan( 50 | text: HelperFunctions.priceToString(candle.close), 51 | style: TextStyle( 52 | color: candle.isBull ? bullColor : bearColor, 53 | ), 54 | ), 55 | ], 56 | ), 57 | ); 58 | } 59 | 60 | String dateFormatter(DateTime date) { 61 | return "${date.year}-${numberFormat(date.month)}-${numberFormat(date.day)} ${numberFormat(date.hour)}:${numberFormat(date.minute)}"; 62 | } 63 | 64 | String numberFormat(int value) { 65 | return "${value < 10 ? 0 : ""}$value"; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/candle_stick_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././models/candle.dart'; 4 | 5 | class CandleStickRenderObject extends RenderBox { 6 | late List _candles; 7 | late int _index; 8 | late double _candleWidth; 9 | late double _low; 10 | late double _high; 11 | late double _close; 12 | late Color _bullColor; 13 | late Color _bearColor; 14 | 15 | CandleStickRenderObject( 16 | List candles, 17 | int index, 18 | double candleWidth, 19 | double low, 20 | double high, 21 | Color bullColor, 22 | Color bearColor, 23 | ) { 24 | _candles = candles; 25 | _index = index; 26 | _candleWidth = candleWidth; 27 | _low = low; 28 | _high = high; 29 | _bearColor = bearColor; 30 | _bullColor = bullColor; 31 | } 32 | 33 | @override 34 | void paint(PaintingContext context, Offset offset) { 35 | double range = (_high - _low) / size.height; 36 | for (int i = 0; (i + 1) * _candleWidth < size.width; i++) { 37 | if (i + _index >= _candles.length || i + _index < 0) continue; 38 | var candle = _candles[i + _index]; 39 | paintCandle(context, offset, i, candle, range); 40 | } 41 | _close = _candles[0].close; 42 | context.canvas.save(); 43 | context.canvas.restore(); 44 | } 45 | 46 | /// draws a single candle 47 | void paintCandle(PaintingContext context, Offset offset, int index, 48 | Candle candle, double range) { 49 | Color color = candle.isBull ? _bullColor : _bearColor; 50 | 51 | Paint paint = Paint() 52 | ..color = color 53 | ..style = PaintingStyle.stroke 54 | ..strokeWidth = 1; 55 | 56 | double x = size.width + offset.dx - (index + 0.5) * _candleWidth; 57 | 58 | context.canvas.drawLine( 59 | Offset(x, offset.dy + (_high - candle.high) / range), 60 | Offset(x, offset.dy + (_high - candle.low) / range), 61 | paint, 62 | ); 63 | 64 | final double openCandleY = offset.dy + (_high - candle.open) / range; 65 | final double closeCandleY = offset.dy + (_high - candle.close) / range; 66 | 67 | if ((openCandleY - closeCandleY).abs() > 1) { 68 | context.canvas.drawLine( 69 | Offset(x, openCandleY), 70 | Offset(x, closeCandleY), 71 | paint..strokeWidth = _candleWidth * 0.8, 72 | ); 73 | } else { 74 | // if the candle body is too small 75 | final double mid = (closeCandleY + openCandleY) / 2; 76 | context.canvas.drawLine( 77 | Offset(x, mid - 0.5), 78 | Offset(x, mid + 0.5), 79 | paint..strokeWidth = _candleWidth * 0.8, 80 | ); 81 | } 82 | } 83 | 84 | /// set size as large as possible 85 | @override 86 | void performLayout() { 87 | size = Size(constraints.maxWidth, constraints.maxHeight); 88 | } 89 | } 90 | 91 | class CandleStickWidget extends LeafRenderObjectWidget { 92 | final List candles; 93 | final int index; 94 | final double candleWidth; 95 | final double high; 96 | final double low; 97 | final Color bullColor; 98 | final Color bearColor; 99 | 100 | const CandleStickWidget({super.key, 101 | required this.candles, 102 | required this.index, 103 | required this.candleWidth, 104 | required this.low, 105 | required this.high, 106 | required this.bearColor, 107 | required this.bullColor, 108 | }); 109 | 110 | @override 111 | RenderObject createRenderObject(BuildContext context) { 112 | return CandleStickRenderObject( 113 | candles, 114 | index, 115 | candleWidth, 116 | low, 117 | high, 118 | bullColor, 119 | bearColor, 120 | ); 121 | } 122 | 123 | @override 124 | void updateRenderObject( 125 | BuildContext context, covariant RenderObject renderObject) { 126 | CandleStickRenderObject candlestickRenderObject = 127 | renderObject as CandleStickRenderObject; 128 | 129 | if (index <= 0 && candlestickRenderObject._close != candles[0].close) { 130 | candlestickRenderObject._candles = candles; 131 | candlestickRenderObject._index = index; 132 | candlestickRenderObject._candleWidth = candleWidth; 133 | candlestickRenderObject._high = high; 134 | candlestickRenderObject._low = low; 135 | candlestickRenderObject._bullColor = bullColor; 136 | candlestickRenderObject._bearColor = bearColor; 137 | candlestickRenderObject.markNeedsPaint(); 138 | } else if (candlestickRenderObject._index != index || 139 | candlestickRenderObject._candleWidth != candleWidth || 140 | candlestickRenderObject._high != high || 141 | candlestickRenderObject._low != low) { 142 | candlestickRenderObject._candles = candles; 143 | candlestickRenderObject._index = index; 144 | candlestickRenderObject._candleWidth = candleWidth; 145 | candlestickRenderObject._high = high; 146 | candlestickRenderObject._low = low; 147 | candlestickRenderObject._bullColor = bullColor; 148 | candlestickRenderObject._bearColor = bearColor; 149 | candlestickRenderObject.markNeedsPaint(); 150 | } 151 | super.updateRenderObject(context, renderObject); 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/dash_line.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class DashLine extends StatelessWidget { 4 | final Axis direction; 5 | final double thickness; 6 | final double length; 7 | final Color color; 8 | 9 | const DashLine({ 10 | Key? key, 11 | required this.direction, 12 | required this.thickness, 13 | required this.length, 14 | required this.color, 15 | }) : super(key: key); 16 | 17 | @override 18 | Widget build(BuildContext context) { 19 | bool isVertical = direction == Axis.vertical; 20 | return SizedBox( 21 | height: isVertical ? length : thickness, 22 | width: isVertical ? thickness : length, 23 | child: ListView.builder( 24 | scrollDirection: direction, 25 | itemCount: length ~/ 2, 26 | itemBuilder: (context, index) { 27 | if (index % 2 == 0) { 28 | return SizedBox( 29 | width: isVertical ? null : 2, height: isVertical ? 2 : null); 30 | } 31 | return Container( 32 | width: isVertical ? thickness : 2, 33 | height: isVertical ? 2 : thickness, 34 | color: color, 35 | ); 36 | }), 37 | ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/mainwindow_indicator_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././models/main_window_indicator.dart'; 4 | 5 | class MainWindowIndicatorRenderObject extends RenderBox { 6 | late List _indicatorDatas; 7 | late int _index; 8 | late double _candleWidth; 9 | late double _low; 10 | late double _high; 11 | 12 | MainWindowIndicatorRenderObject( 13 | List indicatorDatas, 14 | int index, 15 | double candleWidth, 16 | double low, 17 | double high, 18 | ) { 19 | _indicatorDatas = indicatorDatas; 20 | _index = index; 21 | _candleWidth = candleWidth; 22 | _low = low; 23 | _high = high; 24 | } 25 | 26 | @override 27 | void paint(PaintingContext context, Offset offset) { 28 | double range = (_high - _low) / size.height; 29 | for (var element in _indicatorDatas) { 30 | if (element.visible == false) { 31 | continue; 32 | } 33 | Path? path; 34 | for (int i = 0; (i + 1) * _candleWidth < size.width; i++) { 35 | if (i + _index >= element.values.length || 36 | i + _index < 0 || 37 | element.values[i + _index] == null) continue; 38 | if (path == null) { 39 | path = Path() 40 | ..moveTo(size.width + offset.dx - (i + 0.5) * _candleWidth, 41 | offset.dy + (_high - element.values[i + _index]!) / range); 42 | } else { 43 | path.lineTo(size.width + offset.dx - (i + 0.5) * _candleWidth, 44 | offset.dy + (_high - element.values[i + _index]!) / range); 45 | } 46 | } 47 | if (path != null) { 48 | context.canvas.drawPath( 49 | path, 50 | Paint() 51 | ..color = element.color 52 | ..strokeWidth = 1 53 | ..style = PaintingStyle.stroke); 54 | } 55 | } 56 | 57 | context.canvas.save(); 58 | context.canvas.restore(); 59 | } 60 | 61 | /// set size as large as possible 62 | @override 63 | void performLayout() { 64 | size = Size(constraints.maxWidth, constraints.maxHeight); 65 | } 66 | } 67 | 68 | class MainWindowIndicatorWidget extends LeafRenderObjectWidget { 69 | final List indicatorDatas; 70 | final int index; 71 | final double candleWidth; 72 | final double high; 73 | final double low; 74 | 75 | const MainWindowIndicatorWidget({super.key, 76 | required this.indicatorDatas, 77 | required this.index, 78 | required this.candleWidth, 79 | required this.low, 80 | required this.high, 81 | }); 82 | 83 | @override 84 | RenderObject createRenderObject(BuildContext context) { 85 | return MainWindowIndicatorRenderObject( 86 | indicatorDatas, 87 | index, 88 | candleWidth, 89 | low, 90 | high, 91 | ); 92 | } 93 | 94 | @override 95 | void updateRenderObject( 96 | BuildContext context, covariant RenderObject renderObject) { 97 | MainWindowIndicatorRenderObject candlestickRenderObject = 98 | renderObject as MainWindowIndicatorRenderObject; 99 | 100 | candlestickRenderObject._indicatorDatas = indicatorDatas; 101 | candlestickRenderObject._index = index; 102 | candlestickRenderObject._candleWidth = candleWidth; 103 | candlestickRenderObject._high = high; 104 | candlestickRenderObject._low = low; 105 | candlestickRenderObject.markNeedsPaint(); 106 | super.updateRenderObject(context, renderObject); 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/mobile_chart.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math'; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import '.././constant/view_constants.dart'; 6 | import '.././models/main_window_indicator.dart'; 7 | import '.././utils/helper_functions.dart'; 8 | import '.././widgets/candle_stick_widget.dart'; 9 | import '.././widgets/mainwindow_indicator_widget.dart'; 10 | import '.././widgets/price_column.dart'; 11 | import '.././widgets/time_row.dart'; 12 | import '.././widgets/top_panel.dart'; 13 | import '.././widgets/volume_widget.dart'; 14 | import '../candlesticks.dart'; 15 | import '../models/candle.dart'; 16 | import '../models/candle_sticks_style.dart'; 17 | import 'dash_line.dart'; 18 | 19 | /// This widget manages gestures 20 | /// Calculates the highest and lowest price of visible candles. 21 | /// Updates right-hand side numbers. 22 | /// And pass values down to [CandleStickWidget]. 23 | class MobileChart extends StatefulWidget { 24 | /// onScaleUpdate callback 25 | /// called when user scales chart using buttons or scale gesture 26 | final Function onScaleUpdate; 27 | 28 | /// onHorizontalDragUpdate 29 | /// callback calls when user scrolls horizontally along the chart 30 | final Function onHorizontalDragUpdate; 31 | 32 | /// candleWidth controls the width of the single candles. 33 | /// range: [2...10] 34 | final double candleWidth; 35 | 36 | /// list of all candles to display in chart 37 | final List candles; 38 | 39 | /// index of the newest candle to be displayed 40 | /// changes when user scrolls along the chart 41 | final int index; 42 | 43 | /// holds main window indicators data and high and low prices. 44 | final MainWindowDataContainer mainWindowDataContainer; 45 | 46 | /// How chart price range will be adjusted when moving chart 47 | final ChartAdjust chartAdjust; 48 | 49 | final CandleSticksStyle style; 50 | 51 | final void Function(double) onPanDown; 52 | final void Function() onPanEnd; 53 | 54 | final void Function(String)? onRemoveIndicator; 55 | 56 | final Function() onReachEnd; 57 | 58 | const MobileChart({super.key, 59 | required this.style, 60 | required this.onScaleUpdate, 61 | required this.onHorizontalDragUpdate, 62 | required this.candleWidth, 63 | required this.candles, 64 | required this.index, 65 | required this.chartAdjust, 66 | required this.onPanDown, 67 | required this.onPanEnd, 68 | required this.onReachEnd, 69 | required this.mainWindowDataContainer, 70 | required this.onRemoveIndicator, 71 | }); 72 | 73 | @override 74 | State createState() => _MobileChartState(); 75 | } 76 | 77 | class _MobileChartState extends State { 78 | double? longPressX; 79 | double? longPressY; 80 | bool showIndicatorNames = false; 81 | double? manualScaleHigh; 82 | double? manualScaleLow; 83 | 84 | @override 85 | Widget build(BuildContext context) { 86 | return LayoutBuilder( 87 | builder: (context, constraints) { 88 | // determine charts width and height 89 | final double maxWidth = constraints.maxWidth - PRICE_BAR_WIDTH; 90 | final double maxHeight = constraints.maxHeight - DATE_BAR_HEIGHT; 91 | 92 | // visible candles start and end indexes 93 | final int candlesStartIndex = max(widget.index, 0); 94 | final int candlesEndIndex = min( 95 | maxWidth ~/ widget.candleWidth + widget.index, 96 | widget.candles.length - 1); 97 | 98 | if (candlesEndIndex == widget.candles.length - 1) { 99 | Future(() { 100 | widget.onReachEnd(); 101 | }); 102 | } 103 | 104 | List inRangeCandles = widget.candles 105 | .getRange(candlesStartIndex, candlesEndIndex + 1) 106 | .toList(); 107 | 108 | double candlesHighPrice = 0; 109 | double candlesLowPrice = 0; 110 | if (manualScaleHigh != null) { 111 | candlesHighPrice = manualScaleHigh!; 112 | candlesLowPrice = manualScaleLow!; 113 | } else if (widget.chartAdjust == ChartAdjust.visibleRange) { 114 | candlesHighPrice = widget.mainWindowDataContainer.highs 115 | .getRange(candlesStartIndex, candlesEndIndex + 1) 116 | .reduce(max); 117 | candlesLowPrice = widget.mainWindowDataContainer.lows 118 | .getRange(candlesStartIndex, candlesEndIndex + 1) 119 | .reduce(min); 120 | } else if (widget.chartAdjust == ChartAdjust.fullRange) { 121 | candlesHighPrice = widget.mainWindowDataContainer.highs.reduce(max); 122 | candlesLowPrice = widget.mainWindowDataContainer.lows.reduce(min); 123 | } 124 | 125 | if (candlesHighPrice == candlesLowPrice) { 126 | candlesHighPrice += 10; 127 | candlesLowPrice -= 10; 128 | } 129 | 130 | // calculate priceScale 131 | double chartHeight = maxHeight * 0.75 - 2 * MAIN_CHART_VERTICAL_PADDING; 132 | 133 | // calculate highest volume 134 | double volumeHigh = inRangeCandles.map((e) => e.volume).reduce(max); 135 | 136 | if (longPressX != null && longPressY != null) { 137 | longPressX = max(longPressX!, 0); 138 | longPressX = min(longPressX!, maxWidth); 139 | longPressY = max(longPressY!, 0); 140 | longPressY = min(longPressY!, maxHeight); 141 | } 142 | 143 | return TweenAnimationBuilder( 144 | tween: Tween(begin: candlesHighPrice, end: candlesHighPrice), 145 | duration: Duration(milliseconds: manualScaleHigh == null ? 300 : 0), 146 | builder: (context, double high, _) { 147 | return TweenAnimationBuilder( 148 | tween: Tween(begin: candlesLowPrice, end: candlesLowPrice), 149 | duration: 150 | Duration(milliseconds: manualScaleHigh == null ? 300 : 0), 151 | builder: (context, double low, _) { 152 | final currentCandle = longPressX == null 153 | ? null 154 | : widget.candles[min( 155 | max( 156 | (maxWidth - longPressX!) ~/ widget.candleWidth + 157 | widget.index, 158 | 0), 159 | widget.candles.length - 1)]; 160 | return Container( 161 | color: widget.style.background, 162 | child: Stack( 163 | children: [ 164 | TimeRow( 165 | style: widget.style, 166 | indicatorX: longPressX, 167 | candles: widget.candles, 168 | candleWidth: widget.candleWidth, 169 | indicatorTime: currentCandle?.date, 170 | index: widget.index, 171 | ), 172 | Column( 173 | children: [ 174 | Expanded( 175 | flex: 3, 176 | child: Stack( 177 | children: [ 178 | PriceColumn( 179 | style: widget.style, 180 | low: candlesLowPrice, 181 | high: candlesHighPrice, 182 | width: constraints.maxWidth, 183 | chartHeight: chartHeight, 184 | lastCandle: widget.candles[ 185 | widget.index < 0 ? 0 : widget.index], 186 | onScale: (delta) { 187 | if (manualScaleHigh == null) { 188 | manualScaleHigh = candlesHighPrice; 189 | manualScaleLow = candlesLowPrice; 190 | } 191 | setState(() { 192 | double deltaPrice = delta / 193 | chartHeight * 194 | (manualScaleHigh! - manualScaleLow!); 195 | manualScaleHigh = 196 | manualScaleHigh! + deltaPrice; 197 | manualScaleLow = 198 | manualScaleLow! - deltaPrice; 199 | }); 200 | }, 201 | ), 202 | Row( 203 | children: [ 204 | Expanded( 205 | child: Container( 206 | decoration: BoxDecoration( 207 | border: Border( 208 | right: BorderSide( 209 | color: widget.style.borderColor, 210 | width: 1, 211 | ), 212 | ), 213 | ), 214 | child: AnimatedPadding( 215 | duration: 216 | const Duration(milliseconds: 300), 217 | padding: const EdgeInsets.symmetric( 218 | vertical: 219 | MAIN_CHART_VERTICAL_PADDING), 220 | child: RepaintBoundary( 221 | child: Stack( 222 | children: [ 223 | MainWindowIndicatorWidget( 224 | indicatorDatas: widget 225 | .mainWindowDataContainer 226 | .indicatorComponentData, 227 | index: widget.index, 228 | candleWidth: 229 | widget.candleWidth, 230 | low: low, 231 | high: high, 232 | ), 233 | CandleStickWidget( 234 | candles: widget.candles, 235 | candleWidth: 236 | widget.candleWidth, 237 | index: widget.index, 238 | high: high, 239 | low: low, 240 | bearColor: 241 | widget.style.primaryBear, 242 | bullColor: 243 | widget.style.primaryBull, 244 | ), 245 | ], 246 | ), 247 | ), 248 | ), 249 | ), 250 | ), 251 | const SizedBox( 252 | width: PRICE_BAR_WIDTH, 253 | ), 254 | ], 255 | ), 256 | ], 257 | ), 258 | ), 259 | Expanded( 260 | flex: 1, 261 | child: Row( 262 | children: [ 263 | Expanded( 264 | child: Container( 265 | decoration: BoxDecoration( 266 | border: Border( 267 | right: BorderSide( 268 | color: widget.style.borderColor, 269 | width: 1, 270 | ), 271 | ), 272 | ), 273 | child: Padding( 274 | padding: const EdgeInsets.only(top: 10.0), 275 | child: VolumeWidget( 276 | candles: widget.candles, 277 | barWidth: widget.candleWidth, 278 | index: widget.index, 279 | high: 280 | HelperFunctions.getRoof(volumeHigh), 281 | bearColor: widget.style.secondaryBear, 282 | bullColor: widget.style.secondaryBull, 283 | ), 284 | ), 285 | ), 286 | ), 287 | SizedBox( 288 | width: PRICE_BAR_WIDTH, 289 | child: Column( 290 | crossAxisAlignment: 291 | CrossAxisAlignment.start, 292 | children: [ 293 | SizedBox( 294 | height: DATE_BAR_HEIGHT, 295 | child: Center( 296 | child: Row( 297 | children: [ 298 | Text( 299 | "-${HelperFunctions.addMetricPrefix(HelperFunctions.getRoof(volumeHigh))}", 300 | style: TextStyle( 301 | color: 302 | widget.style.borderColor, 303 | fontSize: 12, 304 | ), 305 | ), 306 | ], 307 | ), 308 | ), 309 | ), 310 | ], 311 | ), 312 | ), 313 | ], 314 | ), 315 | ), 316 | const SizedBox( 317 | height: DATE_BAR_HEIGHT, 318 | ), 319 | ], 320 | ), 321 | longPressY != null 322 | ? Positioned( 323 | top: longPressY! - 10, 324 | child: Row( 325 | children: [ 326 | DashLine( 327 | length: maxWidth, 328 | color: widget.style.borderColor, 329 | direction: Axis.horizontal, 330 | thickness: 0.5, 331 | ), 332 | Container( 333 | color: widget 334 | .style.hoverIndicatorBackgroundColor, 335 | width: PRICE_BAR_WIDTH, 336 | height: 20, 337 | child: Center( 338 | child: Text( 339 | longPressY! < maxHeight * 0.75 340 | ? HelperFunctions.priceToString( 341 | high - 342 | (longPressY! - 20) / 343 | (maxHeight * 0.75 - 344 | 40) * 345 | (high - low)) 346 | : HelperFunctions.addMetricPrefix( 347 | HelperFunctions.getRoof( 348 | volumeHigh) * 349 | (1 - 350 | (longPressY! - 351 | maxHeight * 352 | 0.75 - 353 | 10) / 354 | (maxHeight * 0.25 - 355 | 10))), 356 | style: TextStyle( 357 | color: 358 | widget.style.secondaryTextColor, 359 | fontSize: 12, 360 | ), 361 | ), 362 | ), 363 | ), 364 | ], 365 | ), 366 | ) 367 | : Container(), 368 | longPressX != null 369 | ? Positioned( 370 | right: (maxWidth - longPressX!) ~/ 371 | widget.candleWidth * 372 | widget.candleWidth + 373 | PRICE_BAR_WIDTH, 374 | child: Container( 375 | width: widget.candleWidth, 376 | height: maxHeight, 377 | color: widget.style.mobileCandleHoverColor, 378 | ), 379 | ) 380 | : Container(), 381 | Padding( 382 | padding: const EdgeInsets.only(right: 50, bottom: 20), 383 | child: GestureDetector( 384 | onLongPressEnd: (_) { 385 | setState(() { 386 | longPressX = null; 387 | longPressY = null; 388 | }); 389 | }, 390 | onScaleEnd: (_) { 391 | widget.onPanEnd(); 392 | }, 393 | onScaleUpdate: (details) { 394 | if (details.scale == 1) { 395 | widget.onHorizontalDragUpdate( 396 | details.focalPoint.dx); 397 | setState(() { 398 | if (manualScaleHigh != null) { 399 | double deltaPrice = 400 | details.focalPointDelta.dy / 401 | chartHeight * 402 | (manualScaleHigh! - manualScaleLow!); 403 | manualScaleHigh = 404 | manualScaleHigh! + deltaPrice; 405 | manualScaleLow = manualScaleLow! + deltaPrice; 406 | } 407 | }); 408 | } 409 | widget.onScaleUpdate(details.scale); 410 | }, 411 | onScaleStart: (details) { 412 | widget.onPanDown(details.localFocalPoint.dx); 413 | }, 414 | onLongPressStart: (LongPressStartDetails details) { 415 | setState(() { 416 | longPressX = details.localPosition.dx; 417 | longPressY = details.localPosition.dy; 418 | }); 419 | }, 420 | behavior: HitTestBehavior.translucent, 421 | onLongPressMoveUpdate: 422 | (LongPressMoveUpdateDetails details) { 423 | setState(() { 424 | longPressX = details.localPosition.dx; 425 | longPressY = details.localPosition.dy; 426 | }); 427 | }, 428 | ), 429 | ), 430 | Padding( 431 | padding: const EdgeInsets.symmetric( 432 | vertical: 4, horizontal: 12), 433 | child: TopPanel( 434 | style: widget.style, 435 | onRemoveIndicator: widget.onRemoveIndicator, 436 | currentCandle: currentCandle, 437 | indicators: widget.mainWindowDataContainer.indicators, 438 | toggleIndicatorVisibility: (indicatorName) { 439 | setState(() { 440 | widget.mainWindowDataContainer 441 | .toggleIndicatorVisibility(indicatorName); 442 | }); 443 | }, 444 | unvisibleIndicators: widget 445 | .mainWindowDataContainer.unvisibleIndicators, 446 | ), 447 | ), 448 | Positioned( 449 | right: 0, 450 | bottom: 0, 451 | width: PRICE_BAR_WIDTH, 452 | height: 20, 453 | child: ElevatedButton( 454 | style: ElevatedButton.styleFrom( 455 | padding: EdgeInsets.zero, 456 | backgroundColor: 457 | widget.style.hoverIndicatorBackgroundColor, 458 | ), 459 | onPressed: manualScaleHigh == null 460 | ? null 461 | : () { 462 | setState(() { 463 | manualScaleHigh = null; 464 | manualScaleLow = null; 465 | }); 466 | }, 467 | child: const Text("Auto"), 468 | ), 469 | ) 470 | ], 471 | ), 472 | ); 473 | }, 474 | ); 475 | }, 476 | ); 477 | }, 478 | ); 479 | } 480 | } 481 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/price_column.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././constant/view_constants.dart'; 4 | import '.././models/candle.dart'; 5 | import '.././models/candle_sticks_style.dart'; 6 | import '.././utils/helper_functions.dart'; 7 | 8 | class PriceColumn extends StatefulWidget { 9 | final double low; 10 | 11 | final double high; 12 | final double width; 13 | final double chartHeight; 14 | final Candle lastCandle; 15 | final void Function(double) onScale; 16 | final CandleSticksStyle style; 17 | const PriceColumn({ 18 | Key? key, 19 | required this.low, 20 | required this.high, 21 | required this.width, 22 | required this.chartHeight, 23 | required this.lastCandle, 24 | required this.onScale, 25 | required this.style, 26 | }) : super(key: key); 27 | 28 | @override 29 | State createState() => _PriceColumnState(); 30 | } 31 | 32 | class _PriceColumnState extends State { 33 | ScrollController scrollController = ScrollController(); 34 | 35 | @override 36 | Widget build(BuildContext context) { 37 | final double priceScale = HelperFunctions.calculatePriceScale( 38 | widget.chartHeight, widget.high, widget.low); 39 | final double priceTileHeight = 40 | widget.chartHeight / ((widget.high - widget.low) / priceScale); 41 | final double newHigh = (widget.high ~/ priceScale + 1) * priceScale; 42 | final double top = -priceTileHeight / priceScale * (newHigh - widget.high) + 43 | MAIN_CHART_VERTICAL_PADDING - 44 | priceTileHeight / 2; 45 | return GestureDetector( 46 | onVerticalDragUpdate: (details) { 47 | widget.onScale(details.delta.dy); 48 | }, 49 | child: AbsorbPointer( 50 | child: Stack( 51 | children: [ 52 | AnimatedPositioned( 53 | duration: const Duration(milliseconds: 300), 54 | top: top, 55 | height: 56 | widget.chartHeight + 2 * MAIN_CHART_VERTICAL_PADDING - top, 57 | width: widget.width, 58 | child: ListView( 59 | controller: scrollController, 60 | children: List.generate(20, (i) { 61 | return AnimatedContainer( 62 | duration: const Duration(milliseconds: 300), 63 | height: priceTileHeight, 64 | width: double.infinity, 65 | child: Center( 66 | child: Row( 67 | children: [ 68 | Container( 69 | width: widget.width - PRICE_BAR_WIDTH, 70 | height: 0.05, 71 | color: widget.style.borderColor, 72 | ), 73 | Expanded( 74 | child: Text( 75 | HelperFunctions.priceToString( 76 | newHigh - priceScale * i), 77 | textAlign: TextAlign.center, 78 | style: TextStyle( 79 | color: widget.style.primaryTextColor, 80 | fontSize: 11, 81 | ), 82 | ), 83 | ), 84 | ], 85 | ), 86 | ), 87 | ); 88 | }).toList(), 89 | ), 90 | ), 91 | AnimatedPositioned( 92 | duration: const Duration(milliseconds: 300), 93 | right: 0, 94 | top: calculatePriceIndicatorTopPadding( 95 | widget.chartHeight, 96 | widget.low, 97 | widget.high, 98 | ), 99 | child: Row( 100 | children: [ 101 | Container( 102 | color: widget.lastCandle.isBull 103 | ? widget.style.primaryBull 104 | : widget.style.primaryBear, 105 | width: PRICE_BAR_WIDTH, 106 | height: PRICE_INDICATOR_HEIGHT, 107 | child: Center( 108 | child: Text( 109 | HelperFunctions.priceToString(widget.lastCandle.close), 110 | style: TextStyle( 111 | color: widget.style.secondaryTextColor, 112 | fontSize: 11, 113 | ), 114 | ), 115 | ), 116 | ), 117 | ], 118 | ), 119 | ), 120 | ], 121 | ), 122 | ), 123 | ); 124 | } 125 | 126 | double calculatePriceIndicatorTopPadding( 127 | double chartHeight, double low, double high) { 128 | return chartHeight + 129 | 10 - 130 | (widget.lastCandle.close - low) / (high - low) * chartHeight - 131 | MAIN_CHART_VERTICAL_PADDING; 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/time_row.dart: -------------------------------------------------------------------------------- 1 | import 'dart:math' as math; 2 | 3 | import 'package:flutter/material.dart'; 4 | 5 | import '.././constant/view_constants.dart'; 6 | import '.././models/candle.dart'; 7 | import '.././models/candle_sticks_style.dart'; 8 | 9 | class TimeRow extends StatefulWidget { 10 | final List candles; 11 | final double candleWidth; 12 | final double? indicatorX; 13 | final DateTime? indicatorTime; 14 | final int index; 15 | final CandleSticksStyle style; 16 | 17 | const TimeRow({ 18 | Key? key, 19 | required this.candles, 20 | required this.candleWidth, 21 | this.indicatorX, 22 | required this.indicatorTime, 23 | required this.index, 24 | required this.style, 25 | }) : super(key: key); 26 | 27 | @override 28 | State createState() => _TimeRowState(); 29 | } 30 | 31 | class _TimeRowState extends State { 32 | final ScrollController _scrollController = ScrollController(); 33 | 34 | @override 35 | Widget build(BuildContext context) { 36 | int step = _stepCalculator(); 37 | final dif = 38 | widget.candles[0].date.difference(widget.candles[1].date) * step; 39 | return Padding( 40 | padding: const EdgeInsets.only(right: PRICE_BAR_WIDTH + 1.0), 41 | child: Stack( 42 | children: [ 43 | ListView.builder( 44 | physics: const NeverScrollableScrollPhysics(), 45 | itemCount: math.max(widget.candles.length, 1000), 46 | scrollDirection: Axis.horizontal, 47 | itemExtent: step * widget.candleWidth, 48 | controller: _scrollController, 49 | reverse: true, 50 | itemBuilder: (context, index) { 51 | DateTime time = _timeCalculator(step, index, dif); 52 | return Column( 53 | mainAxisSize: MainAxisSize.max, 54 | children: [ 55 | Expanded( 56 | child: Container( 57 | width: 0.05, 58 | color: widget.style.borderColor, 59 | ), 60 | ), 61 | dif.compareTo(const Duration(days: 1)) > 0 62 | ? _monthDayText(time, widget.style.primaryTextColor) 63 | : _hourMinuteText(time, widget.style.primaryTextColor), 64 | ], 65 | ); 66 | }, 67 | ), 68 | widget.indicatorX == null 69 | ? Container() 70 | : Positioned( 71 | bottom: 0, 72 | left: math.max(widget.indicatorX! - 55, 0), 73 | child: Container( 74 | color: widget.style.hoverIndicatorBackgroundColor, 75 | width: 110, 76 | height: 20, 77 | child: Center( 78 | child: Text( 79 | dateFormatter(widget.indicatorTime!), 80 | style: TextStyle( 81 | color: widget.style.secondaryTextColor, 82 | fontSize: 12, 83 | ), 84 | ), 85 | ), 86 | ), 87 | ), 88 | ], 89 | ), 90 | ); 91 | } 92 | 93 | String dateFormatter(DateTime date) { 94 | return "${date.year}-${numberFormat(date.month)}-${numberFormat(date.day)} ${numberFormat(date.hour)}:${numberFormat(date.minute)}"; 95 | } 96 | 97 | @override 98 | void didUpdateWidget(TimeRow oldWidget) { 99 | if (oldWidget.index != widget.index || 100 | oldWidget.candleWidth != widget.candleWidth) { 101 | _scrollController.jumpTo((widget.index + 10) * widget.candleWidth); 102 | } 103 | super.didUpdateWidget(oldWidget); 104 | } 105 | 106 | /// Fomats number as 2 digit integer 107 | String numberFormat(int value) { 108 | return "${value < 10 ? 0 : ""}$value"; 109 | } 110 | 111 | /// Hour/minute text widget 112 | Text _hourMinuteText(DateTime time, Color color) { 113 | return Text( 114 | "${numberFormat(time.hour)}:${numberFormat(time.minute)}", 115 | style: TextStyle( 116 | color: color, 117 | fontSize: 12, 118 | ), 119 | ); 120 | } 121 | 122 | /// Day/month text widget 123 | Text _monthDayText(DateTime time, Color color) { 124 | return Text( 125 | "${numberFormat(time.month)}/${numberFormat(time.day)}", 126 | style: TextStyle( 127 | color: color, 128 | fontSize: 12, 129 | ), 130 | ); 131 | } 132 | 133 | /// Calculates number of candles between two time indicator 134 | int _stepCalculator() { 135 | if (widget.candleWidth < 3) { 136 | return 31; 137 | } else if (widget.candleWidth < 5) { 138 | return 19; 139 | } else if (widget.candleWidth < 7) { 140 | return 13; 141 | } else { 142 | return 9; 143 | } 144 | } 145 | 146 | /// Calculates [DateTime] of a given candle index 147 | DateTime _timeCalculator(int step, int index, Duration dif) { 148 | int candleNumber = (step + 1) ~/ 2 - 10 + index * step + -1; 149 | DateTime? time; 150 | if (candleNumber < 0) { 151 | time = widget.candles[0].date.add(Duration( 152 | milliseconds: dif.inMilliseconds ~/ -1 * step * candleNumber)); 153 | } else if (candleNumber < widget.candles.length) { 154 | time = widget.candles[candleNumber].date; 155 | } else { 156 | time = widget.candles[0].date.subtract( 157 | Duration(milliseconds: dif.inMilliseconds ~/ step * candleNumber)); 158 | } 159 | return time; 160 | } 161 | } 162 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/toolbar.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ToolBar extends StatelessWidget { 4 | const ToolBar({Key? key, required this.children, required this.color}) 5 | : super(key: key); 6 | 7 | final List children; 8 | final Color color; 9 | 10 | @override 11 | Widget build(BuildContext context) { 12 | return Container( 13 | color: color, 14 | child: Padding( 15 | padding: const EdgeInsets.all(2.0), 16 | child: Row( 17 | children: children, 18 | ), 19 | ), 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/toolbar_action.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | /// Top toolbar button widget. 4 | class ToolBarAction extends StatelessWidget { 5 | final void Function() onPressed; 6 | final Widget child; 7 | final double width; 8 | final Color? color; 9 | 10 | const ToolBarAction({ 11 | Key? key, 12 | required this.child, 13 | required this.onPressed, 14 | this.width = 30, 15 | this.color, 16 | }) : super(key: key); 17 | 18 | @override 19 | Widget build(BuildContext context) { 20 | return SizedBox( 21 | width: width, 22 | height: 30, 23 | child: RawMaterialButton( 24 | elevation: 0, 25 | fillColor: color, 26 | onPressed: onPressed, 27 | child: Center(child: child), 28 | ), 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/top_panel.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././models/candle.dart'; 4 | import '.././models/candle_sticks_style.dart'; 5 | import '.././models/indicator.dart'; 6 | import '.././widgets/candle_info_text.dart'; 7 | 8 | class TopPanel extends StatefulWidget { 9 | final Candle? currentCandle; 10 | 11 | final List indicators; 12 | final void Function(String indicatorName) toggleIndicatorVisibility; 13 | final List unvisibleIndicators; 14 | final void Function(String indicatorName)? onRemoveIndicator; 15 | final CandleSticksStyle style; 16 | const TopPanel({ 17 | Key? key, 18 | required this.currentCandle, 19 | required this.indicators, 20 | required this.toggleIndicatorVisibility, 21 | required this.unvisibleIndicators, 22 | required this.onRemoveIndicator, 23 | required this.style, 24 | }) : super(key: key); 25 | 26 | @override 27 | State createState() => _TopPanelState(); 28 | } 29 | 30 | class _PanelButton extends StatelessWidget { 31 | final Widget child; 32 | 33 | final Color borderColor; 34 | const _PanelButton({ 35 | Key? key, 36 | required this.child, 37 | required this.borderColor, 38 | }) : super(key: key); 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return Padding( 43 | padding: const EdgeInsets.symmetric(vertical: 5.0), 44 | child: Row( 45 | children: [ 46 | Container( 47 | height: 25, 48 | padding: const EdgeInsets.symmetric(horizontal: 8), 49 | decoration: BoxDecoration( 50 | border: Border.all( 51 | color: borderColor, 52 | ), 53 | borderRadius: const BorderRadius.all( 54 | Radius.circular(5), 55 | ), 56 | ), 57 | child: Center(child: child), 58 | ), 59 | ], 60 | ), 61 | ); 62 | } 63 | } 64 | 65 | class _TopPanelState extends State { 66 | bool showIndicatorNames = false; 67 | 68 | @override 69 | Widget build(BuildContext context) { 70 | return DefaultTextStyle( 71 | style: TextStyle(color: widget.style.primaryTextColor), 72 | child: Column( 73 | crossAxisAlignment: CrossAxisAlignment.start, 74 | children: [ 75 | SizedBox( 76 | height: 20, 77 | child: widget.currentCandle != null 78 | ? CandleInfoText( 79 | candle: widget.currentCandle!, 80 | bullColor: widget.style.primaryBull, 81 | bearColor: widget.style.primaryBear, 82 | defaultStyle: TextStyle( 83 | color: widget.style.borderColor, fontSize: 10), 84 | ) 85 | : Container(), 86 | ), 87 | showIndicatorNames || widget.indicators.length == 1 88 | ? Column( 89 | children: widget.indicators 90 | .map( 91 | (e) => _PanelButton( 92 | borderColor: widget.style.borderColor, 93 | child: Row( 94 | children: [ 95 | Text(e.name), 96 | const SizedBox( 97 | width: 10, 98 | ), 99 | GestureDetector( 100 | onTap: () { 101 | widget.toggleIndicatorVisibility(e.name); 102 | }, 103 | child: widget.unvisibleIndicators 104 | .contains(e.name) 105 | ? Icon( 106 | Icons.visibility_off_outlined, 107 | size: 16, 108 | color: widget.style.primaryTextColor, 109 | ) 110 | : Icon(Icons.visibility_outlined, 111 | size: 16, 112 | color: widget.style.primaryTextColor), 113 | ), 114 | const SizedBox( 115 | width: 10, 116 | ), 117 | widget.onRemoveIndicator != null 118 | ? GestureDetector( 119 | onTap: () { 120 | widget.onRemoveIndicator!(e.name); 121 | }, 122 | child: Icon(Icons.close, 123 | size: 16, 124 | color: widget.style.primaryTextColor), 125 | ) 126 | : Container(), 127 | ], 128 | ), 129 | ), 130 | ) 131 | .toList(), 132 | ) 133 | : Container(), 134 | widget.indicators.length > 1 135 | ? GestureDetector( 136 | onTap: () { 137 | setState(() { 138 | showIndicatorNames = !showIndicatorNames; 139 | }); 140 | }, 141 | child: _PanelButton( 142 | borderColor: widget.style.borderColor, 143 | child: Row( 144 | children: [ 145 | Icon( 146 | showIndicatorNames 147 | ? Icons.keyboard_arrow_up_rounded 148 | : Icons.keyboard_arrow_down_rounded, 149 | color: widget.style.primaryTextColor), 150 | Text(widget.indicators.length.toString()), 151 | ], 152 | ), 153 | ), 154 | ) 155 | : Container(), 156 | ], 157 | ), 158 | ); 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /lib/candlestick/widgets/volume_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '.././models/candle.dart'; 4 | 5 | class VolumeRenderObject extends RenderBox { 6 | late List _candles; 7 | late int _index; 8 | late double _barWidth; 9 | late double _high; 10 | late Color _bearColor; 11 | late Color _bullColor; 12 | 13 | VolumeRenderObject( 14 | List candles, 15 | int index, 16 | double barWidth, 17 | double high, 18 | Color bearColor, 19 | Color bullColor, 20 | ) { 21 | _candles = candles; 22 | _index = index; 23 | _barWidth = barWidth; 24 | _high = high; 25 | _bearColor = bearColor; 26 | _bullColor = bullColor; 27 | } 28 | 29 | @override 30 | void paint(PaintingContext context, Offset offset) { 31 | double range = (_high) / size.height; 32 | for (int i = 0; (i + 1) * _barWidth < size.width; i++) { 33 | if (i + _index >= _candles.length || i + _index < 0) continue; 34 | var candle = _candles[i + _index]; 35 | paintBar(context, offset, i, candle, range); 36 | } 37 | context.canvas.save(); 38 | context.canvas.restore(); 39 | } 40 | 41 | /// draws a single candle 42 | void paintBar(PaintingContext context, Offset offset, int index, 43 | Candle candle, double range) { 44 | Color color = candle.isBull ? _bullColor : _bearColor; 45 | 46 | double x = size.width + offset.dx - (index + 0.5) * _barWidth; 47 | 48 | context.canvas.drawLine( 49 | Offset(x, offset.dy + (_high - candle.volume) / range), 50 | Offset(x, offset.dy + size.height), 51 | Paint() 52 | ..color = color 53 | ..strokeWidth = _barWidth - 1); 54 | } 55 | 56 | /// set size as large as possible 57 | @override 58 | void performLayout() { 59 | size = Size(constraints.maxWidth, constraints.maxHeight); 60 | } 61 | } 62 | 63 | class VolumeWidget extends LeafRenderObjectWidget { 64 | final List candles; 65 | final int index; 66 | final double barWidth; 67 | final double high; 68 | final Color bullColor; 69 | final Color bearColor; 70 | 71 | const VolumeWidget({super.key, 72 | required this.candles, 73 | required this.index, 74 | required this.barWidth, 75 | required this.high, 76 | required this.bearColor, 77 | required this.bullColor, 78 | }); 79 | 80 | @override 81 | RenderObject createRenderObject(BuildContext context) { 82 | return VolumeRenderObject( 83 | candles, 84 | index, 85 | barWidth, 86 | high, 87 | bearColor, 88 | bullColor, 89 | ); 90 | } 91 | 92 | @override 93 | void updateRenderObject( 94 | BuildContext context, covariant RenderObject renderObject) { 95 | VolumeRenderObject candlestickRenderObject = 96 | renderObject as VolumeRenderObject; 97 | candlestickRenderObject._candles = candles; 98 | candlestickRenderObject._index = index; 99 | candlestickRenderObject._barWidth = barWidth; 100 | candlestickRenderObject._high = high; 101 | candlestickRenderObject._bearColor = bearColor; 102 | candlestickRenderObject._bullColor = bullColor; 103 | candlestickRenderObject.markNeedsPaint(); 104 | super.updateRenderObject(context, renderObject); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /lib/data.dart: -------------------------------------------------------------------------------- 1 | // var data={ 2 | // e: kline, 3 | // E: 1663795903126, 4 | // s: ETHBTC, 5 | // k: { 6 | // t: 1663795860000, 7 | // T: 1663795919999, 8 | // s: ETHBTC, 9 | // i: 1m, 10 | // f: 376189553, 11 | // L: 376189864, 12 | // o: 0.06796300, 13 | // c: 0.06807500, 14 | // h: 0.06807500, 15 | // l: 0.06795800, 16 | // v: 61.31830000, 17 | // n: 312, 18 | // x: false, 19 | // q: 4.17047917, 20 | // V: 54.02020000, 21 | // Q: 3.67425390, 22 | // B: 0 23 | // } 24 | // }; -------------------------------------------------------------------------------- /lib/main.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: library_private_types_in_public_api 2 | 3 | import 'dart:convert'; 4 | 5 | import 'package:flutter/material.dart'; 6 | import 'package:web_socket_channel/web_socket_channel.dart'; 7 | 8 | import './candle_ticker_model.dart'; 9 | import './candlestick/candlesticks.dart'; 10 | import './repository.dart'; 11 | import 'candlestick/models/candle.dart'; 12 | import 'candlestick/models/indicator.dart'; 13 | import 'candlestick/utils/indicators/bollinger_bands_indicator.dart'; 14 | import 'candlestick/utils/indicators/weighted_moving_average.dart'; 15 | import 'candlestick/widgets/toolbar_action.dart'; 16 | 17 | void main() { 18 | runApp(const MyApp()); 19 | } 20 | 21 | class CustomTextField extends StatelessWidget { 22 | final void Function(String) onChanged; 23 | const CustomTextField({Key? key, required this.onChanged}) : super(key: key); 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return TextField( 28 | autofocus: true, 29 | cursorColor: const Color(0xFF494537), 30 | decoration: const InputDecoration( 31 | prefixIcon: Icon( 32 | Icons.search, 33 | color: Color(0xFF494537), 34 | ), 35 | enabledBorder: OutlineInputBorder( 36 | borderSide: 37 | BorderSide(width: 3, color: Color(0xFF494537)), //<-- SEE HER 38 | ), 39 | border: OutlineInputBorder( 40 | borderSide: 41 | BorderSide(width: 3, color: Color(0xFF494537)), //<-- SEE HER 42 | ), 43 | focusedBorder: OutlineInputBorder( 44 | borderSide: 45 | BorderSide(width: 3, color: Color(0xFF494537)), //<-- SEE HER 46 | ), 47 | ), 48 | onChanged: onChanged, 49 | ); 50 | } 51 | } 52 | 53 | class MyApp extends StatefulWidget { 54 | const MyApp({Key? key}) : super(key: key); 55 | 56 | @override 57 | _MyAppState createState() => _MyAppState(); 58 | } 59 | 60 | class SymbolsSearchModal extends StatefulWidget { 61 | final Function(String symbol) onSelect; 62 | 63 | final List symbols; 64 | const SymbolsSearchModal({ 65 | Key? key, 66 | required this.onSelect, 67 | required this.symbols, 68 | }) : super(key: key); 69 | 70 | @override 71 | State createState() => _SymbolSearchModalState(); 72 | } 73 | 74 | class _MyAppState extends State { 75 | BinanceRepository repository = BinanceRepository(); 76 | 77 | List candles = []; 78 | WebSocketChannel? _channel; 79 | bool themeIsDark = true; 80 | String currentInterval = "1m"; 81 | final intervals = [ 82 | '1m', 83 | '3m', 84 | '5m', 85 | '15m', 86 | '30m', 87 | '1h', 88 | '2h', 89 | '4h', 90 | '6h', 91 | '8h', 92 | '12h', 93 | '1d', 94 | '3d', 95 | '1w', 96 | '1M', 97 | ]; 98 | List symbols = []; 99 | String currentSymbol = ""; 100 | List indicators = [ 101 | BollingerBandsIndicator( 102 | length: 20, 103 | stdDev: 2, 104 | upperColor: const Color(0xFF2962FF), 105 | basisColor: const Color(0xFFFF6D00), 106 | lowerColor: const Color(0xFF2962FF), 107 | ), 108 | WeightedMovingAverageIndicator( 109 | length: 100, 110 | color: Colors.green.shade600, 111 | ), 112 | ]; 113 | 114 | @override 115 | Widget build(BuildContext context) { 116 | return MaterialApp( 117 | title: 'Flutter Trading App', 118 | theme: themeIsDark ? ThemeData.dark() : ThemeData.light(), 119 | debugShowCheckedModeBanner: false, 120 | home: Scaffold( 121 | appBar: AppBar( 122 | backgroundColor: themeIsDark ? Colors.blueGrey[900] : Colors.amber, 123 | title: Text( 124 | "Finance Trading Analytics", 125 | style: TextStyle( 126 | color: themeIsDark ? Colors.white : Colors.black, 127 | ), 128 | ), 129 | actions: [ 130 | IconButton( 131 | onPressed: () { 132 | setState(() { 133 | themeIsDark = !themeIsDark; 134 | }); 135 | }, 136 | icon: Icon( 137 | themeIsDark 138 | ? Icons.wb_sunny_sharp 139 | : Icons.nightlight_round_outlined, 140 | ), 141 | ) 142 | ], 143 | ), 144 | body: Center( 145 | child: StreamBuilder( 146 | stream: _channel == null ? null : _channel!.stream, 147 | builder: (context, snapshot) { 148 | updateCandlesFromSnapshot(snapshot); 149 | return Column( 150 | children: [ 151 | Container( 152 | color: themeIsDark ? const Color(0xFF191B20) : Colors.white, 153 | height: 80, 154 | width: double.maxFinite, 155 | child: Padding( 156 | padding: const EdgeInsets.only(left: 20, right: 20), 157 | child: Row( 158 | mainAxisAlignment: MainAxisAlignment.start, 159 | crossAxisAlignment: CrossAxisAlignment.center, 160 | mainAxisSize: MainAxisSize.min, 161 | children: [ 162 | if (!snapshot.hasData) 163 | const Text( 164 | 'Loading... ', 165 | style: TextStyle(color: Colors.grey), 166 | ), 167 | if (snapshot.hasData) 168 | InkWell( 169 | onTap: () { 170 | showModalBottomSheet( 171 | backgroundColor: Colors.transparent, 172 | context: context, 173 | builder: (context) { 174 | return SymbolsSearchModal( 175 | onSelect: (symbol) { 176 | setState(() { 177 | currentSymbol = symbol; 178 | fetchCandles(symbol, currentInterval); 179 | }); 180 | }, 181 | symbols: symbols, 182 | ); 183 | }, 184 | ); 185 | }, 186 | child: Text( 187 | currentSymbol, 188 | style: const TextStyle( 189 | fontSize: 20, 190 | ), 191 | ), 192 | ), 193 | const SizedBox(width: 20), 194 | Column( 195 | mainAxisAlignment: MainAxisAlignment.center, 196 | crossAxisAlignment: CrossAxisAlignment.center, 197 | children: [ 198 | Text( 199 | candles.isNotEmpty 200 | ? candles.last.close.toStringAsFixed(2) 201 | : "0.00", 202 | style: TextStyle( 203 | fontSize: 15, 204 | color: candles.isNotEmpty 205 | ? candles.last.close > 206 | candles[candles.length - 2].close 207 | ? Colors.green 208 | : Colors.red 209 | : Colors.grey, 210 | ), 211 | ), 212 | const SizedBox(height: 5), 213 | Text( 214 | "\$${candles.isNotEmpty ? candles.last.close.toStringAsFixed(2) : ""}", 215 | style: const TextStyle( 216 | fontSize: 12, 217 | ), 218 | ), 219 | ], 220 | ), 221 | const SizedBox(width: 10), 222 | Column( 223 | mainAxisAlignment: MainAxisAlignment.center, 224 | crossAxisAlignment: CrossAxisAlignment.center, 225 | children: [ 226 | const Text( 227 | 'Open', 228 | style: TextStyle( 229 | fontSize: 12, 230 | color: Colors.grey, 231 | ), 232 | ), 233 | const SizedBox(height: 5), 234 | Text(candles.isNotEmpty 235 | ? candles.last.open.toStringAsFixed(2) 236 | : "0.00"), 237 | ], 238 | ), 239 | const SizedBox(width: 10), 240 | Column( 241 | mainAxisAlignment: MainAxisAlignment.center, 242 | crossAxisAlignment: CrossAxisAlignment.center, 243 | children: [ 244 | const Text( 245 | 'Close', 246 | style: TextStyle( 247 | fontSize: 12, 248 | color: Colors.grey, 249 | ), 250 | ), 251 | const SizedBox(height: 5), 252 | Text(candles.isNotEmpty 253 | ? candles.last.close.toStringAsFixed(2) 254 | : "0.00"), 255 | ], 256 | ), 257 | const SizedBox(width: 10), 258 | Column( 259 | mainAxisAlignment: MainAxisAlignment.center, 260 | crossAxisAlignment: CrossAxisAlignment.center, 261 | children: [ 262 | const Text( 263 | 'High', 264 | style: TextStyle( 265 | fontSize: 12, 266 | color: Colors.grey, 267 | ), 268 | ), 269 | const SizedBox(height: 5), 270 | Text(candles.isNotEmpty 271 | ? candles.last.high.toStringAsFixed(2) 272 | : "0.00"), 273 | ], 274 | ), 275 | const SizedBox(width: 10), 276 | Column( 277 | mainAxisAlignment: MainAxisAlignment.center, 278 | crossAxisAlignment: CrossAxisAlignment.center, 279 | children: [ 280 | const Text( 281 | 'Low', 282 | style: TextStyle( 283 | fontSize: 12, 284 | color: Colors.grey, 285 | ), 286 | ), 287 | const SizedBox(height: 5), 288 | Text(candles.isNotEmpty 289 | ? candles.last.low.toStringAsFixed(2) 290 | : "0.00"), 291 | ], 292 | ), 293 | const SizedBox(width: 10), 294 | Column( 295 | mainAxisAlignment: MainAxisAlignment.center, 296 | crossAxisAlignment: CrossAxisAlignment.center, 297 | children: [ 298 | const Text( 299 | 'Change', 300 | style: TextStyle( 301 | fontSize: 12, 302 | color: Colors.grey, 303 | ), 304 | ), 305 | const SizedBox(height: 5), 306 | Text(candles.isNotEmpty 307 | ? (candles.last.close - candles.last.open) 308 | .toStringAsFixed(2) 309 | : "0.00"), 310 | ], 311 | ), 312 | ], 313 | ), 314 | ), 315 | ), 316 | // Show Streaming data in json form 317 | // Text(snapshot.hasData ? '${snapshot.data}' : ''), 318 | const Divider( 319 | height: 1, 320 | color: Colors.grey, 321 | ), 322 | Expanded( 323 | child: Candlesticks( 324 | key: Key(currentSymbol + currentInterval), 325 | indicators: indicators, 326 | candles: candles, 327 | onLoadMoreCandles: loadMoreCandles, 328 | onRemoveIndicator: (String indicator) { 329 | setState(() { 330 | indicators = [...indicators]; 331 | indicators.removeWhere( 332 | (element) => element.name == indicator); 333 | }); 334 | }, 335 | actions: [ 336 | ToolBarAction( 337 | onPressed: () { 338 | showDialog( 339 | context: context, 340 | builder: (context) { 341 | return Center( 342 | child: Container( 343 | width: 200, 344 | color: Theme.of(context).backgroundColor, 345 | child: Wrap( 346 | children: intervals 347 | .map((e) => Padding( 348 | padding: 349 | const EdgeInsets.all(8.0), 350 | child: SizedBox( 351 | width: 50, 352 | height: 30, 353 | child: RawMaterialButton( 354 | elevation: 0, 355 | fillColor: 356 | const Color(0xFF494537), 357 | onPressed: () { 358 | fetchCandles( 359 | currentSymbol, e); 360 | Navigator.of(context) 361 | .pop(); 362 | }, 363 | child: Text( 364 | e, 365 | style: const TextStyle( 366 | color: 367 | Color(0xFFF0B90A), 368 | ), 369 | ), 370 | ), 371 | ), 372 | )) 373 | .toList(), 374 | ), 375 | ), 376 | ); 377 | }, 378 | ); 379 | }, 380 | child: Text( 381 | currentInterval, 382 | ), 383 | ), 384 | ToolBarAction( 385 | width: 100, 386 | onPressed: () { 387 | showDialog( 388 | context: context, 389 | builder: (context) { 390 | return SymbolsSearchModal( 391 | symbols: symbols, 392 | onSelect: (value) { 393 | fetchCandles(value, currentInterval); 394 | }, 395 | ); 396 | }, 397 | ); 398 | }, 399 | child: Text( 400 | currentSymbol, 401 | ), 402 | ) 403 | ], 404 | ), 405 | ), 406 | ], 407 | ); 408 | }, 409 | ), 410 | ), 411 | ), 412 | ); 413 | } 414 | 415 | @override 416 | void dispose() { 417 | if (_channel != null) _channel!.sink.close(); 418 | super.dispose(); 419 | } 420 | 421 | Future fetchCandles(String symbol, String interval) async { 422 | // close current channel if exists 423 | if (_channel != null) { 424 | _channel!.sink.close(); 425 | _channel = null; 426 | } 427 | // clear last candle list 428 | setState(() { 429 | candles = []; 430 | currentInterval = interval; 431 | }); 432 | 433 | try { 434 | // load candles info 435 | final data = 436 | await repository.fetchCandles(symbol: symbol, interval: interval); 437 | // connect to binance stream 438 | _channel = 439 | repository.establishConnection(symbol.toLowerCase(), currentInterval); 440 | // update candles 441 | setState(() { 442 | candles = data; 443 | currentInterval = interval; 444 | currentSymbol = symbol; 445 | }); 446 | } catch (e) { 447 | // handle error 448 | return; 449 | } 450 | } 451 | 452 | Future> fetchSymbols() async { 453 | try { 454 | // load candles info 455 | final data = await repository.fetchSymbols(); 456 | return data; 457 | } catch (e) { 458 | // handle error 459 | return []; 460 | } 461 | } 462 | 463 | @override 464 | void initState() { 465 | fetchSymbols().then((value) { 466 | symbols = value; 467 | if (symbols.isNotEmpty) fetchCandles(symbols[0], currentInterval); 468 | }); 469 | super.initState(); 470 | } 471 | 472 | Future loadMoreCandles() async { 473 | try { 474 | // load candles info 475 | final data = await repository.fetchCandles( 476 | symbol: currentSymbol, 477 | interval: currentInterval, 478 | endTime: candles.last.date.millisecondsSinceEpoch); 479 | candles.removeLast(); 480 | setState(() { 481 | candles.addAll(data); 482 | }); 483 | } catch (e) { 484 | // handle error 485 | return; 486 | } 487 | } 488 | 489 | void updateCandlesFromSnapshot(AsyncSnapshot snapshot) { 490 | if (candles.isEmpty) return; 491 | if (snapshot.data != null) { 492 | final map = jsonDecode(snapshot.data as String) as Map; 493 | if (map.containsKey("k") == true) { 494 | final candleTicker = CandleTickerModel.fromJson(map); 495 | 496 | // cehck if incoming candle is an update on current last candle, or a new one 497 | if (candles[0].date == candleTicker.candle.date && 498 | candles[0].open == candleTicker.candle.open) { 499 | // update last candle 500 | candles[0] = candleTicker.candle; 501 | } 502 | // check if incoming new candle is next candle so the difrence 503 | // between times must be the same as last existing 2 candles 504 | else if (candleTicker.candle.date.difference(candles[0].date) == 505 | candles[0].date.difference(candles[1].date)) { 506 | // add new candle to list 507 | candles.insert(0, candleTicker.candle); 508 | } 509 | } 510 | } 511 | } 512 | } 513 | 514 | class _SymbolSearchModalState extends State { 515 | String symbolSearch = ""; 516 | @override 517 | Widget build(BuildContext context) { 518 | return Center( 519 | child: Material( 520 | color: Colors.transparent, 521 | child: Container( 522 | width: 300, 523 | height: MediaQuery.of(context).size.height * 0.75, 524 | color: Theme.of(context).backgroundColor.withOpacity(0.5), 525 | child: Column( 526 | children: [ 527 | Padding( 528 | padding: const EdgeInsets.all(8.0), 529 | child: CustomTextField( 530 | onChanged: (value) { 531 | setState(() { 532 | symbolSearch = value; 533 | }); 534 | }, 535 | ), 536 | ), 537 | Expanded( 538 | child: ListView( 539 | children: widget.symbols 540 | .where((element) => element 541 | .toLowerCase() 542 | .contains(symbolSearch.toLowerCase())) 543 | .map((e) => Padding( 544 | padding: const EdgeInsets.all(8.0), 545 | child: SizedBox( 546 | width: 50, 547 | height: 30, 548 | child: RawMaterialButton( 549 | elevation: 0, 550 | fillColor: const Color(0xFF494537), 551 | onPressed: () { 552 | widget.onSelect(e); 553 | Navigator.of(context).pop(); 554 | }, 555 | child: Text( 556 | e, 557 | style: const TextStyle( 558 | color: Color(0xFFF0B90A), 559 | ), 560 | ), 561 | ), 562 | ), 563 | )) 564 | .toList(), 565 | ), 566 | ), 567 | ], 568 | ), 569 | ), 570 | ), 571 | ); 572 | } 573 | } 574 | -------------------------------------------------------------------------------- /lib/repository.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:http/http.dart' as http; 4 | import 'package:web_socket_channel/web_socket_channel.dart'; 5 | 6 | import 'candlestick/models/candle.dart'; 7 | 8 | class BinanceRepository { 9 | WebSocketChannel establishConnection(String symbol, String interval) { 10 | final channel = WebSocketChannel.connect( 11 | Uri.parse('wss://stream.binance.com:9443/ws'), 12 | ); 13 | channel.sink.add( 14 | jsonEncode( 15 | { 16 | "method": "SUBSCRIBE", 17 | "params": ["$symbol@kline_$interval"], 18 | "id": 1 19 | }, 20 | ), 21 | ); 22 | return channel; 23 | } 24 | 25 | Future> fetchCandles( 26 | {required String symbol, required String interval, int? endTime}) async { 27 | final uri = Uri.parse( 28 | "https://api.binance.com/api/v3/klines?symbol=$symbol&interval=$interval${endTime != null ? "&endTime=$endTime" : ""}"); 29 | final res = await http.get(uri); 30 | return (jsonDecode(res.body) as List) 31 | .map((e) => Candle.fromJson(e)) 32 | .toList() 33 | .reversed 34 | .toList(); 35 | } 36 | 37 | Future> fetchSymbols() async { 38 | final uri = Uri.parse("https://api.binance.com/api/v3/ticker/price"); 39 | final res = await http.get(uri); 40 | return (jsonDecode(res.body) as List) 41 | .map((e) => e["symbol"] as String) 42 | .toList(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | async: 5 | dependency: transitive 6 | description: 7 | name: async 8 | url: "https://pub.dartlang.org" 9 | source: hosted 10 | version: "2.9.0" 11 | boolean_selector: 12 | dependency: transitive 13 | description: 14 | name: boolean_selector 15 | url: "https://pub.dartlang.org" 16 | source: hosted 17 | version: "2.1.0" 18 | characters: 19 | dependency: transitive 20 | description: 21 | name: characters 22 | url: "https://pub.dartlang.org" 23 | source: hosted 24 | version: "1.2.1" 25 | clock: 26 | dependency: transitive 27 | description: 28 | name: clock 29 | url: "https://pub.dartlang.org" 30 | source: hosted 31 | version: "1.1.1" 32 | collection: 33 | dependency: transitive 34 | description: 35 | name: collection 36 | url: "https://pub.dartlang.org" 37 | source: hosted 38 | version: "1.16.0" 39 | crypto: 40 | dependency: transitive 41 | description: 42 | name: crypto 43 | url: "https://pub.dartlang.org" 44 | source: hosted 45 | version: "3.0.2" 46 | cupertino_icons: 47 | dependency: "direct main" 48 | description: 49 | name: cupertino_icons 50 | url: "https://pub.dartlang.org" 51 | source: hosted 52 | version: "1.0.5" 53 | fake_async: 54 | dependency: transitive 55 | description: 56 | name: fake_async 57 | url: "https://pub.dartlang.org" 58 | source: hosted 59 | version: "1.3.1" 60 | flutter: 61 | dependency: "direct main" 62 | description: flutter 63 | source: sdk 64 | version: "0.0.0" 65 | flutter_lints: 66 | dependency: "direct dev" 67 | description: 68 | name: flutter_lints 69 | url: "https://pub.dartlang.org" 70 | source: hosted 71 | version: "2.0.1" 72 | flutter_test: 73 | dependency: "direct dev" 74 | description: flutter 75 | source: sdk 76 | version: "0.0.0" 77 | http: 78 | dependency: "direct main" 79 | description: 80 | name: http 81 | url: "https://pub.dartlang.org" 82 | source: hosted 83 | version: "0.13.5" 84 | http_parser: 85 | dependency: transitive 86 | description: 87 | name: http_parser 88 | url: "https://pub.dartlang.org" 89 | source: hosted 90 | version: "4.0.1" 91 | lints: 92 | dependency: transitive 93 | description: 94 | name: lints 95 | url: "https://pub.dartlang.org" 96 | source: hosted 97 | version: "2.0.0" 98 | matcher: 99 | dependency: transitive 100 | description: 101 | name: matcher 102 | url: "https://pub.dartlang.org" 103 | source: hosted 104 | version: "0.12.12" 105 | material_color_utilities: 106 | dependency: transitive 107 | description: 108 | name: material_color_utilities 109 | url: "https://pub.dartlang.org" 110 | source: hosted 111 | version: "0.1.5" 112 | meta: 113 | dependency: transitive 114 | description: 115 | name: meta 116 | url: "https://pub.dartlang.org" 117 | source: hosted 118 | version: "1.8.0" 119 | path: 120 | dependency: transitive 121 | description: 122 | name: path 123 | url: "https://pub.dartlang.org" 124 | source: hosted 125 | version: "1.8.2" 126 | sky_engine: 127 | dependency: transitive 128 | description: flutter 129 | source: sdk 130 | version: "0.0.99" 131 | source_span: 132 | dependency: transitive 133 | description: 134 | name: source_span 135 | url: "https://pub.dartlang.org" 136 | source: hosted 137 | version: "1.9.0" 138 | stack_trace: 139 | dependency: transitive 140 | description: 141 | name: stack_trace 142 | url: "https://pub.dartlang.org" 143 | source: hosted 144 | version: "1.10.0" 145 | stream_channel: 146 | dependency: transitive 147 | description: 148 | name: stream_channel 149 | url: "https://pub.dartlang.org" 150 | source: hosted 151 | version: "2.1.0" 152 | string_scanner: 153 | dependency: transitive 154 | description: 155 | name: string_scanner 156 | url: "https://pub.dartlang.org" 157 | source: hosted 158 | version: "1.1.1" 159 | term_glyph: 160 | dependency: transitive 161 | description: 162 | name: term_glyph 163 | url: "https://pub.dartlang.org" 164 | source: hosted 165 | version: "1.2.1" 166 | test_api: 167 | dependency: transitive 168 | description: 169 | name: test_api 170 | url: "https://pub.dartlang.org" 171 | source: hosted 172 | version: "0.4.12" 173 | typed_data: 174 | dependency: transitive 175 | description: 176 | name: typed_data 177 | url: "https://pub.dartlang.org" 178 | source: hosted 179 | version: "1.3.1" 180 | vector_math: 181 | dependency: transitive 182 | description: 183 | name: vector_math 184 | url: "https://pub.dartlang.org" 185 | source: hosted 186 | version: "2.1.2" 187 | web_socket_channel: 188 | dependency: "direct main" 189 | description: 190 | name: web_socket_channel 191 | url: "https://pub.dartlang.org" 192 | source: hosted 193 | version: "2.2.0" 194 | sdks: 195 | dart: ">=2.18.1 <3.0.0" 196 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutter_trading_app 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.1 <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 | flutter: 33 | sdk: flutter 34 | cupertino_icons: ^1.0.2 35 | http: ^0.13.3 36 | web_socket_channel: ^2.1.0 37 | 38 | dev_dependencies: 39 | flutter_test: 40 | sdk: flutter 41 | flutter_lints: ^2.0.0 42 | 43 | # For information on the generic Dart part of this file, see the 44 | # following page: https://dart.dev/tools/pub/pubspec 45 | 46 | # The following section is specific to Flutter packages. 47 | flutter: 48 | 49 | # The following line ensures that the Material Icons font is 50 | # included with your application, so that you can use the icons in 51 | # the material Icons class. 52 | uses-material-design: true 53 | 54 | # To add assets to your application, add an assets section, like this: 55 | # assets: 56 | # - images/a_dot_burr.jpeg 57 | # - images/a_dot_ham.jpeg 58 | 59 | # An image asset can refer to one or more resolution-specific "variants", see 60 | # https://flutter.dev/assets-and-images/#resolution-aware 61 | 62 | # For details regarding adding assets from package dependencies, see 63 | # https://flutter.dev/assets-and-images/#from-packages 64 | 65 | # To add custom fonts to your application, add a fonts section here, 66 | # in this "flutter" section. Each entry in this list should have a 67 | # "family" key with the font family name, and a "fonts" key with a 68 | # list giving the asset and other descriptors for the font. For 69 | # example: 70 | # fonts: 71 | # - family: Schyler 72 | # fonts: 73 | # - asset: fonts/Schyler-Regular.ttf 74 | # - asset: fonts/Schyler-Italic.ttf 75 | # style: italic 76 | # - family: Trajan Pro 77 | # fonts: 78 | # - asset: fonts/TrajanPro.ttf 79 | # - asset: fonts/TrajanPro_Bold.ttf 80 | # weight: 700 81 | # 82 | # For details regarding fonts from package dependencies, 83 | # see https://flutter.dev/custom-fonts/#from-packages 84 | -------------------------------------------------------------------------------- /tempCodeRunnerFile.sh: -------------------------------------------------------------------------------- 1 | cp -r build/web/* docs/ -------------------------------------------------------------------------------- /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:flutter_trading_app/main.dart'; 12 | 13 | void main() { 14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async { 15 | // Build our app and trigger a frame. 16 | await tester.pumpWidget(const MyApp()); 17 | 18 | // Verify that our counter starts at 0. 19 | expect(find.text('0'), findsOneWidget); 20 | expect(find.text('1'), findsNothing); 21 | 22 | // Tap the '+' icon and trigger a frame. 23 | await tester.tap(find.byIcon(Icons.add)); 24 | await tester.pump(); 25 | 26 | // Verify that our counter has incremented. 27 | expect(find.text('0'), findsNothing); 28 | expect(find.text('1'), findsOneWidget); 29 | }); 30 | } 31 | -------------------------------------------------------------------------------- /web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/web/favicon.png -------------------------------------------------------------------------------- /web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/web/icons/Icon-192.png -------------------------------------------------------------------------------- /web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/web/icons/Icon-512.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/UsamaSarwar/flutter-trading-app/56e141b62d95bd7a7f69bd916b49eabc746fc82d/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 | Trading App 33 | 34 | 35 | 39 | 40 | 41 | 42 | 43 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Trading App", 3 | "short_name": "Trading App", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#000000", 7 | "theme_color": "#000000", 8 | "description": "Trading App", 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 | --------------------------------------------------------------------------------