Flutter6:Text
程序员文章站
2022-05-30 17:32:52
...
ex:
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:url_launcher/url_launcher.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// debugPaintSizeEnable = true;
@override
Widget build(BuildContext context) {
// debugPaintSizeEnabled = true;
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Text ex'),
),
body: Center(
child: Column(
children: <Widget>[
Text('Be a master, be a useful man from HUST!',
maxLines:1,
overflow: TextOverflow.ellipsis,
softWrap: true,//自动换行
style: TextStyle(
fontSize: 30.0,
decoration: TextDecoration.lineThrough,//删除画线
decorationStyle: TextDecorationStyle.wavy),
),
SizedBox(//间隔
height: 30.0,
),
RichText(text: TextSpan(//富文本
text: 'Be a master',
style: TextStyle(color: Color(0xffff0000), fontSize: 20.0),
children: <TextSpan>[
TextSpan(
text:'I am a master',
),
TextSpan(
text: 'HUST',
style: TextStyle(color: Color(0xff0000ff)),
recognizer: TapGestureRecognizer()
..onTap = () async {//点击事件
String url = 'https://www.hust.edu.cn/';
if (await canLaunch(url)){
await launch(url);//加载网页
}else{
throw 'error: $url';
}
}),
],
),
),
],
),
),
),
);
}
}
效果
推荐阅读
-
SQLServer 全文检索(full-text)语法
-
Sublime Text shift+ctrl妙用以及Sublime Text快捷组合键大全
-
sublime text3的package control安装失效的解决方法(插件安装包管理)
-
java sqlserver text 类型字段读取方法
-
sublime text2小技巧、帮助您写代码是越写越快
-
windows中sublime text2常用快捷键
-
IE下实现类似CSS3 text-shadow文字阴影的几种方法
-
MSSQL报错:参数数据类型 text 对于 replace 函数的参数 1 无效的解决办法
-
详解小程序rich-text对富文本支持方案
-
sublime text3怎么设置代码字体的大小?