Krunal
Krunal

Reputation: 79686

Flutter: How to open main.dart

With the help of installation guide and this solution: How to create a new project in Flutter, I created a sample (default/demo) project in flutter for iOS and Android compatible platforms. And a default project (code) is working fine.

enter image description here

Now, I want to update the code of the project and according to this document guide: Get Started: Test Drive, a file named main.dart is source file of project and code inside it, is the main source code.

enter image description here

My problem is - How to open main.dart?
Which editor (Xcode/Android Studio or any other tool) can help to open this file? I tried double click on the file, but it shows me a message: "legacy image should be converted".

enter image description here

Upvotes: 1

Views: 7442

Answers (2)

MobileApps
MobileApps

Reputation: 146

Here is an answer to your question by Flutter: Get Started: Configure Editor

You can either use Android Studio or Visual Studio Code as a Flutter (main.dart) project editor.

Steps are also mentioned in this document, how you can open Flutter project with these editors:

Visual Studio Code (VS Code) setup

VS Code: A light-weight editor with Flutter run and debug support.

Install VS Code: VS Code, version 1.20.1 or later.

Install the Dart Code plugin

  1. Start VS Code
  2. Invoke View>Command Palette…
  3. Type ‘install’, and select the ‘Extensions: Install Extension’ action
  4. Enter dart code in the search field, select ‘Dart Code’ in the list, and click Install
  5. Select ‘OK’ to reload VS Code

Validate your setup with the Flutter Doctor

  1. Invoke View>Command Palette…
  2. Type ‘doctor’, and select the ‘Flutter: Run Flutter Doctor’ action
  3. Review the output in the ‘OUTPUT’ pane for any issues

Android Studio setup

Android Studio: A complete, integrated IDE experience for Flutter.

Install Android Studio: Android Studio, version 3.0 or later.

Install the Flutter and Dart plugins

  • The Flutter plugin powers Flutter developer workflows (running, debugging, hot reload, etc.).
  • The Dart plugin offers code analysis (code validation as you type, code completions, etc.).

To install these:

  1. Start Android Studio.
  2. Open plugin preferences (Preferences>Plugins on macOS, File>Settings>Plugins on Windows & Linux).
  3. Select Browse repositories…, select the Flutter plug-in and click install.
  4. Click Yes when prompted to install the Dart plugin.
  5. Click Restart when prompted.

Upvotes: 2

mrunal thanki
mrunal thanki

Reputation: 751

Handle your flutter project with Android Studio 3.0 +.

Install plug-ins for Dart and Flutter in Android studio and then open your project (root directory) of your project in Android Studio.

  1. Start Android Studio.
  2. Open plugin preferences (Preferences>Plugins on macOS, File>Settings>Plugins on Windows & Linux).
  3. Select Browse repositories…, select the Flutter plug-in and click install.
  4. Click Yes when prompted to install the Dart plugin.
  5. Click Restart when prompted.

Here is sample project in Android Studio, with same name as you used in your project:

enter image description here

Look at this reference document: Get Started: Configure Editor

Upvotes: 1

Related Questions