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

Auto Save

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 {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo AnimatedOpacity'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  //透明度を保持する
  double _opacity = 0.8;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text(widget.title)),
      floatingActionButton: FloatingActionButton(
        child: Text("B"),
        //ボタン押下時状態変化
        onPressed: () => _changeOpacity(),
      ),
      body: Stack(
        children: <Widget>[
          Center(
            child: Text(
              "Stack & Opacity",
              style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
            ),
          ),
          Center(
            child: AnimatedOpacity(
              //アニメーションする時間を1秒に設定
              duration: Duration(seconds: 1),
              //透明度を動的に設定
              opacity: _opacity,
              child: Container(
                width: 300,
                height: 100,
                color: Colors.green,
              ),
            ),
          ),
        ],
      ),
    );
  }

  _changeOpacity() {
    setState(() {
      if(_opacity == 0.0){
        _opacity = 0.8;
      }else{
        _opacity = 0.0;
      }
    });
  }
}

              
            
!
999px

Console