Pen Settings

JavaScript

Babel includes JSX processing.

Packages

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.

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 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Home(),
    );
  }
}

class Home extends StatefulWidget {
  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
  bool _withAnimation = true;
  bool _isExtended = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Switch Fab sample'),
      ),
      body: Center(
        child: Column(
          children: [
            SwitchListTile.adaptive(
              title: Text('With animation'),
              value: _withAnimation,
              onChanged: (bool value) {
                setState(() {
                  _withAnimation = value;
                });
              },
            ),
            ElevatedButton(
              child: Text('Change Fab style!'),
              onPressed: () {
                setState(() {
                  _isExtended = !_isExtended;
                });
              },
            ),
          ],
        ),
      ),
      floatingActionButton: _withAnimation
          ? _buildFabWithAnimation()
          : _buildFabWithoutAnimation(),
    );
  }

  Widget _buildFabWithAnimation() {
    return FloatingActionButton.extended(
      onPressed: () {},
      label: AnimatedSwitcher(
        duration: Duration(milliseconds: 200),
        transitionBuilder: (Widget child, Animation<double> animation) =>
            FadeTransition(
          opacity: animation,
          child: SizeTransition(
            child: child,
            sizeFactor: animation,
            axis: Axis.horizontal,
          ),
        ),
        child: !_isExtended
            ? Icon(Icons.add)
            : Row(
                children: [
                  Padding(
                    padding: const EdgeInsets.only(right: 4.0),
                    child: Icon(Icons.add),
                  ),
                  Text("Add")
                ],
              ),
      ),
    );
  }

  Widget _buildFabWithoutAnimation() {
    return FloatingActionButton.extended(
      onPressed: () {},
      label: Text('Add'),
      icon: Icon(Icons.add),
      isExtended: _isExtended,
    );
  }
}

              
            
!
999px

Console