If you want to add item in Settings, go to Project_HOME > lib > hooks_v2.dart
. Look for the getSettingsItemHook()
method.
static getSettingsItemHook(){
SettingsHook settingsHook = (BuildContext context){
List<dynamic> settingsItemHookList = [
// Add menu item map here
];
return settingsItemHookList;
};
}
There are two types of items that you can add to Settings
:
- Single Settings Menu item.
- Settings Menu Section with Menu items.
Steps to Add Single Settings Menu item:
-
Copy and paste the sample code of singleSettingsMenuItem.
Widget singleSettingsMenuItem = genericWidgetRow( iconData: , text: , onTap: (){ // Some Function() }, removeDecoration: , padding: , sectionType: "preferences", ); Map<String, dynamic> singleSettingsMenuItemMap = { "sectionType" : "preferences", "menuItem" : singleSettingsMenuItem, };
- Provide IconData against the
iconData
field. - Provide Item Label against the
text
field. - Provide action that you want to perform on tap of this item, against the
onTap
field. - If you do not want a divider under the menu item, set the value of
removeDecoration
to true. - If you want to manually adjust the padding of menu item, provide Padding against the
padding
field. - Rename the widget
singleSettingsMenuItem
, as you like. - There are two sections on ‘Settings’ page:
- preferences.
- community_standards_and_legal_policies.
If you want to place the menu item in specific section, define the section type (preferences or community_standards_and_legal_policies) against the
sectionType
key insingleSettingsMenuItemMap
. - Add the widget name (e.g. singleSettingsMenuItem, if not changed) against the
menuItem
key in singleSettingsMenuItemMap. - Rename the widget singleSettingsMenuItemMap, as you like.
- Finally add the Widget Map name to the List
settingsItemHookList
. - Restart the App.
Example code for Single Settings Menu item:
Widget descriptionSettingsMenuItem = genericWidgetRow(
iconData: Icons.description_outlined,
text: "Temporary Show Description",
onTap: (){
// Some Function()
print("Showing Description.........................");
},
removeDecoration: true,
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
);
Map<String, dynamic> descriptionSettingsMenuItemMap = {
"sectionType" : "",
"menuItem" : descriptionSettingsMenuItem,
};
Widget helpSettingsMenuItem = genericWidgetRow(
iconData: Icons.help_outlined,
text: "Temporary Show Help",
onTap: (){
// Some Function()
print("Showing Description.........................");
},
removeDecoration: true,
padding: EdgeInsets.symmetric(horizontal: 20.0, vertical: 10.0),
);
Map<String, dynamic> helpSettingsMenuItemMap = {
"sectionType" : "",
"menuItem" : helpSettingsMenuItem,
};
List<dynamic> settingsItemHookList = [
descriptionSettingsMenuItemMap,
helpSettingsMenuItemMap,
];
Steps to Add Settings Menu Section with Menu items:
-
Copy and paste the sample code of settingsMenuSectionWithItems.
Widget settingsMenuSectionWithItems = genericSettingsWidget( headingText: "", headingSubTitleText: "", removeDecoration: false, enableTopDecoration: true, enableBottomDecoration: false, body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // define your menu items here ], ), ); Map<String, dynamic> settingsMenuSectionWithItemsMap = { "sectionType" : "", "menuItem" : settingsMenuSectionWithItems, };
- Provide Section Heading Name against the ‘headingText’ field.
- Provide Section Sub-Heading Name against the ‘headingSubTitleText’ field.
- If you do not want a divider under the menu item, set the value of
removeDecoration
to true. - If you want to provide a divider above the menu section, set the value of
enableTopDecoration
to true. - If you want to provide a divider below the menu section, set the value of
enableBottomDecoration
to true. - Rename the widget
settingsMenuSectionWithItems
, as you like. - Add the menu items in the
childern
section of thebody
. - Leave the empty value against
sectionType
key in settingsMenuSectionWithItemsMap. - Add the widget name (e.g. settingsMenuSectionWithItems, if not changed) against the
menuItem
key in settingsMenuSectionWithItemsMap. - Rename the widget settingsMenuSectionWithItemsMap, as you like.
- Finally add the Widget Map name to the List
settingsItemHookList
. - Restart the App.
Example code for Settings Menu Section with items:
Widget settingsMenuSectionWithItems = genericSettingsWidget(
headingText: "Temporary Heading",
headingSubTitleText: "Temporary Sub Heading",
enableTopDecoration: true,
enableBottomDecoration: false,
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
genericWidgetRow(
iconData: Icons.description_outlined,
text: "Temporary Show Description",
onTap: (){
// Some Function()
print("Showing Description.........................");
},
removeDecoration: true,
),
genericWidgetRow(
iconData: Icons.help_outlined,
text: "Temporary Help Description",
onTap: (){
// Some Function()
print("Showing Help.........................");
},
removeDecoration: true,
),
],
),
);
Map<String, dynamic> settingsMenuSectionWithItemsMap = {
"sectionType" : "",
"menuItem" : settingsMenuSectionWithItems,
};
List<dynamic> settingsItemHookList = [
settingsMenuSectionWithItemsMap,
];