flutterでwidgetを画像化する際に背景を透過させる
現在flutterで画像編集アプリのようなものを作成しており、写真の上にStackでwidgetを重ねて表示しています。その重ねているwidgetのみを保存したく、かつ、その保存した画像が背景透過をできるようにしたいのですが、背景が白になってしまい、透過できません。
コード
InteractiveViewer(
child: Container(
width: MediaQuery.of(context).size.width,
height: 400,
child: WidgetsToImage(
controller: imageController,
child: Stack(
children: [
Image.network(
widget.s3,
width: MediaQuery.of(context).size.width,
),
_bubble1(),
_bubble2(),
_bubble3(),
_text1(),
_text2(),
_text3(),
],
),
)),
),
ここで、以下のようにコードを変更しました。
InteractiveViewer(
child: Container(
width: MediaQuery.of(context).size.width,
height: 400,
child: WidgetsToImage(
controller: imageController,
child: Stack(
children: [
_bubble1(),
_bubble2(),
_bubble3(),
_text1(),
_text2(),
_text3(),
],
),
)),
),
そして画像を保存すると、以下のような画像が.jpegで保存されて、透過情報を持っていせんでした。
flutterでこのような層を保存するにはどのようにすれば良いか教えていただけると幸いです。
0 likes
