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';
import 'dart:math';

void main() {
  runApp(
    MaterialApp(
      home: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        brightness: Brightness.dark,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int data = 0;
  int count = 12;

  @override
  void initState() {
    super.initState();
    fetchData();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Last $count Post'),
      ),
      body: RefreshIndicator(
        onRefresh: fetchData,
        child: data == 0
            ? LinearProgressIndicator()
            : ListView.builder(
                itemCount: count,
                itemBuilder: (context, index) {
                  return ListTile(title: Text('Post ID ${data - index}'));
                },
              ),
      ),
    );
  }

  Future<void> fetchData() async {
    int last = data;
    data = 0;

    setState(() {});
    Future.delayed(Duration(seconds: 3), () {
      data = last + count + (Random().nextInt(count));
      setState(() {});
    });
  }
}

              
            
!
999px

Console