step 1
set variable in class
String myflight;
bool Flight = false;
Implement in Route in onpress()
onPressed: () {
setState(() async {
_controllerCategory.text =
widget.Category;
String myflights=
myflight.toString();
;
widget._isLoading = true;
_isallLoading == true
? _storemytrip(
myflights,
);
});
}
});
}
Implement cheakbox
Widget _buildCheckboxFlight() => ListTile(
title: Text(
'Flight',
style: TextStyle(
color: Colors.black54,
fontSize: 16,
),
),
trailing: Checkbox(
value: Flight,
onChanged: (bool? value) {
setState(() {
this.Flight = value!;
if(Flight==true){
myflight=1.toString();
print("myflight");
print(myflight);
}
else{
myflight=0.toString();
print(" else myflight");
print(myflight);
}
print(Flight);
print(this.Flight);
});
},
),
);
Output

And if want to know to ternary operator in flutter.If you want more clarity output please click here.

I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with Cotocus and continue to contribute to multiple platforms where I share insights across different domains:
-
DevOps School – Tech blogs and tutorials
-
Holiday Landmark – Travel stories and guides
-
Stocks Mantra – Stock market strategies and tips
-
My Medic Plus – Health and fitness guidance
-
TrueReviewNow – Honest product reviews
-
Wizbrand – SEO and digital tools for businesses
I’m also exploring the fascinating world of Quantum Computing.