Skip to content

Commit

Permalink
v1.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
huextrat committed Mar 5, 2021
1 parent 6d1ed77 commit e4d4f89
Show file tree
Hide file tree
Showing 70 changed files with 2,917 additions and 224 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.4.0+1 - 2021-03-03

- Null safety
- Improve documentation
- Tested on Flutter 2.0 it's working on every platform

## 1.3.1+1 - 2021-03-03

- Update README to make it clearer
Expand Down
25 changes: 8 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ Flutter widget to display a popup menu button very simply and easily customizabl
- [Documentation](https://pub.dev/documentation/menu_button/latest/menu_button/MenuButton-class.html)
- [Pub Package](https://pub.dev/packages/menu_button)
- [GitHub Repository](https://github.com/huextrat/menu_button)
- [Online Demo](https://appetize.io/app/w352kxbnz51c6pfvxrdvxcb3xw?device=nexus5&scale=100&orientation=landscape&osVersion=8.1&deviceColor=black)

## Installations

Add `menu_button: ^1.3.1+1` in your `pubspec.yaml` dependencies. And import it:
Add `menu_button: ^1.4.0+1` in your `pubspec.yaml` dependencies. And import it:

```dart
import 'package:menu_button/menu_button.dart';
Expand Down Expand Up @@ -53,19 +52,11 @@ MenuButton<String>(
toggledChild: Container(
child: normalChildButton,
),
divider: Container(
height: 1,
color: Colors.grey,
),
onItemSelected: (String value) {
setState(() {
selectedKey = value;
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
borderRadius: const BorderRadius.all(Radius.circular(3.0))
),
onMenuButtonToggle: (bool isToggle) {
print(isToggle);
},
Expand Down Expand Up @@ -112,25 +103,25 @@ Of course you can make your own according to your needs.
| `child` | A widget to display the default button to trigger the menu button |
| `items` | The list that contains all values that you want to display on the menu button |
| `itemBuilder` | A widget to design each item of the menu button |
| `toggledChild` | Same as child but when the menu button is opened |
| `divider` | A custom divider between each items |
| `onItemSelected` | Function triggered when an item is selected |
| `decoration` | A custom decoration for menu button |
| `onMenuButtonToggle` | Function triggered when menu button is triggered (`true` if displayed, `false` if not) |
| `toggledChild` | Same as child but when the menu button is opened |

## More Parameters

| Parameter | Description |
|---|---|
| `scrollPhysics` | By default items are not scrollable (`NeverScrollableScrollPhysics`), add a ScrollPhysics to enable it, for instance `AlwaysScrollableScrollPhysics` |
| `popupHeight` | By default `popupHeight` is automatically calculated but if you need a custom height use this property |
| `crossTheEdge` | By default `false` you can set it to `true` if you want the button to expand |
| `divider` | A custom divider between each items |
| `decoration` | A custom decoration for menu button |
| `edgeMargin` | By default `0` add a custom value to prevent the button to not touch the edge, check the example `edge_menu_button.dart` for more information |
| `showSelectedItemOnList` | By default `true`, set it to `false` if you don't want the selected items in the list |
| `itemBackgroundColor` | By default `Colors.white` add custom Colors to customize the background of every items |
| `label` | Add a widget to display a custom label as MaterialDesign on top of the button, check `label_menu_button.dart` for more information |
| `labelDecoration` | If you use a `label` you can set a custom `LabelDecoration` |
| `itemBackgroundColor` | By default `Colors.white` add custom Colors to customize the background of every items |
| `menuButtonBackgroundColor` | By default `Colors.white` add custom Colors to customize the background of the menu button |
| `popupHeight` | By default `popupHeight` is automatically calculated but if you need a custom height use this property |
| `scrollPhysics` | By default items are not scrollable (`NeverScrollableScrollPhysics`), add a ScrollPhysics to enable it, for instance `AlwaysScrollableScrollPhysics` |
| `showSelectedItemOnList` | By default `true`, set it to `false` if you don't want the selected items in the list |

---

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class MyApp extends StatelessWidget {
}

class MyHomePage extends StatefulWidget {
const MyHomePage({Key key, this.title}) : super(key: key);
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

Expand Down
10 changes: 5 additions & 5 deletions example/lib/usages/edge_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:menu_button/menu_button.dart';

class EdgeMenuButton extends StatefulWidget {
const EdgeMenuButton({
Key key,
@required this.theme,
Key? key,
required this.theme,
}) : super(key: key);

final ThemeData theme;
Expand All @@ -14,7 +14,7 @@ class EdgeMenuButton extends StatefulWidget {
}

class _EdgeMenuButtonState extends State<EdgeMenuButton> {
String selectedKey;
late String selectedKey;

List<String> keys = <String>[
'Lorem ipsum',
Expand Down Expand Up @@ -67,7 +67,7 @@ class _EdgeMenuButtonState extends State<EdgeMenuButton> {
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Menu button not crossing the edge',
style: widget.theme.textTheme.headline2.copyWith(
style: widget.theme.textTheme.headline2!.copyWith(
fontSize: 18,
),
),
Expand Down Expand Up @@ -101,7 +101,7 @@ class _EdgeMenuButtonState extends State<EdgeMenuButton> {
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
border: Border.all(color: Colors.grey[300]!),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
)),
Expand Down
21 changes: 9 additions & 12 deletions example/lib/usages/label_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:menu_button/menu_button.dart';

class MenuButtonLabel extends StatefulWidget {
const MenuButtonLabel({
Key key,
@required this.theme,
Key? key,
required this.theme,
}) : super(key: key);

final ThemeData theme;
Expand All @@ -14,8 +14,8 @@ class MenuButtonLabel extends StatefulWidget {
}

class _MenuButtonLabelState extends State<MenuButtonLabel> {
String selectedKey;
String initialValue;
late String selectedKey;
late String initialValue;

List<String> keys = <String>[
'Low',
Expand Down Expand Up @@ -67,7 +67,7 @@ class _MenuButtonLabelState extends State<MenuButtonLabel> {
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Menu button usage with label',
style: widget.theme.textTheme.headline2.copyWith(
style: widget.theme.textTheme.headline2!.copyWith(
fontSize: 18,
),
),
Expand All @@ -83,9 +83,10 @@ class _MenuButtonLabelState extends State<MenuButtonLabel> {
fontSize: 12,
),
),
labelDecoration: LabelDecoration(
labelDecoration: const LabelDecoration(
verticalMenuPadding: 12,
// background: Colors.red
background: Colors.white,
leftPosition: 6
),
itemBuilder: (String value) => Container(
height: 40,
Expand All @@ -96,17 +97,13 @@ class _MenuButtonLabelState extends State<MenuButtonLabel> {
toggledChild: Container(
child: childButtonWithoutSameItem,
),
divider: Container(
height: 1,
color: Colors.grey,
),
onItemSelected: (String value) {
setState(() {
selectedKey = value;
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
border: Border.all(color: Colors.grey[300]!),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
),
Expand Down
12 changes: 6 additions & 6 deletions example/lib/usages/menu_button_without_current.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:menu_button/menu_button.dart';

class MenuButtonWithoutShowingSameSelectedIitem extends StatefulWidget {
const MenuButtonWithoutShowingSameSelectedIitem({
Key key,
@required this.theme,
Key? key,
required this.theme,
}) : super(key: key);

final ThemeData theme;
Expand All @@ -16,8 +16,8 @@ class MenuButtonWithoutShowingSameSelectedIitem extends StatefulWidget {

class _MenuButtonWithoutShowingSameSelectedIitemState
extends State<MenuButtonWithoutShowingSameSelectedIitem> {
String selectedKey;
String initialValue;
late String selectedKey;
late String initialValue;

List<String> keys = <String>[
'Low',
Expand Down Expand Up @@ -69,7 +69,7 @@ class _MenuButtonWithoutShowingSameSelectedIitemState
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Usage of menu button without showing the same selected item',
style: widget.theme.textTheme.headline2.copyWith(
style: widget.theme.textTheme.headline2!.copyWith(
fontSize: 18,
),
),
Expand Down Expand Up @@ -99,7 +99,7 @@ class _MenuButtonWithoutShowingSameSelectedIitemState
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
border: Border.all(color: Colors.grey[300]!),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
),
Expand Down
13 changes: 4 additions & 9 deletions example/lib/usages/normal_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:menu_button/menu_button.dart';

class NormalMenuButton extends StatefulWidget {
const NormalMenuButton({
Key key,
@required this.theme,
Key? key,
required this.theme,
}) : super(key: key);

final ThemeData theme;
Expand All @@ -14,7 +14,7 @@ class NormalMenuButton extends StatefulWidget {
}

class _NormalMenuButtonState extends State<NormalMenuButton> {
String selectedKey;
late String selectedKey;

List<String> keys = <String>[
'Low',
Expand Down Expand Up @@ -67,7 +67,7 @@ class _NormalMenuButtonState extends State<NormalMenuButton> {
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Normal usage of menu button',
style: widget.theme.textTheme.headline2.copyWith(
style: widget.theme.textTheme.headline2!.copyWith(
fontSize: 18,
),
),
Expand All @@ -94,11 +94,6 @@ class _NormalMenuButtonState extends State<NormalMenuButton> {
selectedKey = value;
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
)),
onMenuButtonToggle: (bool isToggle) {
print(isToggle);
},
Expand Down
10 changes: 5 additions & 5 deletions example/lib/usages/scroll_menu_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'package:menu_button/menu_button.dart';

class ScrollPhysicsMenuButton extends StatefulWidget {
const ScrollPhysicsMenuButton({
Key key,
@required this.theme,
Key? key,
required this.theme,
}) : super(key: key);

final ThemeData theme;
Expand All @@ -15,7 +15,7 @@ class ScrollPhysicsMenuButton extends StatefulWidget {
}

class _ScrollPhysicsMenuButtonState extends State<ScrollPhysicsMenuButton> {
String selectedKey;
late String selectedKey;

List<String> keys = <String>[
'Low',
Expand Down Expand Up @@ -68,7 +68,7 @@ class _ScrollPhysicsMenuButtonState extends State<ScrollPhysicsMenuButton> {
padding: const EdgeInsets.only(bottom: 12.0),
child: Text(
'Menu button with scroll physics',
style: widget.theme.textTheme.headline2.copyWith(
style: widget.theme.textTheme.headline2!.copyWith(
fontSize: 18,
),
),
Expand Down Expand Up @@ -97,7 +97,7 @@ class _ScrollPhysicsMenuButtonState extends State<ScrollPhysicsMenuButton> {
});
},
decoration: BoxDecoration(
border: Border.all(color: Colors.grey[300]),
border: Border.all(color: Colors.grey[300]!),
borderRadius: const BorderRadius.all(
Radius.circular(3.0),
)),
Expand Down
1 change: 1 addition & 0 deletions example/linux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
flutter/ephemeral
Loading

0 comments on commit e4d4f89

Please sign in to comment.