flutter-样式

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
      appBar: AppBar(title: Text("flutter demo")),
      body: HomeContent(),
    ));
  }
}

class HomeContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Center(
      child: Container(
        child: Text(
          "我是文本",
          textAlign: TextAlign.center, // 文本居中
          overflow: TextOverflow.ellipsis, // 超出显示 ...
          maxLines: 2, // 显示超过 2行自动隐藏
          textScaleFactor: 1.8,
          style: TextStyle(
            fontSize: 16.0, // 设置字体大小
            // fontStyle: FontStyle.italic,    // 字体斜体
            color: Colors.red, // 字体颜色
            // decoration: TextDecoration.lineThrough, // 删除线
            // decorationColor: Colors.white,  // 删除线的颜色
            // decorationStyle: TextDecorationStyle.dashed,   // 删除线是 虚线
            // letterSpacing: 5.0,  // 字体间距
            // fontWeight: FontWeight.w800 // 字体大小
          ),
        ),
        height: 300.0, // 盒子高度
        width: 300.0, // 盒子宽度
        decoration: BoxDecoration(
            // 设置背景颜色
            color: Colors.black45,
            // 设置圆角
            borderRadius: BorderRadius.all(
                // Radius.circular(150) // 圆角
                Radius.circular(10)),
            // 设置边框颜色和 宽度
            border: Border.all(color: Colors.blue, width: 2.0)),
        // padding: EdgeInsets.all(10),
        // padding: EdgeInsets.fromLTRB(10, 30, 5, 0),
        // margin: EdgeInsets.fromLTRB(10, 30, 5, 0),
        // transform: Matrix4.translationValues(100, 0, 0),  // 位移
        // transform: Matrix4.rotationZ(-0.3) // 旋转
        // transform: Matrix4.diagonal3Values(1.2, 1, 1),

        // alignment: Alignment.bottomLeft, // 文字居底部左侧
        // alignment: Alignment.topRight, // 文字顶部右侧
      ),
    );
  }
}
posted @ 2021-07-31 20:05  13522679763-任国强  阅读(55)  评论(0)    收藏  举报