{"id":780,"date":"2023-07-16T12:33:11","date_gmt":"2023-07-16T12:33:11","guid":{"rendered":"https:\/\/www.devopssupport.in\/blog\/?p=780"},"modified":"2023-07-28T12:43:56","modified_gmt":"2023-07-28T12:43:56","slug":"how-to-create-your-flutter-project-in-vs-code","status":"publish","type":"post","link":"https:\/\/www.devopssupport.in\/blog\/how-to-create-your-flutter-project-in-vs-code\/","title":{"rendered":"How to create your Flutter project in VS Code"},"content":{"rendered":"\n<p>Launch Visual Studio Code and open the command palette (with\u00a0<code>F1<\/code>\u00a0or\u00a0<code>Ctrl+Shift+P<\/code>\u00a0or\u00a0<code>Shift+Cmd+P<\/code>). Start typing &#8220;flutter new&#8221;. Select the\u00a0<strong>Flutter: New Project<\/strong>\u00a0command.<\/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-21.png\" alt=\"\" class=\"wp-image-781\" width=\"477\" height=\"314\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-21.png 745w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-21-300x197.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-21-350x230.png 350w\" sizes=\"auto, (max-width: 477px) 100vw, 477px\" \/><\/figure>\n\n\n\n<p>Next, select\u00a0<strong>Application<\/strong>\u00a0and then a folder in which to create your project. This could be your home directory, or something like\u00a0<code>C:\\src\\<\/code>. Finally, name your project. Something like\u00a0<code>name_app<\/code><\/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-22.png\" alt=\"\" class=\"wp-image-782\" width=\"486\" height=\"265\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-22.png 786w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-22-300x164.png 300w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-22-768x419.png 768w\" sizes=\"auto, (max-width: 486px) 100vw, 486px\" \/><\/figure>\n\n\n\n<p>Flutter now creates your project folder and VS Code opens it. You&#8217;ll now overwrite the contents of 3 files with a basic scaffold of the app. Copy &amp; Paste the initial app <\/p>\n\n\n\n<p>In the left pane of VS Code, make sure that\u00a0<strong>Explorer<\/strong>\u00a0is selected, and open the\u00a0<code>pubspec.yaml<\/code>\u00a0file.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"418\" height=\"655\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-24.png\" alt=\"\" class=\"wp-image-784\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-24.png 418w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-24-191x300.png 191w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-24-300x470.png 300w\" sizes=\"auto, (max-width: 418px) 100vw, 418px\" \/><\/figure>\n\n\n\n<p>Replace the contents of this file with the following:<\/p>\n\n\n\n<p>In pubspec.yaml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>name: namer_app\r\ndescription: A new Flutter project.\r\n\r\npublish_to: 'none' # Remove this line if you wish to publish to pub.dev\r\n\r\nversion: 0.0.1+1\r\n\r\nenvironment:\r\n  sdk: '>=2.19.4 &lt;4.0.0'\r\n\r\ndependencies:\r\n  flutter:\r\n    sdk: flutter\r\n\r\n  english_words: ^4.0.0\r\n  provider: ^6.0.0\r\n\r\ndev_dependencies:\r\n  flutter_test:\r\n    sdk: flutter\r\n\r\n  flutter_lints: ^2.0.0\r\n\r\nflutter:\r\n  uses-material-design: true<\/code><\/pre>\n\n\n\n<p>The\u00a0<code>pubspec.yaml<\/code>\u00a0file specifies basic information about your app, such as its current version, its dependencies, and the assets with which it will ship.<\/p>\n\n\n\n<p>Next, open another configuration file in the project,\u00a0<code>analysis_options.yaml<\/code>.<\/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-25.png\" alt=\"\" class=\"wp-image-785\" width=\"442\" height=\"504\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-25.png 559w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-25-263x300.png 263w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-25-300x342.png 300w\" sizes=\"auto, (max-width: 442px) 100vw, 442px\" \/><\/figure>\n\n\n\n<p>Replace its contents with the following:<\/p>\n\n\n\n<p>analysis_options.yaml<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>include: package:flutter_lints\/flutter.yaml\r\n\r\nlinter:\r\n  rules:\r\n    prefer_const_constructors: false\r\n    prefer_final_fields: false\r\n    use_key_in_widget_constructors: false\r\n    prefer_const_literals_to_create_immutables: false\r\n    prefer_const_constructors_in_immutables: false\r\n    avoid_print: false<\/code><\/pre>\n\n\n\n<p>This file determines how strict Flutter should be when analyzing your code. Since this is your first foray into Flutter, you&#8217;re telling the analyzer to take it easy. You can always tune this later. In fact, as you get closer to publishing an actual production app, you will almost certainly want to make the analyzer stricter than this. Finally, open the\u00a0<code>main.dart<\/code>\u00a0file under the\u00a0<code>lib\/<\/code>\u00a0directory.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"616\" src=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-26.png\" alt=\"\" class=\"wp-image-786\" srcset=\"https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-26.png 505w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-26-246x300.png 246w, https:\/\/www.devopssupport.in\/blog\/wp-content\/uploads\/2023\/07\/image-26-300x366.png 300w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/figure>\n\n\n\n<p>Replace the contents of this file with the following:<\/p>\n\n\n\n<p>lib\/main.dart<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import 'package:english_words\/english_words.dart';import 'package:flutter\/material.dart';import 'package:provider\/provider.dart';void main() {&nbsp; runApp(MyApp());}class MyApp extends StatelessWidget {&nbsp; const MyApp({super.key});&nbsp; @override&nbsp; Widget build(BuildContext context) {&nbsp; &nbsp; return ChangeNotifierProvider(&nbsp; &nbsp; &nbsp; create: (context) =&gt; MyAppState(),&nbsp; &nbsp; &nbsp; child: MaterialApp(&nbsp; &nbsp; &nbsp; &nbsp; title: 'Namer App',&nbsp; &nbsp; &nbsp; &nbsp; theme: ThemeData(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; useMaterial3: true,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange),&nbsp; &nbsp; &nbsp; &nbsp; ),&nbsp; &nbsp; &nbsp; &nbsp; home: MyHomePage(),&nbsp; &nbsp; &nbsp; ),&nbsp; &nbsp; );&nbsp; }}class MyAppState extends ChangeNotifier {&nbsp; var current = WordPair.random();}class MyHomePage extends StatelessWidget {&nbsp; @override&nbsp; Widget build(BuildContext context) {&nbsp; &nbsp; var appState = context.watch&lt;MyAppState&gt;();&nbsp; &nbsp; return Scaffold(&nbsp; &nbsp; &nbsp; body: Column(&nbsp; &nbsp; &nbsp; &nbsp; children: &#91;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text('A random idea:'),&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Text(appState.current.asLowerCase),&nbsp; &nbsp; &nbsp; &nbsp; ],&nbsp; &nbsp; &nbsp; ),&nbsp; &nbsp; );&nbsp; }}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Launch Visual Studio Code and open the command palette (with\u00a0F1\u00a0or\u00a0Ctrl+Shift+P\u00a0or\u00a0Shift+Cmd+P). Start typing &#8220;flutter new&#8221;. Select the\u00a0Flutter: New Project\u00a0command. Next, select\u00a0Application\u00a0and then a folder in which to create&#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-780","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/780","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=780"}],"version-history":[{"count":1,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/780\/revisions"}],"predecessor-version":[{"id":787,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/posts\/780\/revisions\/787"}],"wp:attachment":[{"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/media?parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/categories?post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopssupport.in\/blog\/wp-json\/wp\/v2\/tags?post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}