This is my starting code for 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(),
],
),
),
),
);
}
This is where i called the function onpressed top add widgets.
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()
],
),
),
);
}
The exact problem is i can add support1 when pressed but i also want support2 widget which i have added but not know how how to call it.