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 esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM 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(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Basic Properties'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
// 表示位置番号
int index = 0;
// 表示位置リスト
List<FloatingActionButtonLocation> _locations = [
FloatingActionButtonLocation.centerDocked,
FloatingActionButtonLocation.endDocked,
FloatingActionButtonLocation.endFloat,
FloatingActionButtonLocation.centerFloat,
FloatingActionButtonLocation.startFloat,
FloatingActionButtonLocation.startDocked,
];
// 表示位置
FloatingActionButtonLocation _location = FloatingActionButtonLocation.centerDocked;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Text(widget.title)
),
floatingActionButton: FloatingActionButton(
// ボタン内に表示するウィジェット
child: Text("B"),
// ボタン色
backgroundColor: Colors.blueAccent,
// ホバー時のボタン色
hoverColor: Colors.red,
// 機能説明
tooltip: "表示位置変更",
// ボタン押下時実行関数
onPressed: () => _changePosition(),
),
bottomNavigationBar: BottomAppBar(
color: Colors.yellow,
child: Container(height: 50.0,),
),
floatingActionButtonLocation: _location,
);
}
void _changePosition() {
setState(() {
index++;
if(index >= _locations.length){
index = 0;
}
_location = _locations[index];
});
}
}
Also see: Tab Triggers