Pen Settings


Babel includes JSX processing.


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                import 'package:flutter/material.dart';

void main() {

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        visualDensity: VisualDensity.adaptivePlatformDensity,
      home: AnimatedIconWidget(),

class AnimatedIconWidget extends StatefulWidget {
  _AnimatedIconWidgetState createState() => _AnimatedIconWidgetState();

// 1. Define a Stateful Widget whose state mixins with SingleTickerProviderStateMixin.
class _AnimatedIconWidgetState extends State<AnimatedIconWidget>
    with SingleTickerProviderStateMixin {
  //2. Define an AnimationController inside state with animation duration and pass this into vsync.
  AnimationController controller;

  // 4. Define a variable that stores whether animation is at start or end.
  bool animationIsAtStart = true;

  void initState() {
    controller = AnimationController(
        vsync: this, duration: Duration(milliseconds: 1000));

  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("AnimatedIcon Demo"),
      body: Column(
        children: [
            child: AnimatedIcon(
              icon: AnimatedIcons.close_menu,

              // 3. Provide the controller  to AnimatedIcon.
              progress: controller,
              size: 190,
            child: ListView(
              children: [
      floatingActionButton: FloatingActionButton.extended(
          onPressed: () {
            setState(() {
              animationIsAtStart = !animationIsAtStart;
              //5. Animate  icon by calling `.forward()` or `.reverse()` on
              // AnimationController based on the current state of icon.
              animationIsAtStart ? controller.forward() : controller.reverse();
          icon: AnimatedIcon(
              icon: AnimatedIcons.play_pause, progress: controller),
          label: Text(animationIsAtStart ? "Play   " : "Pause")),