Adding custom SettingButtons to the widgets.dart file

As we did for the ProductivityButton, in order to avoid unnecessary code duplication, we can create a button that we can reuse several times within the Settings screen. This button has some properties that are different from the ProductivityButton, so we'll create a new widget using the following steps:

  1. In the widgets.dart file, let's create a new stateless widget called SettingButton, like this:
class SettingButton extends StatelessWidget {  @override  Widget build(BuildContext context) {    return Container(    );  }}

This class will have a few properties that we will use in the constructor method, as follows:

final Color color;final String text;final int value;SettingsButton(this.color, this.text, ...

Get Flutter Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.