Flutter
Flutter is Google's open-source framework for building natively compiled, multi-platform applications from a single codebase.
Flutter in LiveCodes is compiled in the browser, with no server, using the same client-side toolchain as Dart — packaged as @live-codes/dart-wasm. The compiled app then boots the Flutter engine in the result page.
For Dart language support in LiveCodes, see Dart.
Usage
Demo:
The app renders in the context of the result page, so it fills the result pane and responds to user interaction, just like any other Flutter web app.
A stateful counter is the usual way to see a rebuild:
import 'package:flutter/material.dart';
void main() {
runApp(const CounterApp());
}
class CounterApp extends StatefulWidget {
const CounterApp({super.key});
@override
State<CounterApp> createState() => _CounterAppState();
}
class _CounterAppState extends State<CounterApp> {
int _count = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('$_count', style: const TextStyle(fontSize: 56)),
const SizedBox(height: 12),
ElevatedButton(
onPressed: () => setState(() => _count++),
child: const Text('Increment'),
),
],
),
),
),
);
}
}
Root Element
Flutter draws its own UI, so it renders into an element in the result page.
Use "livecodes-app" as the element id to render into a specific element. Otherwise a div element is added to document.body and rendered into.
The app is sized to that element's box, so the element must have a size. An empty div in normal flow has none, and width/height in percent resolve against an unsized body.
Example:
Language Info
Name
flutter
Extensions
flutter
Editor
script
Compiler
The Dart team's client-side toolchain (DDC), using the dartpad package and the CanvasKit renderer.
Version
DartPad SDK 0.0.9
Code Formatting
Dart's official formatter (the dart_style package behind dart format).
Starter Template
https://livecodes.io/?template=flutter