企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
## Container组件 容器组件,类似于div,用于布局 **decoration属性,背景颜色,边框颜色属性等** 1. child 2. height(double):高度 3. width:宽度 4. padding(EdgeInsets):内边距 fromLTRB(左,上,右,下) 5. margin:同padding 6. alignment(Alignment):child在容器中的对齐方式 7. transform(Matrix4):动画 translationValues rotationZ 9. decoration(BoxDecoration):背景颜色,边框,圆角 * color(Color, Colors):背景颜色, * border(Border):边框 同时设置四条边框 ~~~ Border.all( width: 2.0//边框宽度 color: Colors.pink//边框颜色, style: BorderStyle.solid//只支持实线 ) ~~~ 设置单边框 ~~~ border: Border( left: BorderSide( color: Colors.black, width:2.0, ), right: BorderSide( color: Colors.blue, width:4.0, ), ), ~~~ * borderRadius:圆角 写法一: ~~~ borderRadius: BorderRadius.all( Radius.circular(20), ), ~~~ 写法二: ~~~ BorderRadius.circular(40) ~~~ 不规则: 写法一 ~~~ borderRadius: BorderRadius.vertical( top: Radius.elliptical(50, 50), bottom: Radius.elliptical(50, 50) ), ~~~ 写法二: ~~~ borderRadius: BorderRadius.horizontal( left: Radius.elliptical(40, 40), right: Radius.elliptical(50, 50) ), ~~~ ~~~ import 'package:flutter/material.dart'; void main(){ runApp(MyApp()); } class MyApp extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Flutter demo'), ), body: HomeContent() ) ); } } class HomeContent extends StatelessWidget{ @override Widget build(BuildContext context) { // TODO: implement build return Center( child: Container( child: Text( '我是一个文本', textAlign: TextAlign.left, style: TextStyle( fontSize: 16.0, color: Color.fromRGBO(155, 111, 111, 1), fontWeight: FontWeight.w800, fontStyle: FontStyle.italic, decoration: TextDecoration.lineThrough,//文字装饰 decorationColor: Colors.white, decorationStyle: TextDecorationStyle.dashed, letterSpacing: 5.0 //字间距 ), overflow: TextOverflow.ellipsis, maxLines: 1, textScaleFactor: 1.5,//设置字体缩放 ), height: 300.0, width: 300.0, //decoration属性,背景颜色,边框颜色 宽度属性等 decoration: BoxDecoration( color: Colors.yellow, border: Border.all( color: Colors.blue, width: 4.0, ), borderRadius: BorderRadius.all( Radius.circular(20), ), ), //EdgeInsets.all(10.0), padding: EdgeInsets.fromLTRB(10, 30, 10, 10), // transform: Matrix4.translationValues(10.0, 10.0, 0), // transform: Matrix4.rotationZ(-0.3), alignment: Alignment.bottomRight,//元素显示位置 ), ); } } ~~~