How To Create Custom New Widget Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 12-10-2020

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.

How To Create Custom New Widget Using Flutter Android App

Custom New Widget
Complete Code For Custom New Widget In Flutter
Main.dart

import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
  Widget customTextWidget(var text, Color color, double fONTSize, FontStyle fONTStyle) {
    return Text(text,
        style: TextStyle(
            color: color,
            fontSize:  fONTSize,
            fontStyle: fONTStyle
        ));
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
        home: Scaffold(
          appBar: AppBar(
            title: Text('Custom New Widget'),
          ),
          body: Center(
              child: Column(
                  mainAxisAlignment : MainAxisAlignment.center,
                  children: [
                    customTextWidget('Hello Guys', Color(0xFFF50057), 32, FontStyle.normal),
                    customTextWidget('Welcome', Color(0xFFC0CA33), 32, FontStyle.normal),
                    customTextWidget('To', Color(0xFF00695C), 32, FontStyle.normal),
                    customTextWidget('Bajarangisoft.com', Color(0xFF01579B), 32, FontStyle.normal),

                  ])
          ),
        )
    );
  }
}

Related Post