GithubHelp home page GithubHelp logo

Comments (3)

lijy91 avatar lijy91 commented on August 18, 2024

flutter_flipperkit does not support global interception of http

  1. Set useHttpOverrides to false
import 'package:flutter_flipperkit/flutter_flipperkit.dart';

void main() {
  FlipperClient flipperClient = FlipperClient.getDefault();

  flipperClient.addPlugin(new FlipperNetworkPlugin(
    // If you use http library, you must set it to false and use https://pub.dev/packages/flipperkit_http_interceptor
    useHttpOverrides: false,
  ));
  flipperClient.start();

  runApp(MyApp());
}

...
  1. Use flipperkit_http_interceptor instead of http
import 'package:flipperkit_http_interceptor/flipperkit_http_interceptor.dart';

var http = HttpClientWithInterceptor();
http.get("https://www.v2ex.com/api/topics/hot.json");

You don't need to add any Flipper Setup code to AppDelegate.m, flutter_flipperkit will handle these.

Please see http_example

from flutter_flipperkit.

mtchllbrrn avatar mtchllbrrn commented on August 18, 2024

Thanks for the response, that clarifies things a bit.

I updated my example repo with your suggestions and I get the following build error:

Compiler message:
file:///Users/mitchell/bin/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_flipperkit-0.0.17/lib/plugins/network/flipper_http_client_response.dart:7:7: Error: The non-abstract class 'FlipperHttpClientResponse' is missing implementations for these members:
 - HttpClientResponse.compressionState
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class FlipperHttpClientResponse extends Stream<List<int>> implements HttpClientResponse {
      ^^^^^^^^^^^^^^^^^^^^^^^^^
org-dartlang-sdk:///third_party/dart/sdk/lib/_http/http.dart:1967:42: Context: 'HttpClientResponse.compressionState' is defined here.
  HttpClientResponseCompressionState get compressionState;
                                         ^^^^^^^^^^^^^^^^
Compiler failed on /Users/mitchell/viv/src/flipper_example/lib/main.dart
Error launching application on iPhone Xʀ.
Exited (sigterm)

My example repo has been updated here: https://github.com/mtchllbrrn/flipper_example

from flutter_flipperkit.

lijy91 avatar lijy91 commented on August 18, 2024

@mtchllbrrn please upgrade flutter(use beta or stable) and upgrade flutter_flipperkit to 0.0.19

Change your Podifle file

# Uncomment this line to define a global platform for your project
platform :ios, '9.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

-flipperkit_version = '0.22.0'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def parse_KV_file(file, separator='=')
  file_abs_path = File.expand_path(file)
  if !File.exists? file_abs_path
    return [];
  end
  pods_ary = []
  skip_line_start_symbols = ["#", "/"]
  File.foreach(file_abs_path) { |line|
      next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
      plugin = line.split(pattern=separator)
      if plugin.length == 2
        podname = plugin[0].strip()
        path = plugin[1].strip()
        podpath = File.expand_path("#{path}", file_abs_path)
        pods_ary.push({:name => podname, :path => podpath});
      else
        puts "Invalid plugin specification: #{line}"
      end
  }
  return pods_ary
end

target 'Runner' do
  # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
  # referring to absolute paths on developers' machines.
  system('rm -rf .symlinks')
  system('mkdir -p .symlinks/plugins')

  # Flutter Pods
  generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
  if generated_xcode_build_settings.empty?
    puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
  end
  generated_xcode_build_settings.map { |p|
    if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
      symlink = File.join('.symlinks', 'flutter')
      File.symlink(File.dirname(p[:path]), symlink)
      pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
    end
  }

-  # Enable network inspection for Flipper
-  pod 'FlipperKit/SKIOSNetworkPlugin', '~>' + flipperkit_version

  # Plugin Pods
  plugin_pods = parse_KV_file('../.flutter-plugins')
  plugin_pods.map { |p|
    symlink = File.join('.symlinks', 'plugins', p[:name])
    File.symlink(p[:path], symlink)
    pod p[:name], :path => File.join(symlink, 'ios')
  }
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end

-  file_name = Dir.glob("*.xcodeproj")[0]
-  app_project = Xcodeproj::Project.open(file_name)
-  app_project.native_targets.each do |target|
-    target.build_configurations.each do |config|
-      if (config.build_settings['OTHER_SWIFT_FLAGS'])
-        unless config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED'
-          puts 'Adding -DFB_SONARKIT_ENABLED ...'
-          swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
-          if swift_flags.split.last != '-Xcc'
-            config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc'
-          end
-          config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED'
-        end
-      else
-        puts 'OTHER_SWIFT_FLAGS does not exist thus assigning it to `$(inherited) -Xcc -DFB_SONARKIT_ENABLED`'
-        config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -Xcc -DFB_SONARKIT_ENABLED'
-
-  file_name = Dir.glob("*.xcodeproj")[0]
-  app_project = Xcodeproj::Project.open(file_name)
-  app_project.native_targets.each do |target|
-    target.build_configurations.each do |config|
-      if (config.build_settings['OTHER_SWIFT_FLAGS'])
-        unless config.build_settings['OTHER_SWIFT_FLAGS'].include? '-DFB_SONARKIT_ENABLED'
-          puts 'Adding -DFB_SONARKIT_ENABLED ...'
-          swift_flags = config.build_settings['OTHER_SWIFT_FLAGS']
-          if swift_flags.split.last != '-Xcc'
-            config.build_settings['OTHER_SWIFT_FLAGS'] << ' -Xcc'
-          end
-          config.build_settings['OTHER_SWIFT_FLAGS'] << ' -DFB_SONARKIT_ENABLED'
-        end
-      else
-        puts 'OTHER_SWIFT_FLAGS does not exist thus assigning it to `$(inherited) -Xcc -DFB_SONARKIT_ENABLED`'
-        config.build_settings['OTHER_SWIFT_FLAGS'] = '$(inherited) -Xcc -DFB_SONARKIT_ENABLED'
-      end
-      app_project.save
-    end
-  end
-  installer.pods_project.save
-      end
-      app_project.save
-    end
-  end
-  installer.pods_project.save
end

from flutter_flipperkit.

Related Issues (20)

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.