In this series, we take a look at the whole Cupertino package of Flutter. You will get to know every widget, important classes, and much more in this series. All the articles will be less than 2 minutes long, so you can read them every time :) In addition to that, they will be very easy to understand, following the motto
Make everything as simple as possible, but not simpler. ~ Albert Einstein
If you want to check out the other articles of this series, check out this list. Let’s get started!
CupertinoButton is an iOS-style button. There are two different types of
CupertinoButton.filled. As the name suggests, the first one is not filled, and the second one is. So let’s take a look at the
CupertinoButton and see what we can customize:
There are actually very many customization options. Because there are so many, we just take a look at the most basic ones. In addition to that, you know the most ones of a normal button.
child. As in every other widget, this is just a
Widget you specify, usually a
Text, but it can be anything. Then there is
enabled, one that determines if the button is enabled. Fittingly there is
color for the background color of an enabled button and
disabledColor for the background color of a disabled button.
onPressed is also very important to call a callback when the user presses the button as well as
padding, the amount of space to surround the child inside the bounds of the button.
There are even more properties, like
pressedOpacity, but you should be familiar with them if you use a “normal” button.
Now let’s take a look at an example:
Further reading & Conclusion
In this article, you have learned how to use the CupertinoButton widget.
Did you know that there are great packages that enhance your development enormously? For example Freezed, Isar, or Flutter Hooks. If you want to learn about these great packages, I have entire tutorials about them. Check them out here.
In the following few articles, I will introduce more Cupertino widgets, essential classes, and more stuff. If you don’t want to miss this, I recommend you follow me!
Thanks for reading, have a nice day!