CaiJingLong / flutter_photo

Pick image/video from album by flutter. Support ios and android. UI by flutter, no native.
Apache License 2.0
301 stars 132 forks source link

[Need Help] UI会无限跳转不停的打开选择图片的UI #114

Closed tiantianaixuexi closed 4 years ago

tiantianaixuexi commented 4 years ago

`// Future<List> loadAssets(BuildContext context) async {

  List<AssetEntity> entity = await PhotoPicker.pickAsset(
  context:context,
  pickType: PickType.onlyImage,
  loadingDelegate: this,
  badgeDelegate: const DurationBadgeDelegate(),
  );

  for(int i =0;i<entity.length;i++){
    images.add(await entity[i].file);
  }
  return images;

}

@override Widget build(BuildContext context) { return Scaffold( body: FutureBuilder( future: loadAssets(context), builder: (BuildContext context, AsyncSnapshot<List> snapshot) { if (snapshot.hasData) { return Container( child: Column( children: [ Text( "发帖子", style: TextStyle(fontSize: ScreenUtil().getSp(30)), ), TextField( maxLines: 10, controller: widget.postContentController, decoration: const InputDecoration( border: InputBorder.none, //去掉输入框的下滑线 hintText: "请输入要发送的文本~,不能为空", fillColor: Color(0XFFFFF8F4), filled: true,
), onChanged: (str) { PostProperty_Future().contentString = str; }, ), Expanded( child: buildGridView(snapshot.data), ), Divider( color: Colors.red, ), PostDownPage() ], ), ); } else { return Text('fuck'); } })); }`

CaiJingLong commented 4 years ago

See example. Selecting images is usually triggered within a button clicked. It should not be used with FutureBuilder