What is the Difference between Dart console-full and console-simple application?

While learning dart I came across to these type of console application, so I just want to know What is the Difference between Dart console-full and console-simple application?


Solution 1:

Both templates generate a Dart project with some default files:

  • .dart_tool/package_config.json
  • .gitignore
  • .packages
  • analysis_options.yaml
  • CHANGELOG.md
  • pubspec.lock
  • pubspec.yaml
  • README.md

But does then also create Dart files which depends on the type of template:

console-simple

Creates a very basic Dart project with a single Dart file named bin/<project_name>.dart with the content:

void main(List<String> arguments) {
  print('Hello world!');
}

console-full

Create a more complete Dart project where we split the code into bin/, lib/, and test/. The description in the auto-generated README.md file does explain the file structure:

A sample command-line application with an entrypoint in bin/, library code in lib/, and example unit test in test/.

The project makes use of the test package for unit testing so the project will by default include this package in the pubspec.yaml.

Following Dart files is generated to make use of the three directories:

// bin/project_name.dart
import 'package:project_name/project_name.dart' as project_name;

void main(List<String> arguments) {
  print('Hello world: ${project_name.calculate()}!');
}
// lib/project_name.dart
int calculate() {
  return 6 * 7;
}
// test/project_name_test.dart
import 'package:project_name/project_name.dart';
import 'package:test/test.dart';

void main() {
  test('calculate', () {
    expect(calculate(), 42);
  });
}