MYHOSPITALNOW.COM

Find Trusted Doctors & Hospitals

Discover healthcare providers, compare hospitals, and explore treatment options worldwide.

Free Treatment Quotes • Doctor Search • Hospital Comparison

Find Healthcare Options

www.myhospitalnow.com

How To Create Your Own Widget In Flutter.

To Create your Own Widget in Flutter, Just Follow the Below Steps.

Step 1 :- First of all, create a new file in lib directory named home.dart (you can write any name but extension should be .dart). See the below image for help :-

VS Code explorer for the own_widget project with home.dart highlighted in the lib folder
own_widget_in_flutter

Step 2 :- Now, in home.dart file we first import flutter package library named material.dart and create a stateless widget named home and return Centre widget in which we take child as Text Widget, and in text widget lets pass a Welcome Message “My Own Widget“ and also add Direction to our Text Widget otherwise it returns error. See the below code.

Step 3 :- Now, in main.dart file, import material.dart package library and home.dart package library which is created by us, and call our main method.

Step 4 :- Under main() we call runApp() in which we use our own Widget Home to perform operations. See the below code :-

Thats All. We are Ready to Run our Project.

To Run your Project There are Two Methods.

Method 1 :- Go to Terminal and write flutter run and run the command. See the ScreenShot Below.

VS Code with main.dart open and annotated steps to open the terminal and run flutter run

Method 2 :- Click on Run and Debug option and click on Green Button to run the Project. See the Below image :-

VS Code Run and Debug panel with annotations to select Flutter and click the green run button

See Output Below

Flutter app running on an Android emulator showing the text My Own Widget on a black screen

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services — all in one place.

Explore Hospitals
With MotoShare.in, you can book a bike instantly, enjoy doorstep delivery, and ride without worries. Perfect for travelers, professionals, and adventure enthusiasts looking for a seamless mobility solution.

Related Posts

What is Flutter and use cases of Flutter?

What is Flutter? Flutter is an open-source UI software development toolkit developed by Google. It is applied for building natively compiled applications for mobile, web, and desktop…

Read More

[Solved] Flutter : Error: The getter ‘subhead’ isn’t defined for the class ‘TextTheme’ from package:flutter/src/material/text_theme.dart’ – searchable_dropdown

ERROR SOLUTION There are Two Solutions for this error Use Alternative Package Do some changes in .pub-cache Use Alternative Package I switched from searchable_dropdown to search_choices and…

Read More

[SOLVED] Flutter Error: The getter ‘body1’ isn’t defined for the class ‘TextTheme’ – place_picker.

Error SOLUTION Here is what I found on StackOverflow Source (Stackoverflow):- https://stackoverflow.com/questions/69312392/how-to-resolve-error-the-getter-body1-isnt-defined-for-the-class-texttheme To fix this issue you have to make some changes to Two files C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/place_picker-0.9.19-nullsafety/lib/widgets/rich_suggestion.dart 2….

Read More

[SOLVED] Flutter : NoSuchMethodError: The getter ‘isEmpty’ was called on null.

Problem I’m Calling An API and getting response in Variable Data ($data). When data is coming then there is no Error but when I’m getting null as…

Read More

[SOLVED] Flutter : Cannot run with sound null safety, because the following dependencies don’t support null safety

Problem I’m using flutter_recaptcha_v2: ^0.1.0. Now, I am trying to run it using flutter run, however, it will not start because of the following error: Solution If you want…

Read More

How to Check if an application is on its first run or One time Intro Screen with Flutter.

If you wish to show the intro screen only for the first time, you will need to save locally that this user has already seen intro. For…

Read More