Amendment to original question. Can I pass something in to the SessionEntryInfo class that would allow me to add some buttons to the original screen from page4?
I have a class page as seen below. After the user makes a selection in the dropdownmenu, I'd like to display some other buttons on the same screen. In order to keep the class short, I was trying to put the other buttons to be displayed in another class, but I'm not sure this is allowed. From what I understand I should only have 1 layout per page. Can someone suggest a way to do this please? Thanks
const Page2({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
displayLarge: const TextStyle(
fontSize: 84, fontWeight: FontWeight.bold))),
home: Scaffold(
body: Center(
child: Column(children: <Widget>[
SizedBox(height: 50),
DropdownMenu(
width: 200,
textStyle: TextStyle(fontSize: 14),
label: const Text('Session Options'),
inputDecorationTheme: InputDecorationTheme(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 5),
constraints: BoxConstraints.tight(const Size.fromHeight(40)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
)),
onSelected: (value) {
debugPrint(value);
if (value == 'Create Session') {
debugPrint("Calling SessionEntryInfo");
SessionEntryInfo();
}
},
dropdownMenuEntries: <DropdownMenuEntry<String>>[
DropdownMenuEntry(
value: 'Create Session', label: 'Create Session'),
DropdownMenuEntry(value: 'Edit Session', label: 'Edit Session'),
DropdownMenuEntry(
value: 'Delete Session', label: 'Delete Session'),
]),
]))
)
);
}
}```
Amendment to original question. Can I pass something in to the SessionEntryInfo class that would allow me to add some buttons to the original screen from page4?
I have a class page as seen below. After the user makes a selection in the dropdownmenu, I'd like to display some other buttons on the same screen. In order to keep the class short, I was trying to put the other buttons to be displayed in another class, but I'm not sure this is allowed. From what I understand I should only have 1 layout per page. Can someone suggest a way to do this please? Thanks
const Page2({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
displayLarge: const TextStyle(
fontSize: 84, fontWeight: FontWeight.bold))),
home: Scaffold(
body: Center(
child: Column(children: <Widget>[
SizedBox(height: 50),
DropdownMenu(
width: 200,
textStyle: TextStyle(fontSize: 14),
label: const Text('Session Options'),
inputDecorationTheme: InputDecorationTheme(
isDense: true,
contentPadding: const EdgeInsets.symmetric(horizontal: 5),
constraints: BoxConstraints.tight(const Size.fromHeight(40)),
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(10),
)),
onSelected: (value) {
debugPrint(value);
if (value == 'Create Session') {
debugPrint("Calling SessionEntryInfo");
SessionEntryInfo();
}
},
dropdownMenuEntries: <DropdownMenuEntry<String>>[
DropdownMenuEntry(
value: 'Create Session', label: 'Create Session'),
DropdownMenuEntry(value: 'Edit Session', label: 'Edit Session'),
DropdownMenuEntry(
value: 'Delete Session', label: 'Delete Session'),
]),
]))
)
);
}
}```
Share
Improve this question
edited Jan 19 at 3:04
Chris
asked Jan 18 at 23:45
ChrisChris
53 bronze badges
1
- I don't see a long class as a bad sign. Methods that span more than one page, on the other hand, deserve rewrites. Same goes for anything needing more than ten indents. – Randal Schwartz Commented Jan 19 at 0:54
1 Answer
Reset to default 0It's quite common to create custom widgets in your Flutter application for common UI patterns.
For example, you could create a custom widget subclassing DropdownMenu
with all the logic you have here.