Code Monkey home page Code Monkey logo

flutter-stockchart-module's Introduction

Stock Chart

Multiplatform Stock Chart

Contents

Installation

Reference: https://docs.flutter.dev/development/add-to-app/ios/project-setup

iOS

Method I - Embed with CocoaPods and the Flutter SDK

⚠️ This method requires every developer working on your project to have a locally installed version of the Flutter SDK ⚠️


Download or Clone the project

$ git clone https://github.com/wayne90040/Flutter-StockChart-Module.git

Following example assumes that your existing application and the Flutter module are in sibling directories.

some/path/
├── Flutter-StockChart-Module/
│   
└── iOS-Existing-App/
    └── Podfile

Podfile

If existing iOS App doesn’t already have a Podfile, follow the CocoaPods getting started guide to add a Podfile to your project.

Add the following lines to your Podfile:

flutter_application_path = '../Flutter-StockChart-Module'  # according to your clone file name
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

For each Podfile target that needs to embed Flutter, call install_all_flutter_pods(flutter_application_path).

install_all_flutter_pods(flutter_application_path)
flutter_application_path = '../flutter_stock_chart'
load File.join(flutter_application_path, '.ios', 'Flutter', 'podhelper.rb')

platform :ios, '9.0'

target 'ios-flutter-chart-example' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for ios-flutter-chart-example
  install_all_flutter_pods(flutter_application_path)
end

Run

Run flutter pub get first under flutter project

$ flutter pub get

Run pod install under iOS project

$ pod install

Usage

Reference: https://docs.flutter.dev/development/add-to-app/ios/add-flutter-screen?tab=engine-swift-tab

iOS

Create a FlutterEngine

import UIKit
import Flutter
import FlutterPluginRegistrant

@UIApplicationMain
class AppDelegate: FlutterAppDelegate {

    lazy var flutterEngine = FlutterEngine(name: "flutter chart engine")

    override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        flutterEngine.run()
        
        GeneratedPluginRegistrant.register(with: flutterEngine)
        
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
    }
    ...
}

Show a FlutterViewController with your FlutterEngine

let engine = (UIApplication.shared.delegate as! AppDelegate).flutterEngine
let vc = FlutterViewController(engine: engine, nibName: nil, bundle: nil)
present(vc, animated: true)

Send Data

let channel = FlutterMethodChannel(name: "com.wielun.chart/quote", binaryMessenger: vc.binaryMessenger)
var jsonObject: [String: Any] = [:]
jsonObject["open"] = [double ...]
jsonObject["close"] = [double ...]
jsonObject["high"] = [double ...
jsonObject["low"] = [double ...]
jsonObject["vol"] = [double ...]

var convertToString: String?

do {
    let tmp = try JSONSerialization.data(withJSONObject: jsonObject, options: .prettyPrinted)
    convertToString = String(data: tmp, encoding: .utf8)
} catch _ {

}
channel.invokeMethod("fromHostToChart", arguments: convertToString)

Issue

Check flutter version

try

flutter clean

then

flutter run

Failed to find assets path for "Frameworks/App.framework/flutter_assets"

or

Library not loaded: @rpath/App.framework/App

Need to add to project/targets/Build Phases/[CP-User] Run Flutter Build flutter_stock_chart Script

"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh" embed_and_thin

Flutter in iOS14 build on real device crash when stop Xcode connect

Change build mode to release or Set FLUTTER_BUILD_MODE to release in Build Settings/User-Defined

Thank you ~

flutter-stockchart-module's People

Contributors

wayne90040 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.