【发布时间】:2019-09-12 15:42:35
【问题描述】:
我是 Flutter 的新手,我正在尝试一个简单的功能 ..
我有一个带有文本和凸起按钮的页面我想每次按下按钮时将文本大小增加 1.0..
我已经尝试过了,但它不起作用..
class _StoryDetailsState extends State<StoryDetails> {
@override
Widget build(BuildContext context) {
var textSize = 10.0;
return Scaffold(
backgroundColor: Color(0xffEA3A82),
appBar: AppBar(
elevation: 0.0,
backgroundColor: Color(0xffEA3A82),
title: Text(widget.story_title),
)
,body: SingleChildScrollView(
child: Column(
children: <Widget>[
Align(
alignment: Alignment.topLeft
,child: Image.network(widget.story_detail_pic , width: double.infinity,)
),
RaisedButton(
child: Text('enlarge text'),
onPressed: (){
setState(() {
textSize = textSize + 1.0;
print(textSize);
});
},
),
Padding(
padding: const EdgeInsets.all(10.0),
child: ClipRRect(borderRadius: BorderRadius.circular(10)
,child: Container(color: Colors.white.withOpacity(0.6) ,child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(widget.story , style: TextStyle(fontSize: textSize),),
))),
)
],
),
),
);
}
}
【问题讨论】: