1

Description:

  • I'm new to Android Studio and Flutter, and try to write App with. Currently I have to build App on device in order to test some code snippet, and it's inefficient.
  • Is there a way to test code snippet in console, like Python Console or JavaScript Console in browser?

For example:

  • Assuming I'm not sure how datetime manipulation work in Python, and then I write some code in PyCharm IDE to test out:
  • Test some code in PyCharm

2 Answers 2

4

There are two easy ways as I know for this situation.

First is in browser solution; DartPad https://dartpad.dartlang.org/

Second is in Android Studio;

enter image description here

Create a test.dart file under your project folder. Click down arrow near main.dart seen in image. Select "Edit Configurations". Then new screen pops up. Click + sign and "Dart Command Line App". Browse and select your test.dart file. Click apply and close window. Now you can run your test.dart file and see results in console.

Sign up to request clarification or add additional context in comments.

2 Comments

Does the approach at Android Studio also work on other languages, such as Kotlin and etc?
There is "Kotlin script" option on configuration menu but I didn't try it.
1

you can run your code on android studio terminal, there is no need tempering with your configurations. Make sure you are in the same folder with the testing.dart. Then run dart testing.dart

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.