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';
import 'package:flutter/gestures.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('TapGestureRecognizer 手势识别(拖曳)'),
),
body: GestureRecognizerPage(),
),
);
}
}
class GestureRecognizerPage extends StatefulWidget {
@override
_GestureRecognizerPageState createState() => _GestureRecognizerPageState();
}
class _GestureRecognizerPageState extends State<GestureRecognizerPage> {
TapGestureRecognizer recognizer = TapGestureRecognizer();
bool toggle = true;
@override
Widget build(BuildContext context) {
return Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('点击文字放大'),
Text.rich(
TextSpan(
text: '你好',
style: TextStyle(
fontSize: toggle ? 16 : 40,
),
recognizer: recognizer
..onTap = () {
setState(() {
toggle = !toggle;
});
}),
),
],
),
);
}
}
Also see: Tab Triggers