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

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData.light().copyWith(
        primaryColor: Color(0xFF090C22),
        scaffoldBackgroundColor: Color(0xFF090C22),
        appBarTheme: AppBarTheme(
          color: Colors.red[900],
          textTheme: TextTheme(
            headline6: TextStyle(
              fontSize: 24.0,
              fontWeight: FontWeight.w500,
            ),
          ),
        ),
        textTheme: TextTheme(
          bodyText2: TextStyle(
            fontSize: 22.0,
            fontWeight: FontWeight.w600,
          ),
          subtitle1: TextStyle(
            fontSize: 20.0,
            fontWeight: FontWeight.w600,
          ),
        ),
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          'Movies',
        ),
      ),
      body: MovieListView(),
      // body: MovieScreen(),
    );
  }
}

class MovieListView extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        padding: EdgeInsets.all(20),
        children: <Widget>[
          MovieTile(movieName: 'The Godfather'),
          MovieTile(movieName: 'The Notebook'),
        ],
      ),
    );
  }
}

class MovieTile extends StatefulWidget {
  final String movieName;
  MovieTile({@required this.movieName});

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

class _MovieTileState extends State<MovieTile> {
  bool _isFavorite = false;
  void _toggleFavorite() {
    setState(() {
      _isFavorite = !_isFavorite;
    });
  }

  @override
  Widget build(BuildContext context) {
    return ListTile(
      title: Text(
        widget.movieName,
        style: (_isFavorite)
            ? TextStyle(color: Colors.white)
            : TextStyle(color: Colors.white38),
      ),
      trailing: FavoriteIcon(
        isFavorite: _isFavorite,
        onPressedHandler: _toggleFavorite,
      ),
    );
  }
}

class FavoriteIcon extends StatelessWidget {
  final bool isFavorite;
  final Function onPressedHandler;

  FavoriteIcon({
    @required this.isFavorite,
    @required this.onPressedHandler,
  });

  @override
  Widget build(BuildContext context) {
    return IconButton(
      icon: (isFavorite)
          ? Icon(
              Icons.favorite,
              color: Colors.red,
            )
          : Icon(
             Icons.favorite_border,
              color: Colors.red,
            ),
      onPressed: onPressedHandler,
    );
  }
}

              
            
!
999px

Console