fake_weibo 0.2.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 81

fake_weibo #

Build Status Codecov GitHub Tag Pub Package License

flutter版新浪微博SDK

fake 系列 libraries #

dart/flutter 私服 #

docs #

android #

# 不需要做任何额外接入工作
# 混淆已打入 Library,随 Library 引用,自动添加到 apk 打包混淆

ios #

iOS 9.0
在Xcode中,选择你的工程设置项,选中“TARGETS”一栏,在“info”标签栏的“URL type“添加“URL scheme”为你所注册的应用程序id

URL Types
weibosdk: identifier=com.weibo schemes=wb${appKey}
iOS 9系统策略更新,限制了http协议的访问,此外应用需要在“Info.plist”中将要使用的URL Schemes列为白名单,才可正常检查其他应用是否安装。
<key>LSApplicationQueriesSchemes</key>
<array>
    <string>sinaweibo</string>
    <string>sinaweibohd</string>
    <string>weibosdk</string>
    <string>weibosdk2.5</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
    <key>NSExceptionDomains</key>
    <dict>
        <key>sina.com.cn</key>
        <dict>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSThirdPartyExceptionAllowsInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionMinimumTLSVersion</key>
            <string>TLSv1.0</string>
            <key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
            <false/>
        </dict>
    </dict>
</dict>

flutter #

  • snapshot
dependencies:
  fake_weibo:
    git:
      url: https://github.com/v7lin/fake_weibo.git
  • release
dependencies:
  fake_weibo: ^${latestTag}
  • example

示例

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.2.4 - 2019.9.26 #

  • 降级Android SDK
  • 升级iOS SDK

0.2.3 - 2019.8.1 #

  • 升级Android SDK

0.2.2 - 2019.7.12 #

  • 简化

0.2.1 - 2019.5.29 #

  • 添加大图分享
  • 添加图文分享

0.2.0 - 2019.5.24 #

  • 优化
  • 自动化发布

0.1.0 - 2019.3.19 #

  • 规范 library 代码

0.0.1 - 2019.3.5 #

  • android/ios weibo

example/lib/main.dart

import 'dart:async';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:fake_weibo/fake_weibo.dart';

void main() {
  runZoned(() {
    runApp(MyApp());
  }, onError: (dynamic error, dynamic stack) {
    print(error);
    print(stack);
  });

  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
        const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _HomeState();
  }
}

class _HomeState extends State<Home> {
  static const String _WEIBO_APP_KEY = '3393861383';
  static const List<String> _WEIBO_SCOPE = <String>[
    WeiboScope.ALL,
  ];

  Weibo _weibo = Weibo()
    ..registerApp(
      appKey: _WEIBO_APP_KEY,
      scope: _WEIBO_SCOPE,
    );

  StreamSubscription<WeiboAuthResp> _auth;
  StreamSubscription<WeiboSdkResp> _share;

  WeiboAuthResp _authResp;

  @override
  void initState() {
    super.initState();
    _auth = _weibo.authResp().listen(_listenAuth);
    _share = _weibo.shareMsgResp().listen(_listenShareMsg);
  }

  void _listenAuth(WeiboAuthResp resp) {
    _authResp = resp;
    String content = 'auth: ${resp.errorCode}';
    _showTips('登录', content);
  }

  void _listenShareMsg(WeiboSdkResp resp) {
    String content = 'share: ${resp.errorCode}';
    _showTips('分享', content);
  }

  @override
  void dispose() {
    if (_auth != null) {
      _auth.cancel();
    }
    if (_share != null) {
      _share.cancel();
    }
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Fake Weibo Demo'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            title: const Text('环境检查'),
            onTap: () async {
              String content = 'weibo: ${await _weibo.isWeiboInstalled()}';
              _showTips('环境检查', content);
            },
          ),
          ListTile(
            title: const Text('登录'),
            onTap: () {
              _weibo.auth(
                appKey: _WEIBO_APP_KEY,
                scope: _WEIBO_SCOPE,
              );
            },
          ),
          ListTile(
            title: const Text('用户信息'),
            onTap: () async {
              if (_authResp != null &&
                  _authResp.errorCode == WeiboSdkResp.SUCCESS) {
                WeiboUserInfoResp userInfoResp = await _weibo.getUserInfo(
                  appkey: _WEIBO_APP_KEY,
                  userId: _authResp.userId,
                  accessToken: _authResp.accessToken,
                );
                if (userInfoResp != null &&
                    userInfoResp.errorCode == WeiboApiResp.ERROR_CODE_SUCCESS) {
                  _showTips('用户信息',
                      '${userInfoResp.screenName}\n${userInfoResp.description}\n${userInfoResp.location}\n${userInfoResp.profileImageUrl}');
                } else {
                  _showTips('用户信息',
                      '获取用户信息失败\n${userInfoResp.errorCode}:${userInfoResp.error}');
                }
              }
            },
          ),
          ListTile(
            title: const Text('文字分享'),
            onTap: () {
              _weibo.shareText(
                text: 'Share Text',
              );
            },
          ),
          ListTile(
            title: const Text('图片分享'),
            onTap: () async {
              AssetImage image = const AssetImage('images/icon/timg.jpeg');
              AssetBundleImageKey key =
                  await image.obtainKey(createLocalImageConfiguration(context));
              ByteData imageData = await key.bundle.load(key.name);
              await _weibo.shareImage(
                text: 'Share Text',
                imageData: imageData.buffer.asUint8List(),
              );
            },
          ),
          ListTile(
            title: const Text('网页分享'),
            onTap: () async {
              AssetImage image =
                  const AssetImage('images/icon/ic_launcher.png');
              AssetBundleImageKey key =
                  await image.obtainKey(createLocalImageConfiguration(context));
              ByteData thumbData = await key.bundle.load(key.name);
              await _weibo.shareWebpage(
                title: 'title',
                description: 'share webpage',
                thumbData: thumbData.buffer.asUint8List(),
                webpageUrl: 'https://www.baidu.com',
              );
            },
          ),
        ],
      ),
    );
  }

  void _showTips(String title, String content) {
    showDialog(
      context: context,
      builder: (BuildContext context) {
        return AlertDialog(
          title: Text(title),
          content: Text(content),
        );
      },
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  fake_weibo: ^0.2.4

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:fake_weibo/fake_weibo.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
69
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
81
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.9+1
  • Flutter: 1.17.3

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:fake_weibo/fake_weibo.dart]

Package does not support Flutter platform macos

Because of import path [package:fake_weibo/fake_weibo.dart]

Package does not support Flutter platform web

Because of import path [package:fake_weibo/fake_weibo.dart]

Package does not support Flutter platform windows

Because of import path [package:fake_weibo/fake_weibo.dart]

Package not compatible with SDK dart

because of import path [fake_weibo]

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
jaguar_serializer ^2.2.12 2.2.12
meta ^1.1.6 1.1.8 1.2.0
Transitive dependencies
collection 1.14.12 1.14.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
build_runner any
flutter_test
jaguar_serializer_cli any
pedantic >=1.4.0 <3.0.0