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('文本控件的使用'),),
body:HomeContent())
);
}
}
class HomeContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Center(
child: ZText('我的文本', Colors.red, 20, 1)
);
}
}
class ZText extends StatelessWidget {
final String str;
final Color color;
final double fontSize;
final double fontWeight;
ZText(this.str, this.color, this.fontSize, this.fontWeight);
@override
Widget build(BuildContext context) {
return Text(str,
style: TextStyle(
color: color,
fontSize: fontSize,
fontWeight: fontWeight == 1 ? FontWeight.w400 : FontWeight.w600)
);
}
}
4.Flutter封装Text
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
相关阅读更多精彩内容
- 一、目录结构介绍 需要注意以下几个文件夹,其他的暂时不用理会 文件夹作用androidandroid 平台相关代码...
- 一、Flutter Text 组件 二、Container 组件 说明 : border:Border.all()...
- demo 地址: https://github.com/iotjin/jh_flutter_demo 使用版本 包...