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 {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('事件通知'),
        ),
        body: NotificationListenerPage(),
      ),
    );
  }
}

class NotificationListenerPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // 监听滚动通知
    return NotificationListener(
      // ignore: missing_return
      onNotification: (notification) {
        switch (notification.runtimeType) {
          case ScrollStartNotification:
            print('ScrollStart');
            break;
          case ScrollUpdateNotification:
            print('ScrollUpdate');
            break;
          case ScrollEndNotification:
            print('ScrollEnd');
            break;
          case OverscrollNotification:
            print('Overscroll');
            break;
        }
      },
      child: ListView.builder(
        itemCount: 100,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text("$index"),
          );
        },
      ),
    );
  }
}

              
            
!
999px

Console