[英]how to make selected text underline in flutter
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
class HomePage extends StatefulWidget {
@override
_HomePage createState() => _HomePage();
}
class _HomePage extends State<HomePage> {
var text = 'test';
bool isSelect= false;
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Column(
children: [
GestureDetector(
onTap: (){
if(isSelect == false){
setState(() {
isSelect= true;
});
}else{
setState(() {
isSelect = false;
});
}
},
child: isSelect == false ? Center(child: Text(text,style: const TextStyle(fontSize: 50,fontWeight: FontWeight.bold),)): isSelect == true ? Center(child: Text(text,style: const TextStyle(decoration: TextDecoration.underline,fontSize: 50,fontWeight: FontWeight.bold,color: Colors.red),)):Text('')),
],
),
),
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.