flutter Material风格-按钮

1.MaterialButton

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: MaterialButton(
            color: Colors.blue,
            textColor: Colors.white,
            child: Text('按钮'),
            onPressed: () {},
          ))),
    );

2.RaisedButton

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: RaisedButton(
            color: Colors.blue,
            textColor: Colors.white,
            child: Text('按钮'),
            onPressed: () {},
          ))),
    );

 

3.FlatButton 

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: FlatButton(
            color: Colors.blue,
            textColor: Colors.white,
            child: Text('按钮'),
            onPressed: () {},
          ))),
    );

 

4.IconButton

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: IconButton(
            color: Colors.green,
            icon: Icon(Icons.pets),
            //长按提示
            tooltip: "ok",
            onPressed: () {},
          ))),
    );

5.FloatingActionButton

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: FloatingActionButton(
            backgroundColor: Colors.red,
            child: Icon(Icons.arrow_upward),
            onPressed: () {},
          ))),
    );

 

6.OutlineButton

 MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: OutlineButton(
            child: Icon(Icons.pets),
            onPressed: () {},
          ))),
    );

 

7.DropdownButton

下拉按钮

MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: Text("测试"),
          ),
          body: Center(
              child: DropdownButton(
            value: value,
            icon: Icon(Icons.arrow_upward),
            onChanged: (String newValue) {
              setState(() {
                value = newValue;
              });
            },
            items: <String>['a', 'b', 'c', 'd']
                .map<DropdownMenuItem<String>>((String value) {
              return DropdownMenuItem<String>(
                value: value,
                child: Text(value),
              );
            }).toList(),
          ))),
    );

 

 

8.PopupMenuButton

 

posted @ 2020-06-23 14:52  富坚老贼  阅读(459)  评论(0编辑  收藏  举报