1. Home
  2. /
  3. Dart
  4. /
  5. Counter with Lambda Actions

Counter with Lambda Actions - Dart Typing CST Test

Loading…

Counter with Lambda Actions — Dart Code

Demonstrates using Dart anonymous functions (lambdas) for counter actions and theme toggling.

void main() {
	int count = 0;
	bool isDark = false;

	var updateUI = () => print('Counter: $count, Theme: ${isDark ? 'Dark' : 'Light'}');
	var increment = () { count++; updateUI(); };
	var decrement = () { count--; updateUI(); };
	var reset = () { count = 0; updateUI(); };
	var toggleTheme = () { isDark = !isDark; updateUI(); };

	updateUI();
	increment();
	toggleTheme();
	decrement();
	reset();
}

Dart Language Guide

Dart is a modern, object-oriented programming language developed by Google, optimized for building web, server, and mobile applications, particularly for Flutter. It emphasizes performance, strong typing, and productive development.

Primary Use Cases

  • ▸Mobile app development with Flutter
  • ▸Web applications and progressive web apps (PWAs)
  • ▸Server-side applications with Dart VM
  • ▸Command-line tools and scripts
  • ▸Cross-platform desktop applications

Notable Features

  • ▸Strongly typed with sound null safety
  • ▸Ahead-of-time (AOT) and just-in-time (JIT) compilation
  • ▸Hot reload for fast development cycles
  • ▸Rich standard library and asynchronous support
  • ▸Interoperability with JavaScript for web development

Origin & Creator

Created in 2011 by Google, designed by Lars Bak and Kasper Lund.

Industrial Note

Dart is specialized for cross-platform development, especially for Flutter, enabling single codebases for mobile, web, and desktop applications.

More Dart Typing Exercises

Dart Theme Toggle and CounterDart Counter with HistoryDart Counter with Conditional ThemeDart Counter with Max LimitDart Counter with Timer Auto-IncrementDart Counter with User InputDart Counter with Event CallbacksDart Counter with Custom StepDart Counter with Persistent Storage

Practice Other Languages

CReactPythonC++RustTypeScriptKotlinPHPJavaC#RubyMqlCqlN1qlCypher