Pen Settings

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

Flutter

              
                import 'dart:async';
import 'dart:ui';

import 'package:flutter/material.dart';

///
/// Follow this mouse
///

void main() {
  runApp(
    MaterialApp(
      home: Scaffold(body: Board()),
      debugShowCheckedModeBanner: false,
    ),
  );
}

final size = window.physicalSize / window.devicePixelRatio;

class Board extends StatefulWidget {
  @override
  _BoardState createState() => _BoardState();
}

class _BoardState extends State<Board> {
  final StreamController<Offset> _streamer = StreamController<Offset>();

  Stream<Offset> get point$ => _streamer.stream;

  @override
  Widget build(BuildContext context) => MouseRegion(
        onHover: (details) => _streamer.add(details.localPosition),
        child: StreamBuilder<Offset>(
          initialData: Offset.zero,
          stream: point$,
          builder: (context, snapshot) =>
              CustomPaint(size: size, painter: Painter(snapshot.data)),
        ),
      );

  @override
  void dispose() {
    _streamer.close();
    super.dispose();
  }
}

class Painter extends CustomPainter {
  static const radius = 10.0;

  static final fill = Paint()..color = Colors.red;

  final Offset mouse;

  const Painter(this.mouse);

  @override
  void paint(Canvas canvas, Size size) {
    canvas.drawCircle(mouse, radius, fill);
  }

  @override
  bool shouldRepaint(CustomPainter oldDelegate) => true;
}

              
            
!
999px

Console