小编Tiz*_*Dev的帖子

如何在ListView.builder的末尾添加一个元素以移回顶部?

如何在 a 的末尾添加一个元素Listview.builder,允许用户单击它并让他返回列表顶部?

flutter

4
推荐指数
1
解决办法
4820
查看次数

如何添加Image.file作为圆形头像的背景图片

在我的应用程序中,用户无法拾取图片并将其放入应用程序中,而不是我需要放置的图像是圆形头像的背景图像。我通过 package: image_picker 构建了一个屏幕,可以通过手机拾取图像,但因为我无法将图像放入圆形头像的背景中。这是我的代码:

File _image;
  final picker = ImagePicker();

  Future getImage() async {
    final pickedFile = await picker.getImage(source: ImageSource.camera);


    setState(() {
      if (pickedFile != null) {
        _image = File(pickedFile.path);
      } else {
        print('No image selected.');
      }
    });
  }
Run Code Online (Sandbox Code Playgroud)

和构建方法:

_image == null ? CircleAvatar(
                  radius: 60,
                  backgroundColor: Colors.yellow,
                  child: Text(IfUserProfile.firstname[0],),
                ): CircleAvatar(
                  radius: 60,
                backgroundColor: Colors.yellow,
                child: Image.file(_image),),
                SizedBox(
                  height: 4,
                ),
                GestureDetector(
                  onTap: getImage,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.center,
                      children: [Icon(Icons.add_a_photo,color: Colors.white,size: 18,),
                      Text('   Aggiungi un immagine profilo',style: TextStyle(fontSize: …
Run Code Online (Sandbox Code Playgroud)

flutter

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

标签 统计

flutter ×2