小编jan*_*oth的帖子

在 Instagram 提要中分享意图问题

我有一个从 url 共享图像的应用程序。上次 android 更新,当我想在 instagram 提要中共享图像时,我收到了来自 instagram 的消息“无法加载图像”。

但我可以分享图片故事、直接消息和任何地方......我只有 instagram 提要有这个问题。

public void onShareItemOreo() {
    // Get access to bitmap image from view
    imageView = (ImageView) findViewById(R.id.thumbnail);

    // Get access to the URI for the bitmap
    Uri bmpUri = prepareShareIntent(imageView);
    if (bmpUri != null) {

        //outfile is the path of the image stored in the gallery
        // Construct a ShareIntent with link to image
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
        shareIntent.setData(bmpUri);
        shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        shareIntent.setType("image/*");
        shareIntent.putExtra(Intent.EXTRA_TEXT,marketLink);
        // Launch sharing …
Run Code Online (Sandbox Code Playgroud)

android share image android-intent

9
推荐指数
2
解决办法
2430
查看次数

flutter - Future<bool> 转换为 bool

我有一个未来的 bool 方法,我想使用这个方法 IconButton 颜色。如果我使用下面的代码,我会在设备屏幕上看到一条错误消息,类型“Future”不是类型转换中“bool”类型的子类型。

Future<bool> ifExistInFavoriteList(String url) async {
Run Code Online (Sandbox Code Playgroud)

布尔 ifExists = false;

SharedPreferences首选项=等待SharedPreferences.getInstance(); 列出我的 = (prefs.getStringList('myFavoriteList') ?? List());

my.contains(url) ?ifExists = true : ifExists = false;

如果存在则返回;

}

  bool _isLiked() {
bool a = false;
a = ifExistInFavoriteList(widget.imageUrl) as bool;

return a;
Run Code Online (Sandbox Code Playgroud)

} }

Expanded(
                      child: IconButton(
                        color:
                            _isLiked() ? Colors.deepPurple : Colors.green, 
                        icon: Icon(Icons.category),
                        onPressed: () {
                          //TO-DO
                        },
                      ),
                    )
Run Code Online (Sandbox Code Playgroud)

boolean dart flutter

8
推荐指数
2
解决办法
9497
查看次数

在 main.dart 中使用 FutureBuilder

下面的代码总是显示 OnboardingScreen 一段时间(可能是几毫秒),然后显示 MyHomePage。我相信你们都明白我想做什么。我正在使用 FutureBuilder 来检查 getString 方法是否有数据。我有什么错?或者还有其他最好的方法吗?

saveString() async {
  final prefs = await SharedPreferences.getInstance();
  prefs.setString('firstOpen', '1');
}
Run Code Online (Sandbox Code Playgroud)

getString() 方法始终返回字符串。

getString() async {
  final prefs = await SharedPreferences.getInstance();
  String txt = prefs.getString('firstOpen');
  return txt;
}
Run Code Online (Sandbox Code Playgroud)

主程序.dart

home: new FutureBuilder(
            future: getString(),
            builder: (context, snapshot) {
              if (snapshot.hasData) {
                return MyHomePage();
              } else {
                return OnboardingScreen();
              }
            })
Run Code Online (Sandbox Code Playgroud)

sharedpreferences flutter

2
推荐指数
1
解决办法
4573
查看次数

Flutter - 数据更改时 getx 控制器未更新

我正在开发一个应用程序,它有一个五页的底部导航栏。我使用 getx。在第一页,我列出了数据。我的问题是,当我从数据库手动更改数据(底部导航栏中的第一页)然后我越过页面时,回到第一页我看不到更改。

控制器;

class ExploreController extends GetxController {
  var isLoading = true.obs;
  var articleList = List<ExploreModel>().obs;

  @override
  void onInit() {
    fetchArticles();
    super.onInit();
  }

  void fetchArticles() async {
    try {
      isLoading(true);
      var articles = await ApiService.fetchArticles();
      if (articles != null) {
        //articleList.clear();
        articleList.assignAll(articles);
      }
    } finally {
      isLoading(false);
    }
    update();
  }
}
Run Code Online (Sandbox Code Playgroud)

和我的用户界面;

body: SafeArea(
        child: Column(
        children: <Widget>[
          Header(),
          Expanded(
            child: GetX<ExploreController>(builder: (exploreController) {
              if (exploreController.isLoading.value) {
                return Center(
                  child: SpinKitChasingDots(
                      color: Colors.deepPurple[600], size: 40),
                );
              }
              return ListView.separated(
                padding: …
Run Code Online (Sandbox Code Playgroud)

controller flutter getx

2
推荐指数
3
解决办法
2万
查看次数