2017-12-17 18 views
-1

透明な前景でない半透明の背景を示すこのフラッターウィジェットを作成しました。私はそれを行うためにスタックを使用します。残念なことに、私はコンテンツをバックグラウンドでレイアウトする必要があります。そうしないと、コンテンツのサイズが正しくないためです。レイアウトを2回行わずに、スタックの背景にフォアグラウンドのサイズを知らせる方法はありますか?半透明の背景と透明でない前景を持つウィジェットを作成するにはどうすればいいですか

https://gist.github.com/anonymous/1f1189e994fd1c55a050fbbad7a97343

答えて

2

私はあなたがそれを達成するために、スタックを必要としないだろうとします。ウィジェットの装飾を指定することで、背景を直接指定することができます。

例:

new Container(
      decoration: new BoxDecoration(
       border: new Border.all(width: borderWidth ,color: Colors.transparent), //color is transparent so that it does not blend with the actual color specified 
       borderRadius: const BorderRadius.all(const Radius.circular(30.0)), 
       color: new Color.fromRGBO(255, 0, 0, 0.5) // Specifies the background color and the opacity 
      ), 
      child: _content, 
     ) 

助けを願っています!

+0

Thx、これは非常にうまくいった! –

関連する問題