Stratus Cube Logo
Stratus Cube
  • Home
  • Products
  • Articles
  • Music
  • Contact Us

Site Map

  • Home
  • Products
  • Articles

Resources

  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Discover Music

Social

  • LinkedIn
  • Twitter

© Copyright StratusCube.dev. All Rights Reserved

Back to Articles

Flutter Dart Cheat Sheet for TypeScript Developers

February 8, 2024

Welcome to "Flutter Dart Cheat Sheet for TypeScript Developers". This article is meant to be a quick reference guide for software developers already familiar with TypeScript who are looking to expand their expertise into Flutter app development using Dart.

Variables and Constants

// TypeScript
var myVar: string = "hello world";
let myLet: string = "hello world";
const myConst:string = "hello world";

// Dart
var myVar = "hello world"; // Inferred type
const String myConst = "hello world"; // Compile-time constant
final String myFinal = "hello world"; // Set the value at run-time once
late String myLateVar; // Set the value later

async/await

// TypeScript
async myFunction (myArg: string): Promise<void> {
  // await something
}

// Dart
Future<void> myFunction (String myArg) async {
  // await something
}

Console.log / Print

// TypeScript
console.log("hello world");

// Dart
print("hello world");

String interpolation

// TypeScript
const welcomeText = `Hello ${firstName}`;

// Dart
final welcomeText = 'Hello $firstName';

setTimeout

// TypeScript
const myTimeout = setTimeout(() => {
  // do something
}, 1000);
clearTimeout(myTimeout);

// Dart
import 'dart:async';
...
final myTimeout = Timer(Duration(seconds: 1), () {
  // do something
});
myTimeout.cancel();

setInterval

// TypeScript
const myInterval = setInterval(() => {
  // do something
}, 1000);
clearInterval(myInterval);

// Dart
import 'dart:async';
...
final myInterval = Timer.periodic(Duration(seconds: 1), (timer) {
  // do something
});
myInterval.cancel();
Anthony Tietjen

About the Author

Anthony Tietjen is a software engineer with experience across desktop, mobile, and web development. Husband and father, with a passion for music and the outdoors. Connect with Anthony on LinkedIn and X/Twitter

About StratusCube

StratusCube makes software for everyday use along with software engineering articles. If you enjoined this article, please take a moment to browse our apps or check out more articles .