diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
deleted file mode 100644
index 18322f7..0000000
--- a/.github/FUNDING.yml
+++ /dev/null
@@ -1,12 +0,0 @@
-# These are supported funding model platforms
-
-github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
-patreon: # Replace with a single Patreon username
-open_collective: # Replace with a single Open Collective username
-ko_fi: # Replace with a single Ko-fi username
-tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
-community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
-liberapay: # Replace with a single Liberapay username
-issuehunt: # Replace with a single IssueHunt username
-otechie: # Replace with a single Otechie username
-custom: https://v7lin.github.io/docsify/#/navbar/sponsor # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d285774..331fd9d 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -10,10 +10,12 @@ jobs:
matrix:
os: [macos-latest]
steps:
- - uses: actions/checkout@v1
- - uses: actions/setup-java@v1
+ - uses: actions/checkout@v2
+ - uses: actions/setup-java@v2
with:
- java-version: '8.x'
+ distribution: 'temurin'
+ java-version: '11'
+ cache: 'gradle'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
@@ -32,10 +34,12 @@ jobs:
matrix:
os: [ubuntu-latest]
steps:
- - uses: actions/checkout@v1
- - uses: actions/setup-java@v1
+ - uses: actions/checkout@v2
+ - uses: actions/setup-java@v2
with:
- java-version: '8.x'
+ distribution: 'temurin'
+ java-version: '11'
+ cache: 'gradle'
- uses: subosito/flutter-action@v1
with:
channel: 'stable'
@@ -45,5 +49,5 @@ jobs:
- run: flutter format --dry-run --set-exit-if-changed .
- run: flutter pub publish --dry-run
- run: flutter analyze lib example/lib
- - run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;20.0.5594570"
+ - run: sudo echo "y" | sudo $ANDROID_HOME/tools/bin/sdkmanager "ndk;21.1.6352462"
- run: cd example; flutter build apk --debug
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
index eeeadb3..187bfab 100644
--- a/.github/workflows/publish.yml
+++ b/.github/workflows/publish.yml
@@ -9,8 +9,8 @@ jobs:
name: Publish
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
- - uses: sakebook/actions-flutter-pub-publisher@v1.3.0
+ - uses: actions/checkout@v2
+ - uses: sakebook/actions-flutter-pub-publisher@v1.4.0
with:
credential: ${{ secrets.CREDENTIAL_JSON }}
flutter_package: true
diff --git a/.github/workflows/publish_manually.yml b/.github/workflows/publish_manually.yml
index 1c51463..fb0aadf 100644
--- a/.github/workflows/publish_manually.yml
+++ b/.github/workflows/publish_manually.yml
@@ -7,8 +7,8 @@ jobs:
name: Publish Manually
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v1
- - uses: sakebook/actions-flutter-pub-publisher@v1.3.0
+ - uses: actions/checkout@v2
+ - uses: sakebook/actions-flutter-pub-publisher@v1.4.0
with:
credential: ${{ secrets.CREDENTIAL_JSON }}
flutter_package: true
diff --git a/.gitignore b/.gitignore
index 95abf25..96486fd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,11 +1,30 @@
+# Miscellaneous
+*.class
+*.log
+*.pyc
+*.swp
.DS_Store
-.dart_tool/
+.atom/
+.buildlog/
+.history
+.svn/
+migrate_working_dir/
-.packages
-.pub/
-
-build/
-
-#
+# IntelliJ related
*.iml
+*.ipr
+*.iws
.idea/
+
+# The .vscode folder contains launch configuration and tasks you configure in
+# VS Code which you may wish to be included in version control, so this line
+# is commented out by default.
+#.vscode/
+
+# Flutter/Dart/Pub related
+# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
+/pubspec.lock
+**/doc/api/
+.dart_tool/
+.packages
+build/
diff --git a/.metadata b/.metadata
index 53b454c..5bfec1b 100644
--- a/.metadata
+++ b/.metadata
@@ -1,10 +1,33 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
-# This file should be version controlled and should not be manually edited.
+# This file should be version controlled.
version:
- revision: b041144f833e05cf463b8887fa12efdec9493488
+ revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
channel: stable
project_type: plugin
+
+# Tracks metadata for the flutter migrate command
+migration:
+ platforms:
+ - platform: root
+ create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+ base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+ - platform: android
+ create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+ base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+ - platform: ios
+ create_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+ base_revision: ee4e09cce01d6f2d7f4baebd247fde02e5008851
+
+ # User provided section
+
+ # List of Local paths (relative to this file) that should be
+ # ignored by the migrate tool.
+ #
+ # Files that are not part of the templates will be ignored by default.
+ unmanaged_files:
+ - 'lib/main.dart'
+ - 'ios/Runner.xcodeproj/project.pbxproj'
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b6603aa..c5ed36b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 4.0.0
+
+* 升级 Flutter 3.0
+* break change: 官方标准化插件
+
## 3.1.0
* 升级 Android SDK
diff --git a/analysis_options.yaml b/analysis_options.yaml
index 41cde2e..c6a1cb1 100644
--- a/analysis_options.yaml
+++ b/analysis_options.yaml
@@ -5,39 +5,44 @@
#
# For a list of lints, see: http://dart-lang.github.io/linter/lints/
# See the configuration guide for more
-# https://github.com/dart-lang/sdk/tree/master/pkg/analyzer#configuring-the-analyzer
+# https://github.com/dart-lang/sdk/tree/main/pkg/analyzer#configuring-the-analyzer
#
# There are other similar analysis options files in the flutter repos,
# which should be kept in sync with this file:
#
# - analysis_options.yaml (this file)
-# - packages/flutter/lib/analysis_options_user.yaml
# - https://github.com/flutter/plugins/blob/master/analysis_options.yaml
# - https://github.com/flutter/engine/blob/master/analysis_options.yaml
+# - https://github.com/flutter/packages/blob/master/analysis_options.yaml
#
# This file contains the analysis options used by Flutter tools, such as IntelliJ,
# Android Studio, and the `flutter analyze` command.
analyzer:
- strong-mode:
- implicit-casts: false
- implicit-dynamic: false
+ language:
+ strict-raw-types: true
errors:
# treat missing required parameters as a warning (not a hint)
missing_required_param: warning
# treat missing returns as a warning (not a hint)
missing_return: warning
- # allow having TODOs in the code
+ # allow having TODO comments in the code
todo: ignore
# allow self-reference to deprecated members (we do this because otherwise we have
# to annotate every member in every test, assert, etc, when we deprecate something)
deprecated_member_use_from_same_package: ignore
- # Ignore analyzer hints for updating pubspecs when using Future or
- # Stream and not importing dart:async
- # Please see https://github.com/flutter/flutter/pull/24528 for details.
- sdk_version_async_exported_from_core: ignore
+ # TODO(ianh): https://github.com/flutter/flutter/issues/74381
+ # Clean up existing unnecessary imports, and remove line to ignore.
+ unnecessary_import: ignore
+ # Turned off until null-safe rollout is complete.
+ unnecessary_null_comparison: ignore
exclude:
+ - "bin/cache/**"
+ # Ignore protoc generated files
+ - "dev/conductor/lib/proto/*"
+ #
- "lib/*.g.dart"
+ - "lib/**/*.g.dart"
linter:
rules:
@@ -52,62 +57,68 @@ linter:
- always_use_package_imports # we do this commonly
- annotate_overrides
# - avoid_annotating_with_dynamic # conflicts with always_specify_types
- # - avoid_as # required for implicit-casts: true
- avoid_bool_literals_in_conditional_expressions
- # - avoid_catches_without_on_clauses # we do this commonly
- # - avoid_catching_errors # we do this commonly
+ # - avoid_catches_without_on_clauses # blocked on https://github.com/dart-lang/linter/issues/3023
+ # - avoid_catching_errors # blocked on https://github.com/dart-lang/linter/issues/3023
- avoid_classes_with_only_static_members
- # - avoid_double_and_int_checks # only useful when targeting JS runtime
+ - avoid_double_and_int_checks
+ - avoid_dynamic_calls
- avoid_empty_else
- avoid_equals_and_hash_code_on_mutable_classes
- # - avoid_escaping_inner_quotes # not yet tested
+ - avoid_escaping_inner_quotes
- avoid_field_initializers_in_const_classes
+ # - avoid_final_parameters # incompatible with prefer_final_parameters
- avoid_function_literals_in_foreach_calls
- # - avoid_implementing_value_types # not yet tested
+ - avoid_implementing_value_types
- avoid_init_to_null
- # - avoid_js_rounded_ints # only useful when targeting JS runtime
+ - avoid_js_rounded_ints
+ # - avoid_multiple_declarations_per_line # seems to be a stylistic choice we don't subscribe to
- avoid_null_checks_in_equality_operators
- # - avoid_positional_boolean_parameters # not yet tested
- # - avoid_print # not yet tested
+ # - avoid_positional_boolean_parameters # would have been nice to enable this but by now there's too many places that break it
+ - avoid_print
# - avoid_private_typedef_functions # we prefer having typedef (discussion in https://github.com/flutter/flutter/pull/16356)
- # - avoid_redundant_argument_values # not yet tested
+ # - avoid_redundant_argument_values
- avoid_relative_lib_imports
- avoid_renaming_method_parameters
- avoid_return_types_on_setters
- # - avoid_returning_null # there are plenty of valid reasons to return null
- # - avoid_returning_null_for_future # not yet tested
+ # - avoid_returning_null # still violated by some pre-nnbd code that we haven't yet migrated
+ - avoid_returning_null_for_future
- avoid_returning_null_for_void
- # - avoid_returning_this # there are plenty of valid reasons to return this
- # - avoid_setters_without_getters # not yet tested
+ # - avoid_returning_this # there are enough valid reasons to return `this` that this lint ends up with too many false positives
+ - avoid_setters_without_getters
- avoid_shadowing_type_parameters
- avoid_single_cascade_in_expression_statements
- avoid_slow_async_io
- # - avoid_type_to_string # we do this commonly
+ - avoid_type_to_string
- avoid_types_as_parameter_names
# - avoid_types_on_closure_parameters # conflicts with always_specify_types
- # - avoid_unnecessary_containers # not yet tested
+ - avoid_unnecessary_containers
- avoid_unused_constructor_parameters
- avoid_void_async
- # - avoid_web_libraries_in_flutter # not yet tested
+ # - avoid_web_libraries_in_flutter # we use web libraries in web-specific code, and our tests prevent us from using them elsewhere
- await_only_futures
- camel_case_extensions
- camel_case_types
- cancel_subscriptions
- # - cascade_invocations # not yet tested
+ # - cascade_invocations # doesn't match the typical style of this repo
- cast_nullable_to_non_nullable
# - close_sinks # not reliable enough
- # - comment_references # blocked on https://github.com/flutter/flutter/issues/20765
+ # - comment_references # blocked on https://github.com/dart-lang/linter/issues/1142
+ # - conditional_uri_does_not_exist # not yet tested
# - constant_identifier_names # needs an opt-out https://github.com/dart-lang/linter/issues/204
- control_flow_in_finally
# - curly_braces_in_flow_control_structures # not required by flutter style
- # - diagnostic_describe_all_properties # not yet tested
+ - depend_on_referenced_packages
+ - deprecated_consistency
+ # - diagnostic_describe_all_properties # enabled only at the framework level (packages/flutter/lib)
- directives_ordering
- # - do_not_use_environment # we do this commonly
+ # - do_not_use_environment # there are appropriate times to use the environment, especially in our tests and build logic
- empty_catches
- empty_constructor_bodies
- empty_statements
+ - eol_at_end_of_file
- exhaustive_cases
- - file_names # not yet tested
+ - file_names
- flutter_style_todos
- hash_and_equals
- implementation_imports
@@ -117,24 +128,28 @@ linter:
- leading_newlines_in_multiline_strings
- library_names
- library_prefixes
+ - library_private_types_in_public_api
# - lines_longer_than_80_chars # not required by flutter style
- list_remove_unrelated_type
- # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/sdk/issues/34181
- # - missing_whitespace_between_adjacent_strings # not yet tested
+ # - literal_only_boolean_expressions # too many false positives: https://github.com/dart-lang/linter/issues/453
+ - missing_whitespace_between_adjacent_strings
- no_adjacent_strings_in_list
- # - no_default_cases # too many false positives
+ - no_default_cases
- no_duplicate_case_values
+ - no_leading_underscores_for_library_prefixes
+ - no_leading_underscores_for_local_identifiers
- no_logic_in_create_state
# - no_runtimeType_toString # ok in tests; we enable this only in packages/
- non_constant_identifier_names
+ - noop_primitive_operations
- null_check_on_nullable_type_parameter
- # - null_closures # not required by flutter style
+ - null_closures
# - omit_local_variable_types # opposite of always_specify_types
# - one_member_abstracts # too many false positives
- # - only_throw_errors # https://github.com/flutter/flutter/issues/5792
+ - only_throw_errors # this does get disabled in a few places where we have legacy code that uses strings et al
- overridden_fields
- package_api_docs
- # - package_names # non conforming packages in sdk
+ - package_names
- package_prefixed_library_names
# - parameter_assignments # we do this commonly
- prefer_adjacent_string_concatenation
@@ -142,10 +157,10 @@ linter:
# - prefer_asserts_with_message # not required by flutter style
- prefer_collection_literals
- prefer_conditional_assignment
- - prefer_const_constructors
+ # - prefer_const_constructors
- prefer_const_constructors_in_immutables
- prefer_const_declarations
- - prefer_const_literals_to_create_immutables
+ # - prefer_const_literals_to_create_immutables
# - prefer_constructors_over_static_methods # far too many false positives
- prefer_contains
# - prefer_double_quotes # opposite of prefer_single_quotes
@@ -154,33 +169,38 @@ linter:
- prefer_final_fields
- prefer_final_in_for_each
- prefer_final_locals
+ # - prefer_final_parameters # we should enable this one day when it can be auto-fixed (https://github.com/dart-lang/linter/issues/3104), see also parameter_assignments
- prefer_for_elements_to_map_fromIterable
- prefer_foreach
- # - prefer_function_declarations_over_variables # not yet tested
+ - prefer_function_declarations_over_variables
- prefer_generic_function_type_aliases
- prefer_if_elements_to_conditional_expressions
- prefer_if_null_operators
- prefer_initializing_formals
- prefer_inlined_adds
- # - prefer_int_literals # not yet tested
- # - prefer_interpolation_to_compose_strings # not yet tested
+ # - prefer_int_literals # conflicts with https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#use-double-literals-for-double-constants
+ - prefer_interpolation_to_compose_strings
- prefer_is_empty
- prefer_is_not_empty
- prefer_is_not_operator
- prefer_iterable_whereType
- # - prefer_mixin # https://github.com/dart-lang/language/issues/32
- # - prefer_null_aware_operators # disable until NNBD, see https://github.com/flutter/flutter/pull/32711#issuecomment-492930932
- # - prefer_relative_imports # not yet tested
+ # - prefer_mixin # Has false positives, see https://github.com/dart-lang/linter/issues/3018
+ # - prefer_null_aware_method_calls # "call()" is confusing to people new to the language since it's not documented anywhere
+ - prefer_null_aware_operators
+ # - prefer_relative_imports
- prefer_single_quotes
- prefer_spread_collections
- prefer_typing_uninitialized_variables
- prefer_void_to_null
- # - provide_deprecation_message # not yet tested
+ - provide_deprecation_message
# - public_member_api_docs # enabled on a case-by-case basis; see e.g. packages/analysis_options.yaml
- recursive_getters
- # - sized_box_for_whitespace # not yet tested
+ # - require_trailing_commas # blocked on https://github.com/dart-lang/sdk/issues/47441
+ - secure_pubspec_urls
+ - sized_box_for_whitespace
+ # - sized_box_shrink_expand # not yet tested
- slash_for_doc_comments
- # - sort_child_properties_last # not yet tested
+ - sort_child_properties_last
- sort_constructors_first
# - sort_pub_dependencies # prevents separating pinned transitive dependencies
- sort_unnamed_constructors_first
@@ -189,36 +209,43 @@ linter:
- tighten_type_of_initializing_formals
# - type_annotate_public_apis # subset of always_specify_types
- type_init_formals
- - unawaited_futures # too many false positives
- # - unnecessary_await_in_return # not yet tested
+ # - unawaited_futures # too many false positives, especially with the way AnimationController works
+ - unnecessary_await_in_return
- unnecessary_brace_in_string_interps
- unnecessary_const
+ - unnecessary_constructor_name
# - unnecessary_final # conflicts with prefer_final_locals
- unnecessary_getters_setters
# - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498
+ - unnecessary_late
- unnecessary_new
- unnecessary_null_aware_assignments
- # - unnecessary_null_checks # not yet tested
+ - unnecessary_null_checks
- unnecessary_null_in_if_null_operators
- unnecessary_nullable_for_final_variable_declarations
- unnecessary_overrides
- unnecessary_parenthesis
- # - unnecessary_raw_strings # not yet tested
+ # - unnecessary_raw_strings # what's "necessary" is a matter of opinion; consistency across strings can help readability more than this lint
- unnecessary_statements
- unnecessary_string_escapes
- unnecessary_string_interpolations
- unnecessary_this
- unrelated_type_equality_checks
- # - unsafe_html # not yet tested
+ - unsafe_html
+ - use_build_context_synchronously
+ # - use_decorated_box # not yet tested
- use_full_hex_values_for_flutter_colors
- # - use_function_type_syntax_for_parameters # not yet tested
+ - use_function_type_syntax_for_parameters
+ - use_if_null_to_convert_nulls_to_bools
- use_is_even_rather_than_modulo
- # - use_key_in_widget_constructors # not yet tested
+ - use_key_in_widget_constructors
- use_late_for_private_fields_and_variables
+ - use_named_constants
- use_raw_strings
- use_rethrow_when_possible
- # - use_setters_to_change_properties # not yet tested
+ - use_setters_to_change_properties
# - use_string_buffers # has false positives: https://github.com/dart-lang/sdk/issues/34182
+ - use_test_throws_matchers
# - use_to_and_as_if_applicable # has false positives, so we prefer to catch this by code-review
- valid_regexps
- void_checks
diff --git a/android/.gitignore b/android/.gitignore
index c6cbe56..161bdcd 100644
--- a/android/.gitignore
+++ b/android/.gitignore
@@ -6,3 +6,4 @@
.DS_Store
/build
/captures
+.cxx
diff --git a/android/build.gradle b/android/build.gradle
index bccad87..883f947 100644
--- a/android/build.gradle
+++ b/android/build.gradle
@@ -1,5 +1,5 @@
group 'io.github.v7lin.weibo_kit'
-version '3.1.0'
+version '4.0.0'
buildscript {
repositories {
@@ -8,7 +8,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath 'com.android.tools.build:gradle:7.1.2'
}
}
@@ -24,6 +24,11 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 31
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
defaultConfig {
minSdkVersion 16
@@ -31,10 +36,6 @@ android {
consumerProguardFiles 'consumer-rules.pro'
}
- lintOptions {
- disable 'InvalidPackage'
- }
-
flavorDimensions 'vendor'
productFlavors {
diff --git a/android/gradle.properties b/android/gradle.properties
deleted file mode 100644
index 38c8d45..0000000
--- a/android/gradle.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-org.gradle.jvmargs=-Xmx1536M
-android.enableR8=true
-android.useAndroidX=true
-android.enableJetifier=true
diff --git a/android/gradle/wrapper/gradle-wrapper.properties b/android/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 3c9d085..0000000
--- a/android/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml
index 0e1c2bb..791c603 100644
--- a/android/src/main/AndroidManifest.xml
+++ b/android/src/main/AndroidManifest.xml
@@ -1,3 +1,3 @@
+ package="io.github.v7lin.weibo_kit">
diff --git a/android/src/main/java/io/github/v7lin/weibo_kit/WeiboKitPlugin.java b/android/src/main/java/io/github/v7lin/weibo_kit/WeiboKitPlugin.java
index a5ce75e..5dd0f7f 100644
--- a/android/src/main/java/io/github/v7lin/weibo_kit/WeiboKitPlugin.java
+++ b/android/src/main/java/io/github/v7lin/weibo_kit/WeiboKitPlugin.java
@@ -9,6 +9,7 @@ import android.net.Uri;
import android.os.Build;
import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
import com.sina.weibo.sdk.api.ImageObject;
import com.sina.weibo.sdk.api.MultiImageObject;
@@ -43,7 +44,6 @@ import io.flutter.plugin.common.PluginRegistry;
* WeiboKitPlugin
*/
public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegistry.ActivityResultListener, MethodCallHandler {
-
private static class WeiboErrorCode {
public static final int SUCCESS = 0;//成功
public static final int USERCANCEL = -1;//用户取消发送
@@ -56,34 +56,6 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
public static final int UNKNOWN = -100;
}
- private static final String METHOD_REGISTERAPP = "registerApp";
- private static final String METHOD_ISINSTALLED = "isInstalled";
- private static final String METHOD_AUTH = "auth";
- private static final String METHOD_SHARETEXT = "shareText";
- private static final String METHOD_SHAREIMAGE = "shareImage";
- private static final String METHOD_SHAREWEBPAGE = "shareWebpage";
-
- private static final String METHOD_ONAUTHRESP = "onAuthResp";
- private static final String METHOD_ONSHAREMSGRESP = "onShareMsgResp";
-
- private static final String ARGUMENT_KEY_APPKEY = "appKey";
- private static final String ARGUMENT_KEY_SCOPE = "scope";
- private static final String ARGUMENT_KEY_REDIRECTURL = "redirectUrl";
- private static final String ARGUMENT_KEY_TEXT = "text";
- private static final String ARGUMENT_KEY_TITLE = "title";
- private static final String ARGUMENT_KEY_DESCRIPTION = "description";
- private static final String ARGUMENT_KEY_THUMBDATA = "thumbData";
- private static final String ARGUMENT_KEY_IMAGEDATA = "imageData";
- private static final String ARGUMENT_KEY_IMAGEURI = "imageUri";
- private static final String ARGUMENT_KEY_WEBPAGEURL = "webpageUrl";
-
- private static final String ARGUMENT_KEY_RESULT_ERRORCODE = "errorCode";
- private static final String ARGUMENT_KEY_RESULT_ERRORMESSAGE = "errorMessage";
- private static final String ARGUMENT_KEY_RESULT_USERID = "userId";
- private static final String ARGUMENT_KEY_RESULT_ACCESSTOKEN = "accessToken";
- private static final String ARGUMENT_KEY_RESULT_REFRESHTOKEN = "refreshToken";
- private static final String ARGUMENT_KEY_RESULT_EXPIRESIN = "expiresIn";
-
/// The MethodChannel that will the communication between Flutter and native Android
///
/// This local reference serves to register the plugin with the Flutter Engine and unregister it
@@ -137,7 +109,7 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
// --- ActivityResultListener
@Override
- public boolean onActivityResult(int requestCode, int resultCode, Intent data) {
+ public boolean onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
switch (requestCode) {
case 32973:
if (iwbapi != null) {
@@ -149,28 +121,28 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
iwbapi.doResultIntent(data, new WbShareCallback() {
@Override
public void onComplete() {
- Map map = new HashMap<>();
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
+ final Map map = new HashMap<>();
+ map.put("errorCode", WeiboErrorCode.SUCCESS);
if (channel != null) {
- channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
+ channel.invokeMethod("onShareMsgResp", map);
}
}
@Override
public void onError(UiError uiError) {
- Map map = new HashMap<>();
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SHARE_IN_SDK_FAILED);
+ final Map map = new HashMap<>();
+ map.put("errorCode", WeiboErrorCode.SHARE_IN_SDK_FAILED);
if (channel != null) {
- channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
+ channel.invokeMethod("onShareMsgResp", map);
}
}
@Override
public void onCancel() {
- Map map = new HashMap<>();
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
+ final Map map = new HashMap<>();
+ map.put("errorCode", WeiboErrorCode.USERCANCEL);
if (channel != null) {
- channel.invokeMethod(METHOD_ONSHAREMSGRESP, map);
+ channel.invokeMethod("onShareMsgResp", map);
}
}
});
@@ -184,21 +156,21 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
@Override
public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
- if (METHOD_REGISTERAPP.equals(call.method)) {
- final String appKey = call.argument(ARGUMENT_KEY_APPKEY);
- final String scope = call.argument(ARGUMENT_KEY_SCOPE);
- final String redirectUrl = call.argument(ARGUMENT_KEY_REDIRECTURL);
+ if ("registerApp".equals(call.method)) {
+ final String appKey = call.argument("appKey");
+ final String scope = call.argument("scope");
+ final String redirectUrl = call.argument("redirectUrl");
iwbapi = WBAPIFactory.createWBAPI(activityPluginBinding.getActivity());
iwbapi.registerApp(applicationContext, new AuthInfo(applicationContext, appKey, redirectUrl, scope));
result.success(null);
- } else if (METHOD_ISINSTALLED.equals(call.method)) {
+ } else if ("isInstalled".equals(call.method)) {
result.success(iwbapi.isWBAppInstalled());
- } else if (METHOD_AUTH.equals(call.method)) {
+ } else if ("auth".equals(call.method)) {
handleAuthCall(call, result);
- } else if (METHOD_SHARETEXT.equals(call.method)) {
+ } else if ("shareText".equals(call.method)) {
handleShareTextCall(call, result);
- } else if (METHOD_SHAREIMAGE.equals(call.method) ||
- METHOD_SHAREWEBPAGE.equals(call.method)) {
+ } else if ("shareImage".equals(call.method) ||
+ "shareWebpage".equals(call.method)) {
handleShareMediaCall(call, result);
} else {
result.notImplemented();
@@ -212,35 +184,35 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
public void onComplete(Oauth2AccessToken token) {
final Map map = new HashMap<>();
if (token.isSessionValid()) {
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.SUCCESS);
- map.put(ARGUMENT_KEY_RESULT_USERID, token.getUid());
- map.put(ARGUMENT_KEY_RESULT_ACCESSTOKEN, token.getAccessToken());
- map.put(ARGUMENT_KEY_RESULT_REFRESHTOKEN, token.getRefreshToken());
+ map.put("errorCode", WeiboErrorCode.SUCCESS);
+ map.put("userId", token.getUid());
+ map.put("accessToken", token.getAccessToken());
+ map.put("refreshToken", token.getRefreshToken());
final long expiresIn = (long) Math.ceil((token.getExpiresTime() - System.currentTimeMillis()) / 1000.0);
- map.put(ARGUMENT_KEY_RESULT_EXPIRESIN, expiresIn);// 向上取整
+ map.put("expiresIn", expiresIn);// 向上取整
} else {
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
+ map.put("errorCode", WeiboErrorCode.UNKNOWN);
}
if (channel != null) {
- channel.invokeMethod(METHOD_ONAUTHRESP, map);
+ channel.invokeMethod("onAuthResp", map);
}
}
@Override
public void onError(UiError uiError) {
final Map map = new HashMap<>();
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.UNKNOWN);
+ map.put("errorCode", WeiboErrorCode.UNKNOWN);
if (channel != null) {
- channel.invokeMethod(METHOD_ONAUTHRESP, map);
+ channel.invokeMethod("onAuthResp", map);
}
}
@Override
public void onCancel() {
final Map map = new HashMap<>();
- map.put(ARGUMENT_KEY_RESULT_ERRORCODE, WeiboErrorCode.USERCANCEL);
+ map.put("errorCode", WeiboErrorCode.USERCANCEL);
if (channel != null) {
- channel.invokeMethod(METHOD_ONAUTHRESP, map);
+ channel.invokeMethod("onAuthResp", map);
}
}
});
@@ -252,7 +224,7 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
final WeiboMultiMessage message = new WeiboMultiMessage();
final TextObject object = new TextObject();
- object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
+ object.text = call.argument("text");// 1024
message.textObject = object;
@@ -265,18 +237,18 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
private void handleShareMediaCall(@NonNull MethodCall call, @NonNull Result result) {
final WeiboMultiMessage message = new WeiboMultiMessage();
- if (METHOD_SHAREIMAGE.equals(call.method)) {
- if (call.hasArgument(ARGUMENT_KEY_TEXT)) {
+ if ("shareImage".equals(call.method)) {
+ if (call.hasArgument("text")) {
final TextObject object = new TextObject();
- object.text = call.argument(ARGUMENT_KEY_TEXT);// 1024
+ object.text = call.argument("text");// 1024
message.textObject = object;
}
- if (iwbapi != null && iwbapi.isWBAppSupportMultipleImage() && call.hasArgument(ARGUMENT_KEY_IMAGEURI)) {
+ if (iwbapi != null && iwbapi.isWBAppSupportMultipleImage() && call.hasArgument("imageUri")) {
final MultiImageObject object = new MultiImageObject();
- String imageUri = call.argument(ARGUMENT_KEY_IMAGEURI);
- ArrayList images = new ArrayList<>();
+ final String imageUri = call.argument("imageUri");
+ final ArrayList images = new ArrayList<>();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
try {
final ProviderInfo providerInfo = applicationContext.getPackageManager().getProviderInfo(new ComponentName(applicationContext, FileProvider.class), PackageManager.MATCH_DEFAULT_ONLY);
@@ -293,22 +265,22 @@ public class WeiboKitPlugin implements FlutterPlugin, ActivityAware, PluginRegis
message.mediaObject = object;
} else {
final ImageObject object = new ImageObject();
- if (call.hasArgument(ARGUMENT_KEY_IMAGEDATA)) {
- object.imageData = call.argument(ARGUMENT_KEY_IMAGEDATA);// 2 * 1024 * 1024
- } else if (call.hasArgument(ARGUMENT_KEY_IMAGEURI)) {
- String imageUri = call.argument(ARGUMENT_KEY_IMAGEURI);
+ if (call.hasArgument("imageData")) {
+ object.imageData = call.argument("imageData");// 2 * 1024 * 1024
+ } else if (call.hasArgument("imageUri")) {
+ final String imageUri = call.argument("imageUri");
object.imagePath = Uri.parse(imageUri).getPath();// 512 - 10 * 1024 * 1024
}
message.mediaObject = object;
}
- } else if (METHOD_SHAREWEBPAGE.equals(call.method)) {
+ } else if ("shareWebpage".equals(call.method)) {
final WebpageObject object = new WebpageObject();
object.identify = UUID.randomUUID().toString();
- object.title = call.argument(ARGUMENT_KEY_TITLE);// 512
- object.description = call.argument(ARGUMENT_KEY_DESCRIPTION);// 1024
- object.thumbData = call.argument(ARGUMENT_KEY_THUMBDATA);// 32 * 1024
- object.defaultText = call.argument(ARGUMENT_KEY_DESCRIPTION);
- object.actionUrl = call.argument(ARGUMENT_KEY_WEBPAGEURL);// 512
+ object.title = call.argument("title");// 512
+ object.description = call.argument("description");// 1024
+ object.thumbData = call.argument("thumbData");// 32 * 1024
+ object.defaultText = call.argument("description");
+ object.actionUrl = call.argument("webpageUrl");// 512
message.mediaObject = object;
}
diff --git a/example/.gitignore b/example/.gitignore
index 0fa6b67..a8e938c 100644
--- a/example/.gitignore
+++ b/example/.gitignore
@@ -8,6 +8,7 @@
.buildlog/
.history
.svn/
+migrate_working_dir/
# IntelliJ related
*.iml
diff --git a/example/.metadata b/example/.metadata
deleted file mode 100644
index 7c361dd..0000000
--- a/example/.metadata
+++ /dev/null
@@ -1,10 +0,0 @@
-# This file tracks properties of this Flutter project.
-# Used by Flutter tool to assess capabilities and perform upgrades etc.
-#
-# This file should be version controlled and should not be manually edited.
-
-version:
- revision: b041144f833e05cf463b8887fa12efdec9493488
- channel: stable
-
-project_type: app
diff --git a/example/README.md b/example/README.md
index 4b650e0..5e2c402 100644
--- a/example/README.md
+++ b/example/README.md
@@ -8,9 +8,9 @@ This project is a starting point for a Flutter application.
A few resources to get you started if this is your first Flutter project:
-- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
-- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
+- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
+- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
-For help getting started with Flutter, view our
-[online documentation](https://flutter.dev/docs), which offers tutorials,
+For help getting started with Flutter development, view the
+[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
diff --git a/example/android/.gitignore b/example/android/.gitignore
index 0a741cb..6f56801 100644
--- a/example/android/.gitignore
+++ b/example/android/.gitignore
@@ -9,3 +9,5 @@ GeneratedPluginRegistrant.java
# Remember to never publicly share your keystore.
# See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
key.properties
+**/*.keystore
+**/*.jks
diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle
index 0931adb..de4b91c 100644
--- a/example/android/app/build.gradle
+++ b/example/android/app/build.gradle
@@ -27,14 +27,18 @@ apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
+ ndkVersion flutter.ndkVersion
- lintOptions {
- disable 'InvalidPackage'
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "io.github.v7lin.weibo_kit_example"
+ // You can update the following values to match your application needs.
+ // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
diff --git a/example/android/app/src/debug/AndroidManifest.xml b/example/android/app/src/debug/AndroidManifest.xml
index 2799474..38117eb 100644
--- a/example/android/app/src/debug/AndroidManifest.xml
+++ b/example/android/app/src/debug/AndroidManifest.xml
@@ -1,6 +1,7 @@
-
diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml
index 3e43489..3d2f23a 100644
--- a/example/android/app/src/main/AndroidManifest.xml
+++ b/example/android/app/src/main/AndroidManifest.xml
@@ -1,12 +1,8 @@
-
-
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values-night/styles.xml b/example/android/app/src/main/res/values-night/styles.xml
new file mode 100644
index 0000000..06952be
--- /dev/null
+++ b/example/android/app/src/main/res/values-night/styles.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
diff --git a/example/android/app/src/main/res/values/styles.xml b/example/android/app/src/main/res/values/styles.xml
index 1f83a33..cb1ef88 100644
--- a/example/android/app/src/main/res/values/styles.xml
+++ b/example/android/app/src/main/res/values/styles.xml
@@ -1,18 +1,18 @@
-
-
-
diff --git a/example/android/app/src/profile/AndroidManifest.xml b/example/android/app/src/profile/AndroidManifest.xml
index 2799474..38117eb 100644
--- a/example/android/app/src/profile/AndroidManifest.xml
+++ b/example/android/app/src/profile/AndroidManifest.xml
@@ -1,6 +1,7 @@
-
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 4256f91..83ae220 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -6,7 +6,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath 'com.android.tools.build:gradle:7.1.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
diff --git a/example/android/gradle.properties b/example/android/gradle.properties
index 38c8d45..94adc3a 100644
--- a/example/android/gradle.properties
+++ b/example/android/gradle.properties
@@ -1,4 +1,3 @@
org.gradle.jvmargs=-Xmx1536M
-android.enableR8=true
android.useAndroidX=true
android.enableJetifier=true
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index bc6a58a..cc5527d 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
diff --git a/example/android/settings.gradle b/example/android/settings.gradle
index d3b6a40..44e62bc 100644
--- a/example/android/settings.gradle
+++ b/example/android/settings.gradle
@@ -1,7 +1,3 @@
-// Copyright 2014 The Flutter Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
diff --git a/example/ios/.gitignore b/example/ios/.gitignore
index e96ef60..7a7f987 100644
--- a/example/ios/.gitignore
+++ b/example/ios/.gitignore
@@ -1,3 +1,4 @@
+**/dgph
*.mode1v3
*.mode2v3
*.moved-aside
@@ -18,6 +19,7 @@ Flutter/App.framework
Flutter/Flutter.framework
Flutter/Flutter.podspec
Flutter/Generated.xcconfig
+Flutter/ephemeral/
Flutter/app.flx
Flutter/app.zip
Flutter/flutter_assets/
diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist
index f2872cf..8d4492f 100644
--- a/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/example/ios/Flutter/AppFrameworkInfo.plist
@@ -3,7 +3,7 @@
CFBundleDevelopmentRegion
- $(DEVELOPMENT_LANGUAGE)
+ en
CFBundleExecutable
App
CFBundleIdentifier
diff --git a/example/ios/Flutter/Debug.xcconfig b/example/ios/Flutter/Debug.xcconfig
index e8efba1..ec97fc6 100644
--- a/example/ios/Flutter/Debug.xcconfig
+++ b/example/ios/Flutter/Debug.xcconfig
@@ -1,2 +1,2 @@
-#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
#include "Generated.xcconfig"
diff --git a/example/ios/Flutter/Release.xcconfig b/example/ios/Flutter/Release.xcconfig
index 399e934..c4855bf 100644
--- a/example/ios/Flutter/Release.xcconfig
+++ b/example/ios/Flutter/Release.xcconfig
@@ -1,2 +1,2 @@
-#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
+#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
#include "Generated.xcconfig"
diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock
index e1cbe75..4e88ddc 100644
--- a/example/ios/Podfile.lock
+++ b/example/ios/Podfile.lock
@@ -3,22 +3,22 @@ PODS:
- FMDB (2.7.5):
- FMDB/standard (= 2.7.5)
- FMDB/standard (2.7.5)
- - path_provider (0.0.1):
+ - path_provider_ios (0.0.1):
- Flutter
- sqflite (0.0.2):
- Flutter
- FMDB (>= 2.7.5)
- - weibo_kit (3.1.0):
+ - weibo_kit (4.0.0):
- Flutter
- - weibo_kit/vendor (= 3.1.0)
- - weibo_kit/vendor (3.1.0):
+ - weibo_kit/vendor (= 4.0.0)
+ - weibo_kit/vendor (4.0.0):
- Flutter
- Weibo_SDK (~> 3.3.0)
- Weibo_SDK (3.3.0)
DEPENDENCIES:
- Flutter (from `Flutter`)
- - path_provider (from `.symlinks/plugins/path_provider/ios`)
+ - path_provider_ios (from `.symlinks/plugins/path_provider_ios/ios`)
- sqflite (from `.symlinks/plugins/sqflite/ios`)
- weibo_kit (from `.symlinks/plugins/weibo_kit/ios`)
@@ -30,8 +30,8 @@ SPEC REPOS:
EXTERNAL SOURCES:
Flutter:
:path: Flutter
- path_provider:
- :path: ".symlinks/plugins/path_provider/ios"
+ path_provider_ios:
+ :path: ".symlinks/plugins/path_provider_ios/ios"
sqflite:
:path: ".symlinks/plugins/sqflite/ios"
weibo_kit:
@@ -40,9 +40,9 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
Flutter: 50d75fe2f02b26cc09d224853bb45737f8b3214a
FMDB: 2ce00b547f966261cd18927a3ddb07cb6f3db82a
- path_provider: abfe2b5c733d04e238b0d8691db0cfd63a27a93c
+ path_provider_ios: 14f3d2fd28c4fdb42f44e0f751d12861c43cee02
sqflite: 6d358c025f5b867b29ed92fc697fd34924e11904
- weibo_kit: 2b9acdf65bf6effde4231759e53e136db0c01380
+ weibo_kit: 8064857ffe649258a0e813d94e4690cf4ef4d948
Weibo_SDK: 7478846cccb43c4785ba76b214115fb7ec9dc0d4
PODFILE CHECKSUM: 8e679eca47255a8ca8067c4c67aab20e64cb974d
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 116fc15..8e6f9c8 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -3,18 +3,18 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 51;
+ objectVersion = 50;
objects = {
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
- 3CDD46DAA37A5371B2A70EC2 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FF490F57C9D1EABC131B9426 /* libPods-Runner.a */; };
978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; };
97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
+ 9D6A641CC2AA3D1DAB1CA737 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D17CA4B716FF2615EC5592DD /* libPods-Runner.a */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -31,13 +31,14 @@
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
+ 08F4E8DC6CED25389BD315E9 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
+ 148E72EBAA782EE70454F3DD /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
- 8C3451CC4D3C94BCDF014D4C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -46,9 +47,8 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
- C5C37EFD234544E62872E54A /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
- E0BD40F9BEC5B3B35E91E09D /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
- FF490F57C9D1EABC131B9426 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
+ AD1CFD40D1E8023F905A8C4C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
+ D17CA4B716FF2615EC5592DD /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -56,21 +56,19 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
- 3CDD46DAA37A5371B2A70EC2 /* libPods-Runner.a in Frameworks */,
+ 9D6A641CC2AA3D1DAB1CA737 /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
- 6C41AA3581FC291CB33F9055 /* Pods */ = {
+ 02EA110EDFCF98FC06871CF0 /* Frameworks */ = {
isa = PBXGroup;
children = (
- E0BD40F9BEC5B3B35E91E09D /* Pods-Runner.debug.xcconfig */,
- C5C37EFD234544E62872E54A /* Pods-Runner.release.xcconfig */,
- 8C3451CC4D3C94BCDF014D4C /* Pods-Runner.profile.xcconfig */,
+ D17CA4B716FF2615EC5592DD /* libPods-Runner.a */,
);
- path = Pods;
+ name = Frameworks;
sourceTree = "";
};
9740EEB11CF90186004384FC /* Flutter */ = {
@@ -90,8 +88,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
- 6C41AA3581FC291CB33F9055 /* Pods */,
- 97EA60ED8F200E6F573A9890 /* Frameworks */,
+ D4D0DC52653A5DE40E2C9908 /* Pods */,
+ 02EA110EDFCF98FC06871CF0 /* Frameworks */,
);
sourceTree = "";
};
@@ -127,12 +125,15 @@
name = "Supporting Files";
sourceTree = "";
};
- 97EA60ED8F200E6F573A9890 /* Frameworks */ = {
+ D4D0DC52653A5DE40E2C9908 /* Pods */ = {
isa = PBXGroup;
children = (
- FF490F57C9D1EABC131B9426 /* libPods-Runner.a */,
+ AD1CFD40D1E8023F905A8C4C /* Pods-Runner.debug.xcconfig */,
+ 08F4E8DC6CED25389BD315E9 /* Pods-Runner.release.xcconfig */,
+ 148E72EBAA782EE70454F3DD /* Pods-Runner.profile.xcconfig */,
);
- name = Frameworks;
+ name = Pods;
+ path = Pods;
sourceTree = "";
};
/* End PBXGroup section */
@@ -142,14 +143,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
- 631D2F29201BBC63DC66AD43 /* [CP] Check Pods Manifest.lock */,
+ AD4B13FBAB7E2A550C0DD869 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
- BEFF80007E7E4E2B2694658C /* [CP] Copy Pods Resources */,
+ 64BE94D785EB23A0C92F017D /* [CP] Copy Pods Resources */,
);
buildRules = (
);
@@ -221,7 +222,38 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin";
};
- 631D2F29201BBC63DC66AD43 /* [CP] Check Pods Manifest.lock */ = {
+ 64BE94D785EB23A0C92F017D /* [CP] Copy Pods Resources */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Copy Pods Resources";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
+ 9740EEB61CF901F6004384FC /* Run Script */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputPaths = (
+ );
+ name = "Run Script";
+ outputPaths = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
+ };
+ AD4B13FBAB7E2A550C0DD869 /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
@@ -243,37 +275,6 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
- 9740EEB61CF901F6004384FC /* Run Script */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- name = "Run Script";
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
- };
- BEFF80007E7E4E2B2694658C /* [CP] Copy Pods Resources */ = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputFileListPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-input-files.xcfilelist",
- );
- name = "[CP] Copy Pods Resources";
- outputFileListPaths = (
- "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources-${CONFIGURATION}-output-files.xcfilelist",
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
- showEnvVarsInLog = 0;
- };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -365,21 +366,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEVELOPMENT_TEAM = 78W43A3TE2;
ENABLE_BITCODE = NO;
- FRAMEWORK_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
INFOPLIST_FILE = Runner/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
PRODUCT_NAME = "$(TARGET_NAME)";
VERSIONING_SYSTEM = "apple-generic";
@@ -497,21 +490,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEVELOPMENT_TEAM = 78W43A3TE2;
ENABLE_BITCODE = NO;
- FRAMEWORK_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
INFOPLIST_FILE = Runner/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
PRODUCT_NAME = "$(TARGET_NAME)";
VERSIONING_SYSTEM = "apple-generic";
@@ -524,21 +509,13 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
+ DEVELOPMENT_TEAM = 78W43A3TE2;
ENABLE_BITCODE = NO;
- FRAMEWORK_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
INFOPLIST_FILE = Runner/Info.plist;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
- LIBRARY_SEARCH_PATHS = (
- "$(inherited)",
- "$(PROJECT_DIR)/Flutter",
- );
PRODUCT_BUNDLE_IDENTIFIER = io.github.v7lin.weiboKitExample;
PRODUCT_NAME = "$(TARGET_NAME)";
VERSIONING_SYSTEM = "apple-generic";
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
new file mode 100644
index 0000000..18d9810
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
@@ -0,0 +1,8 @@
+
+
+
+
+ IDEDidComputeMac32BitWarning
+
+
+
diff --git a/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
new file mode 100644
index 0000000..f9b0d7c
--- /dev/null
+++ b/example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
@@ -0,0 +1,8 @@
+
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index 3db53b6..c87d15a 100644
--- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -27,8 +27,6 @@
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
-
-
-
-
+
+
-
-
+
+
+
+ PreviewsEnabled
+
+
+
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index 9203935..812d77c 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -4,6 +4,8 @@
CFBundleDevelopmentRegion
$(DEVELOPMENT_LANGUAGE)
+ CFBundleDisplayName
+ Weibo Kit
CFBundleExecutable
$(EXECUTABLE_NAME)
CFBundleIdentifier
@@ -138,5 +140,7 @@
UIViewControllerBasedStatusBarAppearance
+ CADisableMinimumFrameDurationOnPhone
+
diff --git a/example/lib/model/weibo_api_resp.dart b/example/lib/api/model/weibo_api_resp.dart
similarity index 92%
rename from example/lib/model/weibo_api_resp.dart
rename to example/lib/api/model/weibo_api_resp.dart
index 17f1ee2..7341fb9 100644
--- a/example/lib/model/weibo_api_resp.dart
+++ b/example/lib/api/model/weibo_api_resp.dart
@@ -28,9 +28,9 @@ abstract class WeiboApiResp {
)
class WeiboUserInfoResp extends WeiboApiResp {
const WeiboUserInfoResp({
- required int errorCode,
- String? error,
- String? request,
+ required super.errorCode,
+ super.error,
+ super.request,
this.id,
this.idstr,
this.screenName,
@@ -41,7 +41,7 @@ class WeiboUserInfoResp extends WeiboApiResp {
this.gender,
this.avatarLarge,
this.avatarHd,
- }) : super(errorCode: errorCode, error: error, request: request);
+ });
factory WeiboUserInfoResp.fromJson(Map json) =>
_$WeiboUserInfoRespFromJson(json);
diff --git a/example/lib/model/weibo_api_resp.g.dart b/example/lib/api/model/weibo_api_resp.g.dart
similarity index 100%
rename from example/lib/model/weibo_api_resp.g.dart
rename to example/lib/api/model/weibo_api_resp.g.dart
diff --git a/example/lib/weibo.dart b/example/lib/api/weibo_api.dart
similarity index 88%
rename from example/lib/weibo.dart
rename to example/lib/api/weibo_api.dart
index ebdee1a..1af2c02 100644
--- a/example/lib/weibo.dart
+++ b/example/lib/api/weibo_api.dart
@@ -2,12 +2,13 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';
-import 'package:weibo_kit/weibo_kit.dart';
-import 'package:weibo_kit_example/model/weibo_api_resp.dart';
+import 'package:weibo_kit_example/api/model/weibo_api_resp.dart';
+
+class WeiboApi {
+ const WeiboApi._();
-extension ApiWeibo on Weibo {
/// 用户信息
- Future getUserInfo({
+ static Future getUserInfo({
required String appkey,
required String userId,
required String accessToken,
@@ -31,7 +32,7 @@ extension ApiWeibo on Weibo {
});
}
- Uri _encodeUrl(
+ static Uri _encodeUrl(
String baseUrl,
String appkey,
String accessToken,
diff --git a/example/lib/main.dart b/example/lib/main.dart
index e73f43b..b1f0bf3 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -1,13 +1,11 @@
import 'dart:async';
import 'dart:io';
-// import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:flutter_cache_manager/flutter_cache_manager.dart';
-// import 'package:image/image.dart' as image;
import 'package:weibo_kit/weibo_kit.dart';
-import 'package:weibo_kit_example/model/weibo_api_resp.dart';
-import 'package:weibo_kit_example/weibo.dart';
+import 'package:weibo_kit_example/api/model/weibo_api_resp.dart';
+import 'package:weibo_kit_example/api/weibo_api.dart';
const String _WEIBO_APP_KEY = 'your weibo app key';
const String _WEIBO_UNIVERSAL_LINK = 'your weibo universal link';
@@ -16,16 +14,14 @@ const List _WEIBO_SCOPE = [
];
void main() {
- WidgetsFlutterBinding.ensureInitialized();
- Weibo.instance.registerApp(
- appKey: _WEIBO_APP_KEY,
- universalLink: _WEIBO_UNIVERSAL_LINK,
- scope: _WEIBO_SCOPE,
- );
runApp(MyApp());
}
class MyApp extends StatelessWidget {
+ const MyApp({
+ super.key,
+ });
+
@override
Widget build(BuildContext context) {
return MaterialApp(
@@ -35,6 +31,9 @@ class MyApp extends StatelessWidget {
}
class Home extends StatefulWidget {
+ const Home({
+ super.key,
+ });
@override
State createState() {
return _HomeState();
@@ -73,12 +72,23 @@ class _HomeState extends State {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
- title: const Text('Weibo Kit Demo'),
+ title: Text('Weibo Kit Demo'),
),
body: ListView(
children: [
ListTile(
- title: const Text('环境检查'),
+ title: Text('注册APP'),
+ onTap: () async {
+ await Weibo.instance.registerApp(
+ appKey: _WEIBO_APP_KEY,
+ universalLink: _WEIBO_UNIVERSAL_LINK,
+ scope: _WEIBO_SCOPE,
+ );
+ _showTips('注册APP', '注册成功');
+ },
+ ),
+ ListTile(
+ title: Text('环境检查'),
onTap: () async {
final String content =
'weibo: ${await Weibo.instance.isInstalled()}';
@@ -86,7 +96,7 @@ class _HomeState extends State {
},
),
ListTile(
- title: const Text('登录'),
+ title: Text('登录'),
onTap: () {
Weibo.instance.auth(
appKey: _WEIBO_APP_KEY,
@@ -95,11 +105,11 @@ class _HomeState extends State {
},
),
ListTile(
- title: const Text('用户信息'),
+ title: Text('用户信息'),
onTap: () async {
if (_authResp?.isSuccessful ?? false) {
final WeiboUserInfoResp userInfoResp =
- await Weibo.instance.getUserInfo(
+ await WeiboApi.getUserInfo(
appkey: _WEIBO_APP_KEY,
userId: _authResp!.userId!,
accessToken: _authResp!.accessToken!,
@@ -115,7 +125,7 @@ class _HomeState extends State {
},
),
ListTile(
- title: const Text('文字分享'),
+ title: Text('文字分享'),
onTap: () {
Weibo.instance.shareText(
text: 'Share Text',
@@ -123,7 +133,7 @@ class _HomeState extends State {
},
),
ListTile(
- title: const Text('图片分享'),
+ title: Text('图片分享'),
onTap: () async {
final File file = await DefaultCacheManager().getSingleFile(
'https://www.baidu.com/img/bd_logo1.png?where=super');
@@ -134,7 +144,7 @@ class _HomeState extends State {
},
),
ListTile(
- title: const Text('网页分享'),
+ title: Text('网页分享'),
onTap: () async {
// final File file = await DefaultCacheManager().getSingleFile(
// 'https://www.baidu.com/img/bd_logo1.png?where=super');
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 681251d..f2d8b0d 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -1,34 +1,13 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
- _fe_analyzer_shared:
- dependency: transitive
- description:
- name: _fe_analyzer_shared
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "22.0.0"
- analyzer:
- dependency: transitive
- description:
- name: analyzer
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.7.2"
archive:
dependency: transitive
description:
name: archive
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.1.2"
- args:
- dependency: transitive
- description:
- name: args
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.2.0"
+ version: "3.3.0"
async:
dependency: transitive
description:
@@ -43,62 +22,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
- build:
- dependency: transitive
- description:
- name: build
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.3"
- build_config:
- dependency: transitive
- description:
- name: build_config
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.4.7"
- build_daemon:
- dependency: transitive
- description:
- name: build_daemon
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.1.10"
- build_resolvers:
- dependency: transitive
- description:
- name: build_resolvers
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.4"
- build_runner:
- dependency: "direct dev"
- description:
- name: build_runner
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.12.2"
- build_runner_core:
- dependency: transitive
- description:
- name: build_runner_core
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "6.1.12"
- built_collection:
- dependency: transitive
- description:
- name: built_collection
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "5.1.0"
- built_value:
- dependency: transitive
- description:
- name: built_value
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "8.1.1"
characters:
dependency: transitive
description:
@@ -113,20 +36,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
- checked_yaml:
- dependency: transitive
- description:
- name: checked_yaml
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.1"
- cli_util:
- dependency: transitive
- description:
- name: cli_util
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.3.3"
clock:
dependency: transitive
description:
@@ -134,76 +43,48 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
- code_builder:
- dependency: transitive
- description:
- name: code_builder
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "3.7.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.15.0"
- convert:
- dependency: transitive
- description:
- name: convert
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "3.0.1"
+ version: "1.16.0"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.0"
+ version: "3.0.2"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.2"
- dart_style:
- dependency: transitive
- description:
- name: dart_style
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.3.14"
+ version: "1.0.4"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.2.0"
+ version: "1.3.0"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.2.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.flutter-io.cn"
source: hosted
- version: "6.1.0"
- fixnum:
- dependency: transitive
- description:
- name: fixnum
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
+ version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
@@ -216,88 +97,53 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.3.0"
+ flutter_lints:
+ dependency: "direct dev"
+ description:
+ name: flutter_lints
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
- glob:
- dependency: transitive
- description:
- name: glob
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.1"
- graphs:
- dependency: transitive
- description:
- name: graphs
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.13.0"
- http_multi_server:
- dependency: transitive
- description:
- name: http_multi_server
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "3.0.1"
+ version: "0.13.4"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.0.0"
+ version: "4.0.1"
image:
dependency: "direct main"
description:
name: image
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.1"
- io:
- dependency: transitive
- description:
- name: io
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.3"
- js:
- dependency: transitive
- description:
- name: js
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.6.3"
+ version: "3.2.0"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.0.0"
- json_serializable:
- dependency: "direct dev"
- description:
- name: json_serializable
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "4.0.3"
- logging:
+ version: "4.5.0"
+ lints:
dependency: transitive
description:
- name: logging
+ name: lints
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.1"
+ version: "2.0.0"
matcher:
dependency: transitive
description:
@@ -311,7 +157,7 @@ packages:
name: material_color_utilities
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.1.3"
+ version: "0.1.4"
meta:
dependency: transitive
description:
@@ -319,76 +165,76 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
- mime:
- dependency: transitive
- description:
- name: mime
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
- package_config:
- dependency: transitive
- description:
- name: package_config
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.8.0"
+ version: "1.8.1"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.1"
+ version: "2.0.10"
+ path_provider_android:
+ dependency: transitive
+ description:
+ name: path_provider_android
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.0.14"
+ path_provider_ios:
+ dependency: transitive
+ description:
+ name: path_provider_ios
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.0.9"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.1.6"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.0.6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.1"
+ version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.0.6"
pedantic:
- dependency: "direct dev"
+ dependency: transitive
description:
name: pedantic
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.11.0"
+ version: "1.11.1"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.0.2"
+ version: "5.0.0"
platform:
dependency: transitive
description:
@@ -402,89 +248,47 @@ packages:
name: plugin_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
- pool:
- dependency: transitive
- description:
- name: pool
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.5.0"
+ version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.1.0"
- pub_semver:
- dependency: transitive
- description:
- name: pub_semver
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.0"
- pubspec_parse:
- dependency: transitive
- description:
- name: pubspec_parse
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
+ version: "4.2.4"
rxdart:
dependency: transitive
description:
name: rxdart
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.26.0"
- shelf:
- dependency: transitive
- description:
- name: shelf
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.2.0"
- shelf_web_socket:
- dependency: transitive
- description:
- name: shelf_web_socket
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.1"
+ version: "0.27.3"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
- source_gen:
- dependency: transitive
- description:
- name: source_gen
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.9.10+4"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.8.1"
+ version: "1.8.2"
sqflite:
dependency: transitive
description:
name: sqflite
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0+3"
+ version: "2.0.2+1"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0+2"
+ version: "2.2.1+1"
stack_trace:
dependency: transitive
description:
@@ -499,13 +303,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
- stream_transform:
- dependency: transitive
- description:
- name: stream_transform
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.0.0"
string_scanner:
dependency: transitive
description:
@@ -519,7 +316,7 @@ packages:
name: synchronized
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.0"
+ version: "3.0.0+2"
term_glyph:
dependency: transitive
description:
@@ -533,84 +330,56 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.4.8"
- timing:
- dependency: transitive
- description:
- name: timing
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
+ version: "0.4.9"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.1"
+ version: "3.0.6"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.1.1"
- watcher:
- dependency: transitive
- description:
- name: watcher
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "1.0.0"
- web_socket_channel:
- dependency: transitive
- description:
- name: web_socket_channel
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "2.1.0"
+ version: "2.1.2"
weibo_kit:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
- version: "3.1.0"
+ version: "4.0.0"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.4"
+ version: "2.6.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.2.0"
+ version: "0.2.0+1"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.flutter-io.cn"
source: hosted
- version: "5.0.2"
- yaml:
- dependency: transitive
- description:
- name: yaml
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "3.1.0"
+ version: "6.0.1"
sdks:
- dart: ">=2.14.0 <3.0.0"
- flutter: ">=1.24.0-10"
+ dart: ">=2.17.0 <3.0.0"
+ flutter: ">=2.8.1"
diff --git a/example/pubspec.yaml b/example/pubspec.yaml
index 12fb44e..b0b921e 100644
--- a/example/pubspec.yaml
+++ b/example/pubspec.yaml
@@ -2,14 +2,20 @@ name: weibo_kit_example
description: Demonstrates how to use the weibo_kit plugin.
# The following line prevents the package from being accidentally published to
-# pub.dev using `pub publish`. This is preferred for private packages.
+# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
-environment:
- sdk: ">=2.12.0 <3.0.0"
-
version: 1.0.0+100
+environment:
+ sdk: ">=2.17.0 <3.0.0"
+
+# Dependencies specify other packages that your package needs in order to work.
+# To automatically upgrade your package dependencies to the latest versions
+# consider running `flutter pub upgrade --major-versions`. Alternatively,
+# dependencies can be manually updated by changing the version numbers below to
+# the latest version available on pub.dev. To see which dependencies have newer
+# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
@@ -19,7 +25,7 @@ dependencies:
# weibo_kit: ^x.y.z
# See https://dart.dev/tools/pub/dependencies#version-constraints
# The example app is bundled with the plugin so we use a path dependency on
- # the parent directory to use the current plugin's version.
+ # the parent directory to use the current plugin's version.
path: ../
# The following adds the Cupertino Icons font to your application.
@@ -29,13 +35,18 @@ dependencies:
image: ^3.0.1
flutter_cache_manager: ^3.0.0
- json_annotation: ^4.0.0
+ json_annotation: ^4.5.0
dev_dependencies:
flutter_test:
sdk: flutter
- pedantic:
+ # The "flutter_lints" package below contains a set of recommended lints to
+ # encourage good coding practices. The lint set provided by the package is
+ # activated in the `analysis_options.yaml` file located at the root of your
+ # package. See that file for information about deactivating specific lint
+ # rules and activating additional ones.
+ flutter_lints: ^2.0.0
build_runner:
json_serializable:
@@ -43,7 +54,7 @@ dev_dependencies:
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
-# The following section is specific to Flutter.
+# The following section is specific to Flutter packages.
flutter:
# The following line ensures that the Material Icons font is
@@ -57,7 +68,7 @@ flutter:
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware.
+ # https://flutter.dev/assets-and-images/#resolution-aware
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart
index 570e0e4..4764edc 100644
--- a/example/test/widget_test.dart
+++ b/example/test/widget_test.dart
@@ -1,8 +1,12 @@
// This is a basic Flutter widget test.
//
// To perform an interaction with a widget in your test, use the WidgetTester
-// utility that Flutter provides. For example, you can send tap and scroll
+// utility in the flutter_test package. For example, you can send tap and scroll
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.
-void main() {}
+import 'package:flutter_test/flutter_test.dart';
+
+void main() {
+ testWidgets('smoke test', (WidgetTester tester) async {});
+}
diff --git a/ios/.gitignore b/ios/.gitignore
index aa479fd..0c88507 100644
--- a/ios/.gitignore
+++ b/ios/.gitignore
@@ -34,4 +34,5 @@ Icon?
.tags*
/Flutter/Generated.xcconfig
+/Flutter/ephemeral/
/Flutter/flutter_export_environment.sh
\ No newline at end of file
diff --git a/ios/Classes/WeiboKitPlugin.m b/ios/Classes/WeiboKitPlugin.m
index e582012..dedb7c0 100644
--- a/ios/Classes/WeiboKitPlugin.m
+++ b/ios/Classes/WeiboKitPlugin.m
@@ -10,43 +10,14 @@
}
+ (void)registerWithRegistrar:(NSObject *)registrar {
- FlutterMethodChannel *channel =
- [FlutterMethodChannel methodChannelWithName:@"v7lin.github.io/weibo_kit"
- binaryMessenger:[registrar messenger]];
+ FlutterMethodChannel *channel = [FlutterMethodChannel
+ methodChannelWithName:@"v7lin.github.io/weibo_kit"
+ binaryMessenger:[registrar messenger]];
WeiboKitPlugin *instance = [[WeiboKitPlugin alloc] initWithChannel:channel];
[registrar addApplicationDelegate:instance];
[registrar addMethodCallDelegate:instance channel:channel];
}
-static NSString *const METHOD_REGISTERAPP = @"registerApp";
-static NSString *const METHOD_ISINSTALLED = @"isInstalled";
-static NSString *const METHOD_AUTH = @"auth";
-static NSString *const METHOD_SHARETEXT = @"shareText";
-static NSString *const METHOD_SHAREIMAGE = @"shareImage";
-static NSString *const METHOD_SHAREWEBPAGE = @"shareWebpage";
-
-static NSString *const METHOD_ONAUTHRESP = @"onAuthResp";
-static NSString *const METHOD_ONSHAREMSGRESP = @"onShareMsgResp";
-
-static NSString *const ARGUMENT_KEY_APPKEY = @"appKey";
-static NSString *const ARGUMENT_KEY_UNIVERSALLINK = @"universalLink";
-static NSString *const ARGUMENT_KEY_SCOPE = @"scope";
-static NSString *const ARGUMENT_KEY_REDIRECTURL = @"redirectUrl";
-static NSString *const ARGUMENT_KEY_TEXT = @"text";
-static NSString *const ARGUMENT_KEY_TITLE = @"title";
-static NSString *const ARGUMENT_KEY_DESCRIPTION = @"description";
-static NSString *const ARGUMENT_KEY_THUMBDATA = @"thumbData";
-static NSString *const ARGUMENT_KEY_IMAGEDATA = @"imageData";
-static NSString *const ARGUMENT_KEY_IMAGEURI = @"imageUri";
-static NSString *const ARGUMENT_KEY_WEBPAGEURL = @"webpageUrl";
-
-static NSString *const ARGUMENT_KEY_RESULT_ERRORCODE = @"errorCode";
-static NSString *const ARGUMENT_KEY_RESULT_ERRORMESSAGE = @"errorMessage";
-static NSString *const ARGUMENT_KEY_RESULT_USERID = @"userId";
-static NSString *const ARGUMENT_KEY_RESULT_ACCESSTOKEN = @"accessToken";
-static NSString *const ARGUMENT_KEY_RESULT_REFRESHTOKEN = @"refreshToken";
-static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
-
- (instancetype)initWithChannel:(FlutterMethodChannel *)channel {
self = [super init];
if (self) {
@@ -57,19 +28,19 @@ static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
- (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result {
- if ([METHOD_REGISTERAPP isEqualToString:call.method]) {
- NSString *appKey = call.arguments[ARGUMENT_KEY_APPKEY];
- NSString *universalLink = call.arguments[ARGUMENT_KEY_UNIVERSALLINK];
+ if ([@"registerApp" isEqualToString:call.method]) {
+ NSString *appKey = call.arguments[@"appKey"];
+ NSString *universalLink = call.arguments[@"universalLink"];
[WeiboSDK registerApp:appKey universalLink:universalLink];
result(nil);
- } else if ([METHOD_ISINSTALLED isEqualToString:call.method]) {
+ } else if ([@"isInstalled" isEqualToString:call.method]) {
result([NSNumber numberWithBool:[WeiboSDK isWeiboAppInstalled]]);
- } else if ([METHOD_AUTH isEqualToString:call.method]) {
+ } else if ([@"auth" isEqualToString:call.method]) {
[self handleAuthCall:call result:result];
- } else if ([METHOD_SHARETEXT isEqualToString:call.method]) {
+ } else if ([@"shareText" isEqualToString:call.method]) {
[self handleShareTextCall:call result:result];
- } else if ([METHOD_SHAREIMAGE isEqualToString:call.method] ||
- [METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
+ } else if ([@"shareImage" isEqualToString:call.method] ||
+ [@"shareWebpage" isEqualToString:call.method]) {
[self handleShareMediaCall:call result:result];
} else {
result(FlutterMethodNotImplemented);
@@ -78,58 +49,61 @@ static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
- (void)handleAuthCall:(FlutterMethodCall *)call result:(FlutterResult)result {
WBAuthorizeRequest *request = [WBAuthorizeRequest request];
- request.scope = call.arguments[ARGUMENT_KEY_SCOPE];
- request.redirectURI = call.arguments[ARGUMENT_KEY_REDIRECTURL];
+ request.scope = call.arguments[@"scope"];
+ request.redirectURI = call.arguments[@"redirectUrl"];
request.shouldShowWebViewForAuthIfCannotSSO = YES;
request.shouldOpenWeiboAppInstallPageIfNotInstalled = NO;
- [WeiboSDK sendRequest:request completion:^(BOOL success) {
- // do nothing
- }];
+ [WeiboSDK sendRequest:request
+ completion:^(BOOL success){
+ // do nothing
+ }];
result(nil);
}
- (void)handleShareTextCall:(FlutterMethodCall *)call result:(FlutterResult)result {
WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest request];
WBMessageObject *message = [WBMessageObject message];
- message.text = call.arguments[ARGUMENT_KEY_TEXT];
+ message.text = call.arguments[@"text"];
request.message = message;
- [WeiboSDK sendRequest:request completion:^(BOOL success) {
- // do nothing
- }];
+ [WeiboSDK sendRequest:request
+ completion:^(BOOL success){
+ // do nothing
+ }];
result(nil);
}
- (void)handleShareMediaCall:(FlutterMethodCall *)call result:(FlutterResult)result {
WBSendMessageToWeiboRequest *request = [WBSendMessageToWeiboRequest request];
WBMessageObject *message = [WBMessageObject message];
- if ([METHOD_SHAREIMAGE isEqualToString:call.method]) {
- message.text = call.arguments[ARGUMENT_KEY_TEXT];
+ if ([@"shareImage" isEqualToString:call.method]) {
+ message.text = call.arguments[@"text"];
WBImageObject *object = [WBImageObject object];
- FlutterStandardTypedData *imageData = call.arguments[ARGUMENT_KEY_IMAGEDATA];
+ FlutterStandardTypedData *imageData = call.arguments[@"imageData"];
if (imageData != nil) {
object.imageData = imageData.data;
} else {
- NSString *imageUri = call.arguments[ARGUMENT_KEY_IMAGEURI];
+ NSString *imageUri = call.arguments[@"imageUri"];
NSURL *imageUrl = [NSURL URLWithString:imageUri];
object.imageData = [NSData dataWithContentsOfFile:imageUrl.path];
}
message.imageObject = object;
- } else if ([METHOD_SHAREWEBPAGE isEqualToString:call.method]) {
+ } else if ([@"shareWebpage" isEqualToString:call.method]) {
WBWebpageObject *object = [WBWebpageObject object];
object.objectID = [[NSUUID UUID].UUIDString stringByReplacingOccurrencesOfString:@"-" withString:@""];
- object.title = call.arguments[ARGUMENT_KEY_TITLE];
- object.description = call.arguments[ARGUMENT_KEY_DESCRIPTION];
- FlutterStandardTypedData *thumbData = call.arguments[ARGUMENT_KEY_THUMBDATA];
+ object.title = call.arguments[@"title"];
+ object.description = call.arguments[@"description"];
+ FlutterStandardTypedData *thumbData = call.arguments[@"thumbData"];
if (thumbData != nil) {
object.thumbnailData = thumbData.data;
}
- object.webpageUrl = call.arguments[ARGUMENT_KEY_WEBPAGEURL];
+ object.webpageUrl = call.arguments[@"webpageUrl"];
message.mediaObject = object;
}
request.message = message;
- [WeiboSDK sendRequest:request completion:^(BOOL success) {
- // do nothing
- }];
+ [WeiboSDK sendRequest:request
+ completion:^(BOOL success){
+ // do nothing
+ }];
result(nil);
}
@@ -147,8 +121,9 @@ static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
return [WeiboSDK handleOpenURL:url delegate:self];
}
-- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray * _Nonnull))restorationHandler {
- return [WeiboSDK handleOpenUniversalLink:userActivity delegate:self];;
+- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *_Nonnull))restorationHandler {
+ return [WeiboSDK handleOpenUniversalLink:userActivity delegate:self];
+ ;
}
#pragma mark - WeiboSDKDelegate
@@ -158,7 +133,7 @@ static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
- (void)didReceiveWeiboResponse:(WBBaseResponse *)response {
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
- [dictionary setValue:[NSNumber numberWithInteger:response.statusCode] forKey:ARGUMENT_KEY_RESULT_ERRORCODE];
+ [dictionary setValue:[NSNumber numberWithInteger:response.statusCode] forKey:@"errorCode"];
if ([response isKindOfClass:[WBAuthorizeResponse class]]) {
if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) {
WBAuthorizeResponse *authorizeResponse = (WBAuthorizeResponse *)response;
@@ -166,17 +141,17 @@ static NSString *const ARGUMENT_KEY_RESULT_EXPIRESIN = @"expiresIn";
NSString *accessToken = authorizeResponse.accessToken;
NSString *refreshToken = authorizeResponse.refreshToken;
long long expiresIn = ceil(authorizeResponse.expirationDate.timeIntervalSinceNow); // 向上取整
- [dictionary setValue:userId forKey:ARGUMENT_KEY_RESULT_USERID];
- [dictionary setValue:accessToken forKey:ARGUMENT_KEY_RESULT_ACCESSTOKEN];
- [dictionary setValue:refreshToken forKey:ARGUMENT_KEY_RESULT_REFRESHTOKEN];
- [dictionary setValue:[NSNumber numberWithLongLong:expiresIn] forKey:ARGUMENT_KEY_RESULT_EXPIRESIN];
+ [dictionary setValue:userId forKey:@"userId"];
+ [dictionary setValue:accessToken forKey:@"accessToken"];
+ [dictionary setValue:refreshToken forKey:@"refreshToken"];
+ [dictionary setValue:[NSNumber numberWithLongLong:expiresIn] forKey:@"expiresIn"];
}
- [_channel invokeMethod:METHOD_ONAUTHRESP arguments:dictionary];
+ [_channel invokeMethod:@"onAuthResp" arguments:dictionary];
} else if ([response isKindOfClass:[WBSendMessageToWeiboResponse class]]) {
if (response.statusCode == WeiboSDKResponseStatusCodeSuccess) {
WBSendMessageToWeiboResponse *sendMessageToWeiboResponse = (WBSendMessageToWeiboResponse *)response;
}
- [_channel invokeMethod:METHOD_ONSHAREMSGRESP arguments:dictionary];
+ [_channel invokeMethod:@"onShareMsgResp" arguments:dictionary];
}
}
diff --git a/ios/weibo_kit.podspec b/ios/weibo_kit.podspec
index c3aa9a0..0ed1231 100644
--- a/ios/weibo_kit.podspec
+++ b/ios/weibo_kit.podspec
@@ -1,10 +1,10 @@
#
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html.
-# Run `pod lib lint weibo_kit.podspec' to validate before publishing.
+# Run `pod lib lint weibo_kit.podspec` to validate before publishing.
#
Pod::Spec.new do |s|
s.name = 'weibo_kit'
- s.version = '3.1.0'
+ s.version = '4.0.0'
s.summary = 'A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Weibo SDKs.'
s.description = <<-DESC
A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Weibo SDKs.
diff --git a/lib/src/model/resp.dart b/lib/src/model/resp.dart
index 66c40b9..808b961 100644
--- a/lib/src/model/resp.dart
+++ b/lib/src/model/resp.dart
@@ -57,14 +57,14 @@ abstract class BaseResp {
explicitToJson: true,
)
class AuthResp extends BaseResp {
- AuthResp({
- required int errorCode,
- String? errorMessage,
+ const AuthResp({
+ required super.errorCode,
+ super.errorMessage,
this.userId,
this.accessToken,
this.refreshToken,
this.expiresIn,
- }) : super(errorCode: errorCode, errorMessage: errorMessage);
+ });
factory AuthResp.fromJson(Map json) =>
_$AuthRespFromJson(json);
@@ -83,9 +83,9 @@ class AuthResp extends BaseResp {
)
class ShareMsgResp extends BaseResp {
const ShareMsgResp({
- required int errorCode,
- String? errorMessage,
- }) : super(errorCode: errorCode, errorMessage: errorMessage);
+ required super.errorCode,
+ super.errorMessage,
+ });
factory ShareMsgResp.fromJson(Map json) =>
_$ShareMsgRespFromJson(json);
diff --git a/lib/src/weibo.dart b/lib/src/weibo.dart
index e3bb6f3..642b1c3 100644
--- a/lib/src/weibo.dart
+++ b/lib/src/weibo.dart
@@ -1,163 +1,7 @@
-import 'dart:async';
-import 'dart:io';
-import 'dart:typed_data';
-
-import 'package:flutter/services.dart';
-import 'package:weibo_kit/src/model/resp.dart';
+import 'package:weibo_kit/src/weibo_kit_platform_interface.dart';
class Weibo {
- ///
- Weibo._();
+ const Weibo._();
- static Weibo get instance => _instance;
-
- static final Weibo _instance = Weibo._();
-
- static const String _METHOD_REGISTERAPP = 'registerApp';
- static const String _METHOD_ISINSTALLED = 'isInstalled';
- static const String _METHOD_AUTH = 'auth';
- static const String _METHOD_SHARETEXT = 'shareText';
- static const String _METHOD_SHAREIMAGE = 'shareImage';
- static const String _METHOD_SHAREWEBPAGE = 'shareWebpage';
-
- static const String _METHOD_ONAUTHRESP = 'onAuthResp';
- static const String _METHOD_ONSHAREMSGRESP = 'onShareMsgResp';
-
- static const String _ARGUMENT_KEY_APPKEY = 'appKey';
- static const String _ARGUMENT_KEY_UNIVERSALLINK = 'universalLink';
- static const String _ARGUMENT_KEY_SCOPE = 'scope';
- static const String _ARGUMENT_KEY_REDIRECTURL = 'redirectUrl';
- static const String _ARGUMENT_KEY_TEXT = 'text';
- static const String _ARGUMENT_KEY_TITLE = 'title';
- static const String _ARGUMENT_KEY_DESCRIPTION = 'description';
- static const String _ARGUMENT_KEY_THUMBDATA = 'thumbData';
- static const String _ARGUMENT_KEY_IMAGEDATA = 'imageData';
- static const String _ARGUMENT_KEY_IMAGEURI = 'imageUri';
- static const String _ARGUMENT_KEY_WEBPAGEURL = 'webpageUrl';
-
- static const String _SCHEME_FILE = 'file';
-
- static const String _DEFAULT_REDIRECTURL =
- 'https://api.weibo.com/oauth2/default.html';
-
- late final MethodChannel _channel =
- const MethodChannel('v7lin.github.io/weibo_kit')
- ..setMethodCallHandler(_handleMethod);
-
- final StreamController _respStreamController =
- StreamController.broadcast();
-
- Future registerApp({
- required String appKey,
- required String? universalLink,
- required List scope,
- String redirectUrl =
- _DEFAULT_REDIRECTURL, // 新浪微博开放平台 -> 我的应用 -> 应用信息 -> 高级信息 -> OAuth2.0授权设置
- }) {
- assert(!Platform.isIOS || (universalLink?.isNotEmpty ?? false));
- return _channel.invokeMethod(
- _METHOD_REGISTERAPP,
- {
- _ARGUMENT_KEY_APPKEY: appKey,
- _ARGUMENT_KEY_UNIVERSALLINK: universalLink,
- _ARGUMENT_KEY_SCOPE: scope.join(','),
- _ARGUMENT_KEY_REDIRECTURL: redirectUrl,
- },
- );
- }
-
- Future _handleMethod(MethodCall call) async {
- switch (call.method) {
- case _METHOD_ONAUTHRESP:
- _respStreamController.add(AuthResp.fromJson(
- (call.arguments as Map).cast()));
- break;
- case _METHOD_ONSHAREMSGRESP:
- _respStreamController.add(ShareMsgResp.fromJson(
- (call.arguments as Map).cast()));
- break;
- }
- }
-
- ///
- Stream respStream() {
- return _respStreamController.stream;
- }
-
- Future isInstalled() async {
- return await _channel.invokeMethod(_METHOD_ISINSTALLED) ?? false;
- }
-
- /// 登录
- Future auth({
- required String appKey,
- required List scope,
- String redirectUrl = _DEFAULT_REDIRECTURL,
- }) {
- return _channel.invokeMethod(
- _METHOD_AUTH,
- {
- _ARGUMENT_KEY_APPKEY: appKey,
- _ARGUMENT_KEY_SCOPE: scope.join(','),
- _ARGUMENT_KEY_REDIRECTURL: redirectUrl,
- },
- );
- }
-
- /// 分享 - 文本
- Future shareText({
- required String text,
- }) {
- return _channel.invokeMethod(
- _METHOD_SHARETEXT,
- {
- _ARGUMENT_KEY_TEXT: text,
- },
- );
- }
-
- /// 分享 - 图片
- Future shareImage({
- String? text,
- Uint8List? imageData,
- Uri? imageUri,
- }) {
- assert(text == null || text.length <= 1024);
- assert((imageData != null && imageData.lengthInBytes <= 2 * 1024 * 1024) ||
- (imageUri != null &&
- imageUri.isScheme(_SCHEME_FILE) &&
- imageUri.toFilePath().length <= 512 &&
- File.fromUri(imageUri).lengthSync() <= 10 * 1024 * 1024));
- return _channel.invokeMethod(
- _METHOD_SHAREIMAGE,
- {
- if (text != null && text.isNotEmpty) _ARGUMENT_KEY_TEXT: text,
- if (imageData != null) _ARGUMENT_KEY_IMAGEDATA: imageData,
- if (imageUri != null) _ARGUMENT_KEY_IMAGEURI: imageUri.toString(),
- },
- );
- }
-
- /// 分享 - 网页
- @Deprecated('iOS:分享多媒体已经弃用 请不要用相关api')
- Future shareWebpage({
- required String title,
- required String description,
- required Uint8List thumbData,
- required String webpageUrl,
- }) {
- assert(title.length <= 512);
- assert(description.isNotEmpty && description.length <= 1024);
- assert(thumbData.lengthInBytes <= 32 * 1024);
- assert(webpageUrl.length <= 255);
- return _channel.invokeMethod(
- _METHOD_SHAREWEBPAGE,
- {
- _ARGUMENT_KEY_TITLE: title,
- _ARGUMENT_KEY_DESCRIPTION: description,
- _ARGUMENT_KEY_THUMBDATA: thumbData,
- _ARGUMENT_KEY_WEBPAGEURL: webpageUrl,
- },
- );
- }
+ static WeiboKitPlatform get instance => WeiboKitPlatform.instance;
}
diff --git a/lib/src/weibo_constant.dart b/lib/src/weibo_constant.dart
index ef81fe8..ccca6d8 100644
--- a/lib/src/weibo_constant.dart
+++ b/lib/src/weibo_constant.dart
@@ -1,3 +1,10 @@
+class WeiboRegister {
+ const WeiboRegister._();
+
+ static const String DEFAULT_REDIRECTURL =
+ 'https://api.weibo.com/oauth2/default.html';
+}
+
class WeiboScope {
const WeiboScope._();
diff --git a/lib/src/weibo_kit_method_channel.dart b/lib/src/weibo_kit_method_channel.dart
new file mode 100644
index 0000000..22019d9
--- /dev/null
+++ b/lib/src/weibo_kit_method_channel.dart
@@ -0,0 +1,134 @@
+import 'dart:async';
+import 'dart:io';
+import 'dart:typed_data';
+
+import 'package:flutter/foundation.dart';
+import 'package:flutter/services.dart';
+import 'package:weibo_kit/src/model/resp.dart';
+import 'package:weibo_kit/src/weibo_constant.dart';
+import 'package:weibo_kit/src/weibo_kit_platform_interface.dart';
+
+/// An implementation of [WeiboKitPlatform] that uses method channels.
+class MethodChannelWeiboKit extends WeiboKitPlatform {
+ /// The method channel used to interact with the native platform.
+ @visibleForTesting
+ late final MethodChannel methodChannel =
+ const MethodChannel('v7lin.github.io/weibo_kit')
+ ..setMethodCallHandler(_handleMethod);
+ final StreamController _respStreamController =
+ StreamController.broadcast();
+
+ Future _handleMethod(MethodCall call) async {
+ switch (call.method) {
+ case 'onAuthResp':
+ _respStreamController.add(AuthResp.fromJson(
+ (call.arguments as Map).cast()));
+ break;
+ case 'onShareMsgResp':
+ _respStreamController.add(ShareMsgResp.fromJson(
+ (call.arguments as Map).cast()));
+ break;
+ }
+ }
+
+ @override
+ Future registerApp({
+ required String appKey,
+ required String? universalLink,
+ required List scope,
+ String redirectUrl = WeiboRegister.DEFAULT_REDIRECTURL,
+ }) {
+ assert(!Platform.isIOS || (universalLink?.isNotEmpty ?? false));
+ return methodChannel.invokeMethod(
+ 'registerApp',
+ {
+ 'appKey': appKey,
+ 'universalLink': universalLink,
+ 'scope': scope.join(','),
+ 'redirectUrl': redirectUrl,
+ },
+ );
+ }
+
+ @override
+ Stream respStream() {
+ return _respStreamController.stream;
+ }
+
+ @override
+ Future isInstalled() async {
+ return await methodChannel.invokeMethod('isInstalled') ?? false;
+ }
+
+ @override
+ Future auth({
+ required String appKey,
+ required List scope,
+ String redirectUrl = WeiboRegister.DEFAULT_REDIRECTURL,
+ }) {
+ return methodChannel.invokeMethod(
+ 'auth',
+ {
+ 'appKey': appKey,
+ 'scope': scope.join(','),
+ 'redirectUrl': redirectUrl,
+ },
+ );
+ }
+
+ @override
+ Future shareText({
+ required String text,
+ }) {
+ return methodChannel.invokeMethod(
+ 'shareText',
+ {
+ 'text': text,
+ },
+ );
+ }
+
+ @override
+ Future shareImage({
+ String? text,
+ Uint8List? imageData,
+ Uri? imageUri,
+ }) {
+ assert(text == null || text.length <= 1024);
+ assert((imageData != null && imageData.lengthInBytes <= 2 * 1024 * 1024) ||
+ (imageUri != null &&
+ imageUri.isScheme('file') &&
+ imageUri.toFilePath().length <= 512 &&
+ File.fromUri(imageUri).lengthSync() <= 10 * 1024 * 1024));
+ return methodChannel.invokeMethod(
+ 'shareImage',
+ {
+ if (text != null && text.isNotEmpty) 'text': text,
+ if (imageData != null) 'imageData': imageData,
+ if (imageUri != null) 'imageUri': imageUri.toString(),
+ },
+ );
+ }
+
+ @override
+ Future shareWebpage({
+ required String title,
+ required String description,
+ required Uint8List thumbData,
+ required String webpageUrl,
+ }) {
+ assert(title.length <= 512);
+ assert(description.isNotEmpty && description.length <= 1024);
+ assert(thumbData.lengthInBytes <= 32 * 1024);
+ assert(webpageUrl.length <= 255);
+ return methodChannel.invokeMethod(
+ 'shareWebpage',
+ {
+ 'title': title,
+ 'description': description,
+ 'thumbData': thumbData,
+ 'webpageUrl': webpageUrl,
+ },
+ );
+ }
+}
diff --git a/lib/src/weibo_kit_platform_interface.dart b/lib/src/weibo_kit_platform_interface.dart
new file mode 100644
index 0000000..5429b89
--- /dev/null
+++ b/lib/src/weibo_kit_platform_interface.dart
@@ -0,0 +1,90 @@
+import 'dart:typed_data';
+
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+import 'package:weibo_kit/src/model/resp.dart';
+import 'package:weibo_kit/src/weibo_constant.dart';
+import 'package:weibo_kit/src/weibo_kit_method_channel.dart';
+
+abstract class WeiboKitPlatform extends PlatformInterface {
+ /// Constructs a WeiboKitPlatform.
+ WeiboKitPlatform() : super(token: _token);
+
+ static final Object _token = Object();
+
+ static WeiboKitPlatform _instance = MethodChannelWeiboKit();
+
+ /// The default instance of [WeiboKitPlatform] to use.
+ ///
+ /// Defaults to [MethodChannelWeiboKit].
+ static WeiboKitPlatform get instance => _instance;
+
+ /// Platform-specific implementations should set this with their own
+ /// platform-specific class that extends [WeiboKitPlatform] when
+ /// they register themselves.
+ static set instance(WeiboKitPlatform instance) {
+ PlatformInterface.verifyToken(instance, _token);
+ _instance = instance;
+ }
+
+ ///
+ Future registerApp({
+ required String appKey,
+ required String? universalLink,
+ required List scope,
+ String redirectUrl = WeiboRegister
+ .DEFAULT_REDIRECTURL, // 新浪微博开放平台 -> 我的应用 -> 应用信息 -> 高级信息 -> OAuth2.0授权设置
+ }) {
+ throw UnimplementedError(
+ 'registerApp({required appKey, required universalLink, required scope, redirectUrl}) has not been implemented.');
+ }
+
+ ///
+ Stream respStream() {
+ throw UnimplementedError('respStream() has not been implemented.');
+ }
+
+ ///
+ Future isInstalled() {
+ throw UnimplementedError('isInstalled() has not been implemented.');
+ }
+
+ /// 登录
+ Future auth({
+ required String appKey,
+ required List scope,
+ String redirectUrl = WeiboRegister.DEFAULT_REDIRECTURL,
+ }) {
+ throw UnimplementedError(
+ 'auth({required appKey, required scope, redirectUrl}) has not been implemented.');
+ }
+
+ /// 分享 - 文本
+ Future shareText({
+ required String text,
+ }) {
+ throw UnimplementedError(
+ 'shareText({required text}) has not been implemented.');
+ }
+
+ /// 分享 - 图片
+ Future shareImage({
+ String? text,
+ Uint8List? imageData,
+ Uri? imageUri,
+ }) {
+ throw UnimplementedError(
+ 'shareImage({text, imageData, imageUri}) has not been implemented.');
+ }
+
+ /// 分享 - 网页
+ @Deprecated('iOS:分享多媒体已经弃用 请不要用相关api')
+ Future shareWebpage({
+ required String title,
+ required String description,
+ required Uint8List thumbData,
+ required String webpageUrl,
+ }) {
+ throw UnimplementedError(
+ 'shareWebpage({required title, required description, required thumbData, required webpageUrl}) has not been implemented.');
+ }
+}
diff --git a/lib/weibo_kit_platform_interface.dart b/lib/weibo_kit_platform_interface.dart
new file mode 100644
index 0000000..1970525
--- /dev/null
+++ b/lib/weibo_kit_platform_interface.dart
@@ -0,0 +1,6 @@
+library weibo_kit_platform_interface;
+
+export 'src/model/resp.dart';
+export 'src/weibo_constant.dart';
+export 'src/weibo_kit_method_channel.dart';
+export 'src/weibo_kit_platform_interface.dart';
diff --git a/pubspec.lock b/pubspec.lock
index 33e9740..897b809 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -7,21 +7,21 @@ packages:
name: _fe_analyzer_shared
url: "https://pub.flutter-io.cn"
source: hosted
- version: "18.0.0"
+ version: "40.0.0"
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.2.0"
+ version: "4.1.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.3.1"
async:
dependency: transitive
description:
@@ -42,56 +42,56 @@ packages:
name: build
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.3.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.4.7"
+ version: "1.0.0"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.1.10"
+ version: "3.1.0"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.0.8"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.12.2"
+ version: "2.1.11"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.flutter-io.cn"
source: hosted
- version: "6.1.12"
+ version: "7.2.3"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.flutter-io.cn"
source: hosted
- version: "5.0.0"
+ version: "5.1.1"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.flutter-io.cn"
source: hosted
- version: "8.0.3"
+ version: "8.3.0"
characters:
dependency: transitive
description:
@@ -113,13 +113,6 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.1"
- cli_util:
- dependency: transitive
- description:
- name: cli_util
- url: "https://pub.flutter-io.cn"
- source: hosted
- version: "0.3.0"
clock:
dependency: transitive
description:
@@ -133,87 +126,101 @@ packages:
name: code_builder
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.7.0"
+ version: "4.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.15.0"
+ version: "1.16.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.0"
+ version: "3.0.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.0"
+ version: "3.0.2"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.3.14"
+ version: "2.2.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.2.0"
+ version: "1.3.0"
file:
dependency: transitive
description:
name: file
url: "https://pub.flutter-io.cn"
source: hosted
- version: "6.1.0"
+ version: "6.1.2"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.0.1"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
+ flutter_lints:
+ dependency: "direct dev"
+ description:
+ name: flutter_lints
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
+ frontend_server_client:
+ dependency: transitive
+ description:
+ name: frontend_server_client
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.1.3"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.0.2"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "2.1.0"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.0.0"
+ version: "3.2.0"
http_parser:
dependency: transitive
description:
@@ -227,35 +234,42 @@ packages:
name: io
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.0.3"
js:
dependency: transitive
description:
name: js
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.6.3"
+ version: "0.6.4"
json_annotation:
dependency: "direct main"
description:
name: json_annotation
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.0.0"
+ version: "4.5.0"
json_serializable:
dependency: "direct dev"
description:
name: json_serializable
url: "https://pub.flutter-io.cn"
source: hosted
- version: "4.0.3"
+ version: "6.2.0"
+ lints:
+ dependency: transitive
+ description:
+ name: lints
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "2.0.0"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.0.2"
matcher:
dependency: transitive
description:
@@ -263,6 +277,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.11"
+ material_color_utilities:
+ dependency: transitive
+ description:
+ name: material_color_utilities
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "0.1.4"
meta:
dependency: transitive
description:
@@ -276,28 +297,28 @@ packages:
name: mime
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.0.2"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.0.2"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.8.0"
- pedantic:
- dependency: "direct dev"
+ version: "1.8.1"
+ plugin_platform_interface:
+ dependency: "direct main"
description:
- name: pedantic
+ name: plugin_platform_interface
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.11.0"
+ version: "2.1.2"
pool:
dependency: transitive
description:
@@ -311,21 +332,21 @@ packages:
name: pub_semver
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.1.1"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.2.0"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.1.0"
+ version: "1.3.0"
shelf_web_socket:
dependency: transitive
description:
@@ -344,14 +365,21 @@ packages:
name: source_gen
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.9.10+4"
+ version: "1.2.2"
+ source_helper:
+ dependency: transitive
+ description:
+ name: source_helper
+ url: "https://pub.flutter-io.cn"
+ source: hosted
+ version: "1.3.2"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.8.1"
+ version: "1.8.2"
stack_trace:
dependency: transitive
description:
@@ -393,7 +421,7 @@ packages:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
- version: "0.4.3"
+ version: "0.4.9"
timing:
dependency: transitive
description:
@@ -407,35 +435,35 @@ packages:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.3.0"
+ version: "1.3.1"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.1.1"
+ version: "2.1.2"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.flutter-io.cn"
source: hosted
- version: "1.0.0"
+ version: "1.0.1"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.flutter-io.cn"
source: hosted
- version: "2.0.0"
+ version: "2.2.0"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.flutter-io.cn"
source: hosted
- version: "3.1.0"
+ version: "3.1.1"
sdks:
- dart: ">=2.14.0 <3.0.0"
- flutter: ">=1.20.0"
+ dart: ">=2.17.0 <3.0.0"
+ flutter: ">=2.5.0"
diff --git a/pubspec.yaml b/pubspec.yaml
index 11dfddc..db14fc0 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,24 +1,24 @@
name: weibo_kit
description: A powerful Flutter plugin allowing developers to auth/share with natvie Android & iOS Weibo SDKs.
-version: 3.1.0
+version: 4.0.0
# author: v7lin
-homepage: https://github.com/rxreader/weibo_kit.git
+homepage: https://github.com/RxReader/weibo_kit.git
environment:
- sdk: ">=2.12.0 <3.0.0"
- flutter: ">=1.20.0"
+ sdk: ">=2.17.0 <3.0.0"
+ flutter: ">=2.5.0"
dependencies:
flutter:
sdk: flutter
+ plugin_platform_interface: ^2.0.2
- json_annotation: ^4.0.0
+ json_annotation: ^4.5.0
dev_dependencies:
flutter_test:
sdk: flutter
-
- pedantic:
+ flutter_lints: ^2.0.0
build_runner:
json_serializable:
@@ -26,11 +26,17 @@ dev_dependencies:
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
-# The following section is specific to Flutter.
+# The following section is specific to Flutter packages.
flutter:
# This section identifies this Flutter project as a plugin project.
- # The 'pluginClass' and Android 'package' identifiers should not ordinarily
- # be modified. They are used by the tooling to maintain consistency when
+ # The 'pluginClass' specifies the class (in Java, Kotlin, Swift, Objective-C, etc.)
+ # which should be registered in the plugin registry. This is required for
+ # using method channels.
+ # The Android 'package' specifies package in which the registered class is.
+ # This is required for using method channels on Android.
+ # The 'ffiPlugin' specifies that native code should be built and bundled.
+ # This is required for using `dart:ffi`.
+ # All these are used by the tooling to maintain consistency when
# adding or updating assets for this project.
plugin:
platforms:
@@ -49,7 +55,7 @@ flutter:
# https://flutter.dev/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
- # https://flutter.dev/assets-and-images/#resolution-aware.
+ # https://flutter.dev/assets-and-images/#resolution-aware
# To add custom fonts to your plugin package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
diff --git a/test/weibo_kit_method_channel_test.dart b/test/weibo_kit_method_channel_test.dart
new file mode 100644
index 0000000..10d9bc2
--- /dev/null
+++ b/test/weibo_kit_method_channel_test.dart
@@ -0,0 +1,27 @@
+import 'package:flutter/services.dart';
+import 'package:flutter_test/flutter_test.dart';
+import 'package:weibo_kit/src/weibo_kit_method_channel.dart';
+
+void main() {
+ final MethodChannelWeiboKit platform = MethodChannelWeiboKit();
+ const MethodChannel channel = MethodChannel('v7lin.github.io/weibo_kit');
+
+ TestWidgetsFlutterBinding.ensureInitialized();
+
+ setUp(() {
+ channel.setMockMethodCallHandler((MethodCall methodCall) async {
+ switch (methodCall.method) {
+ case 'isInstalled':
+ return true;
+ }
+ });
+ });
+
+ tearDown(() {
+ channel.setMockMethodCallHandler(null);
+ });
+
+ test('isInstalled', () async {
+ expect(await platform.isInstalled(), true);
+ });
+}
diff --git a/test/weibo_kit_test.dart b/test/weibo_kit_test.dart
index 36b149d..56ef90a 100644
--- a/test/weibo_kit_test.dart
+++ b/test/weibo_kit_test.dart
@@ -1,81 +1,83 @@
-import 'dart:async';
-import 'dart:convert';
+import 'dart:typed_data';
-import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
-import 'package:pedantic/pedantic.dart';
-import 'package:weibo_kit/weibo_kit.dart';
+import 'package:plugin_platform_interface/plugin_platform_interface.dart';
+import 'package:weibo_kit/src/model/resp.dart';
+import 'package:weibo_kit/src/weibo.dart';
+import 'package:weibo_kit/src/weibo_constant.dart';
+import 'package:weibo_kit/src/weibo_kit_method_channel.dart';
+import 'package:weibo_kit/src/weibo_kit_platform_interface.dart';
+
+class MockWeiboKitPlatform
+ with MockPlatformInterfaceMixin
+ implements WeiboKitPlatform {
+ @override
+ Future registerApp({
+ required String appKey,
+ required String? universalLink,
+ required List scope,
+ String redirectUrl = WeiboRegister.DEFAULT_REDIRECTURL,
+ }) {
+ throw UnimplementedError();
+ }
+
+ @override
+ Stream respStream() {
+ throw UnimplementedError();
+ }
+
+ @override
+ Future isInstalled() {
+ throw UnimplementedError();
+ }
+
+ @override
+ Future auth({
+ required String appKey,
+ required List scope,
+ String redirectUrl = WeiboRegister.DEFAULT_REDIRECTURL,
+ }) {
+ throw UnimplementedError();
+ }
+
+ @override
+ Future shareText({
+ required String text,
+ }) {
+ throw UnimplementedError();
+ }
+
+ @override
+ Future shareImage({
+ String? text,
+ Uint8List? imageData,
+ Uri? imageUri,
+ }) {
+ throw UnimplementedError();
+ }
+
+ @override
+ Future shareWebpage({
+ required String title,
+ required String description,
+ required Uint8List thumbData,
+ required String webpageUrl,
+ }) {
+ throw UnimplementedError();
+ }
+}
void main() {
- TestWidgetsFlutterBinding.ensureInitialized();
+ final WeiboKitPlatform initialPlatform = WeiboKitPlatform.instance;
- const MethodChannel channel = MethodChannel('v7lin.github.io/weibo_kit');
-
- setUp(() {
- channel.setMockMethodCallHandler((MethodCall call) async {
- switch (call.method) {
- case 'registerApp':
- return null;
- case 'isInstalled':
- return true;
- case 'auth':
- unawaited(channel.binaryMessenger.handlePlatformMessage(
- channel.name,
- channel.codec.encodeMethodCall(
- MethodCall('onAuthResp', json.decode('{"errorCode":-1}'))),
- (ByteData? data) {
- // mock success
- },
- ));
- return null;
- case 'shareText':
- case 'shareImage':
- case 'shareWebpage':
- unawaited(channel.binaryMessenger.handlePlatformMessage(
- channel.name,
- channel.codec.encodeMethodCall(
- MethodCall('onShareMsgResp', json.decode('{"errorCode":-1}'))),
- (ByteData? data) {
- // mock success
- },
- ));
- return null;
- }
- throw PlatformException(code: '0', message: '想啥呢,升级插件不想升级Mock?');
- });
- });
-
- tearDown(() {
- channel.setMockMethodCallHandler(null);
+ test('$MethodChannelWeiboKit is the default instance', () {
+ expect(initialPlatform, isInstanceOf());
});
test('isInstalled', () async {
+ final MockWeiboKitPlatform fakePlatform = MockWeiboKitPlatform();
+ WeiboKitPlatform.instance = fakePlatform;
+
expect(await Weibo.instance.isInstalled(), true);
});
-
- test('auth', () async {
- final StreamSubscription subs =
- Weibo.instance.respStream().listen((BaseResp resp) {
- expect(resp.runtimeType, AuthResp);
- expect(resp.errorCode, BaseResp.USERCANCEL);
- });
- await Weibo.instance.auth(
- appKey: 'your weibo app key',
- scope: [WeiboScope.ALL],
- );
- await Future.delayed(const Duration(seconds: 1));
- await subs.cancel();
- });
-
- test('share', () async {
- final StreamSubscription sub =
- Weibo.instance.respStream().listen((BaseResp resp) {
- expect(resp.runtimeType, ShareMsgResp);
- expect(resp.errorCode, BaseResp.USERCANCEL);
- });
- await Weibo.instance.shareText(
- text: 'share text',
- );
- await sub.cancel();
- });
}