美文网首页
6.Flutter按钮事件

6.Flutter按钮事件

作者: 李响2022 | 来源:发表于2020-03-05 01:10 被阅读0次
import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
      home: Scaffold(body: HomePage())
    ));
}

class HomePage extends StatefulWidget {
  HomePage({Key key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int num = 0;
  @override
  Widget build(BuildContext context) {
    return Column(children: <Widget>[
      SizedBox(height:100),
      Chip(label: Text('${this.num}')),
      SizedBox(height:40),
      RaisedButton(child: Text('按钮'),onPressed: (){
        setState(() {
          this.num ++;
        });
      })
    ]);
  }
}

相关文章

网友评论

      本文标题:6.Flutter按钮事件

      本文链接:https://www.haomeiwen.com/subject/unxnlhtx.html