这是我的Flutter启动代码
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
// ignore: library_private_types_in_public_api
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final formkey = GlobalKey<FormState>();
File? inchargePic;
File? support1Pic;
File? support2Pic;
File? kmPic;
bool _isExpanded = false;
TextEditingController totalKMController = TextEditingController();
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
return Scaffold(
appBar: AppBar(
centerTitle: true,
title: Text(widget.title),
),
body: SizedBox(
height: size.height,
width: size.width,
child: SingleChildScrollView(
padding: const EdgeInsets.all(20),
physics: const BouncingScrollPhysics(),
child: Column(
children: [
inchargeName(),
space(),
inchargeImage(),
space(),
addSupport(),
space(),
kmAndImagePicWidget(size.height, size.width),
space(),
elevatedButton(),
],
),
),
),
);
}
这是我调用按下顶部添加小工具的函数的地方
SizedBox addSupport() {
return SizedBox(
child: SingleChildScrollView(
child: Column(
children: [
ElevatedButton(
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10))),
onPressed: () {
setState(() {
_isExpanded = !_isExpanded;
});
},
child: const Text("Add Support"),
),
space(),
if (_isExpanded) support1()
],
),
),
);
}
确切的问题是,我可以在按下时添加support1,但我还需要已添加但不知道如何调用的support2小部件
2条答案
按热度按时间3htmauhk1#
9fkzdhlc2#