JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
Using packages here is powered by Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
import 'package:flutter/material.dart';
void main() {
runApp(ScrollNotificationPage());
}
class ScrollNotificationPage extends StatefulWidget {
@override
_ScrollNotificationPageState createState() => _ScrollNotificationPageState();
}
class _ScrollNotificationPageState extends State<ScrollNotificationPage> {
String _progress = "0%";
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('ScrollNotification 组件'),
),
body: Scrollbar(
child: NotificationListener<ScrollNotification>(
onNotification: (ScrollNotification notification) {
double progress = notification.metrics.pixels /
notification.metrics.maxScrollExtent;
setState(() {
_progress = "${(progress * 100).toInt()}%";
});
// 返回true,表示通知被拦截,不再向上传递
return true;
},
child: Stack(
alignment: Alignment.center,
children: [
ListView.builder(
itemCount: 100,
// itemExtent: 50,
itemBuilder: (context, index) {
return ListTile(title: Text("标题 $index"));
},
),
CircleAvatar(
radius: 30.0,
child: Text(_progress),
backgroundColor: Colors.black54,
),
],
),
),
),
),
);
}
}
Also see: Tab Triggers