Flutter Create Custom New Widget in Android iOS Example Tutorial

In flutter we would use Widget keyword along with widget name to create custom widgets. Flutter gives us functionality to make designing easier using custom widgets. Using custom widgets we can easily existing widgets and also make new widgets by modifying current widgets. Custom widgets has return area which would return us complete widget pass in it. Widget is the center of development in flutter framework. So in this tutorial we would Flutter Create Custom New Widget in Android iOS Example Tutorial.

Contents in this project Flutter Create Custom New Widget in Android iOS Example Tutorial:

1. Import material.dart package in your app’s main.dart file.

2. Create void main runApp() method and here we would pass our main MyApp class. This class is our main screen class in current tutorial.

3. Create our main class named as MyApp extends with StatelessWidget.

4. Create a Custom widget named as customTextWidget() with 4 different properties. This is our custom widget. In this widget we would requiring 4 values from user at widget calling time.

  1. text : Text used to print on screen in Text widget.
  2. Color : Text Color pass by user to set Text color.
  3. fONTSize : Require double value to set Text font size.
  4. fONTStyle : Used to set font style like bold or Italic.;

5. Create Widget Build area in MyApp. Now we would make the Scaffold widget -> Center widget -> Column widget.

6. Now we would call our custom widget customTextWidget() with all 4 parameter values.

7. Complete source code for main.dart file:

Screenshot:

Flutter Create Custom New Widget in Android iOS Example Tutorial

Leave a Reply

Your email address will not be published. Required fields are marked *