线性渐变色

class LayoutDemoextends StatelessWidget {

@override

  Widgetbuild(BuildContext context) {

return new Scaffold(

appBar:new AppBar(

title:new Text('LinearGradient线性渐变效果'),

      ),

      body:new Center(

child:new DecoratedBox(

decoration:new BoxDecoration(

gradient:new LinearGradient(

begin:const FractionalOffset(0.5, 0.0),//起始偏移量

              end:const FractionalOffset(1.0, 1.0),//终止偏移量

//渐变颜色数据集

              colors: [

Colors.red,

                Colors.green,

                Colors.blue,

                Colors.grey,

              ],

            ),

          ),

          child:new Container(

width:280.0,

            height:280.0,

            child:new Center(

child:Text(

'LinearGradient线性渐变效果',

                style:TextStyle(

color: Colors.black,

                  fontSize:28.0,

                ),

              ),

            ),

          ),

        ),

      ),

    );

  }

}

猜你喜欢

转载自blog.csdn.net/weixin_34189116/article/details/90866686