{"id":741,"date":"2023-07-25T06:25:05","date_gmt":"2023-07-25T06:25:05","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=741"},"modified":"2023-07-25T06:25:07","modified_gmt":"2023-07-25T06:25:07","slug":"creating-your-first-project-and-running-hello-world-on-the-emulator","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/creating-your-first-project-and-running-hello-world-on-the-emulator\/","title":{"rendered":"Creating Your First Project and Running &#8220;Hello World&#8221; on the Emulator"},"content":{"rendered":"\n<p>Create a New Flutter Project<\/p>\n\n\n\n<p>To create a new Flutter project, run the following command in the terminal.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter create hello_world_app\r\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-13.png\" alt=\"\" class=\"wp-image-742\" width=\"444\" height=\"187\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-13.png 906w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-13-300x126.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-13-768x324.png 768w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-13-850x358.png 850w\" sizes=\"auto, (max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n\n<p>This command creates a new directory named &#8220;hello_world_app&#8221; with the necessary files and folder structure for a Flutter project.<\/p>\n\n\n\n<p>Depending on your chosen IDE (Android Studio or Visual Studio Code), open the &#8220;hello_world_app&#8221; directory as a Flutter project. Ensure that you have an emulator set up, Open your emulator. <\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-14.png\" alt=\"\" class=\"wp-image-743\" width=\"444\" height=\"252\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-14.png 862w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-14-300x171.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-14-768x437.png 768w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-14-850x483.png 850w\" sizes=\"auto, (max-width: 444px) 100vw, 444px\" \/><\/figure>\n\n\n\n<p>In your IDE, click on the &#8220;Run&#8221; button (usually a green triangle) to run the app.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>flutter run\r\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-15.png\" alt=\"\" class=\"wp-image-744\" width=\"448\" height=\"196\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-15.png 708w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-15-300x131.png 300w\" sizes=\"auto, (max-width: 448px) 100vw, 448px\" \/><\/figure>\n\n\n\n<p>This will launch the app on the emulator or connected device, and you&#8217;ll see the &#8220;Hello World&#8221; message on the screen.<\/p>\n\n\n\n<p>Open the <code>main.dart<\/code> file located inside the <code>lib<\/code> folder of your project. You will see the following code:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:flutter\/material.dart';\r\n\r\nvoid main() {\r\n  runApp(MyApp());\r\n}\r\n\r\nclass MyApp extends StatelessWidget {\r\n  @override\r\n  Widget build(BuildContext context) {\r\n    return MaterialApp(\r\n      home: Scaffold(\r\n        appBar: AppBar(\r\n          title: Text('Hello World'),\r\n        ),\r\n        body: Center(\r\n          child: Text('Hello World!'),\r\n        ),\r\n      ),\r\n    );\r\n  }\r\n}\r\n<\/code><\/pre>\n\n\n\n<p>The <code>main<\/code> function is the entry point of the Flutter app, and it calls <code>runApp()<\/code> to start the application. The <code>MyApp<\/code> class is a StatelessWidget, which means its UI cannot change after it&#8217;s built.<\/p>\n\n\n\n<p>The <code>MaterialApp<\/code> widget sets up the basic material design for the app, and the <code>Scaffold<\/code> widget provides a basic structure for the app, including an <code>AppBar<\/code> and a <code>body<\/code>.<\/p>\n\n\n\n<p>The <code>Text<\/code> widget inside the <code>Center<\/code> widget displays the &#8220;Hello World!&#8221; message on the screen.<\/p>\n\n\n\n<p>Now that you have successfully run your first Flutter app<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a New Flutter Project To create a new Flutter project, run the following command in the terminal. This command creates a new directory named &#8220;hello_world_app&#8221; with&#8230; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-741","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/741","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/comments?post=741"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/741\/revisions"}],"predecessor-version":[{"id":745,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/741\/revisions\/745"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=741"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=741"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=741"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}