flutter3重构按钮
import 'package:flutter/material.dart'; class MyButton extends StatelessWidget { const MyButton({super.key}); @override Widget build(BuildContext context) { //return const Placeholder(); //具体内容开始 return Column( children: [ //const TextField(), //文本框输入开始 const TextField( decoration: InputDecoration( border: OutlineInputBorder(), hintText: "请输入查询地址。"), ), //文本框输入结束 // buildMaterialButton() //重构按钮 ], );//注意最后一个是冒号 //具体内容结束 } MaterialButton buildMaterialButton() { return MaterialButton( // textColor: Colors.white, color: Colors.green, shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(30.0)), onPressed: () { print('按钮被点击'); }, child: const Text('位置'), ); } }