Complete reference of all supported widgets in FlutterJS.
Note
FlutterJS implements the most commonly used Flutter widgets. More widgets are being added regularly.
Tip
Want to know how these widgets render to HTML? Check out the VDOM Rendering Architecture.
A versatile widget for styling and positioning.
Container(
color: Colors.blue,
padding: EdgeInsets.all(16.0),
margin: EdgeInsets.symmetric(vertical: 8.0),
width: 200,
height: 100,
child: Text('Hello FlutterJS'),
)Properties:
child— Single child widgetcolor— Background colorpadding— Internal spacingmargin— External spacingwidth,height— Dimensionsdecoration— BoxDecoration for advanced stylingalignment— Child alignment
Centers its child widget.
Center(
child: Text('Centered Text'),
)Adds padding around a child.
Padding(
padding: EdgeInsets.all(16.0),
child: Text('Padded Text'),
)A box with a specified size.
SizedBox(
width: 100,
height: 50,
child: ElevatedButton(
onPressed: () {},
child: Text('Button'),
),
)Arranges children horizontally.
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(Icons.star),
Text('Rating'),
Text('4.5'),
],
)Properties:
mainAxisAlignment— Horizontal alignmentcrossAxisAlignment— Vertical alignmentmainAxisSize—maxorminchildren— List of widgets
Arranges children vertically.
Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Title'),
Text('Subtitle'),
ElevatedButton(
onPressed: () {},
child: Text('Action'),
),
],
)Expands a child to fill available space in a Row or Column.
Row(
children: [
Text('Left'),
Expanded(
child: Text('Fills remaining space'),
),
Text('Right'),
],
)A more flexible version of Expanded with custom flex factor.
Row(
children: [
Flexible(
flex: 2,
child: Container(color: Colors.red, height: 100),
),
Flexible(
flex: 1,
child: Container(color: Colors.blue, height: 100),
),
],
)Creates flexible empty space.
Row(
children: [
Text('Left'),
Spacer(),
Text('Right'),
],
)Overlays widgets on top of each other.
Stack(
children: [
Container(width: 300, height: 300, color: Colors.blue),
Positioned(
top: 50,
left: 50,
child: Container(width: 100, height: 100, color: Colors.red),
),
],
)Positions a child within a Stack.
Positioned(
top: 10,
right: 10,
child: Icon(Icons.close),
)The basic structure for a Material Design page.
Scaffold(
appBar: AppBar(
title: Text('My App'),
),
body: Center(
child: Text('Content'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
)Properties:
appBar— AppBar widgetbody— Main contentfloatingActionButton— FAB widgetdrawer— Side navigation drawer (planned)bottomNavigationBar— Bottom nav bar (planned)
Application header bar.
AppBar(
title: Text('Page Title'),
backgroundColor: Colors.blue,
leading: IconButton(
icon: Icon(Icons.menu),
onPressed: () {},
),
actions: [
IconButton(
icon: Icon(Icons.search),
onPressed: () {},
),
],
)Material Design card.
Card(
elevation: 4.0,
margin: EdgeInsets.all(8.0),
child: Padding(
padding: EdgeInsets.all(16.0),
child: Text('Card Content'),
),
)A horizontal line divider.
Divider(
height: 1,
color: Colors.grey,
)Filled Material Design button.
ElevatedButton(
onPressed: () {
print('Button pressed');
},
child: Text('Click Me'),
)Flat Material Design button.
TextButton(
onPressed: () {},
child: Text('Text Button'),
)Button with an icon, no background.
IconButton(
icon: Icon(Icons.favorite),
onPressed: () {},
tooltip: 'Like',
)Circular floating action button.
FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
backgroundColor: Colors.blue,
)Displays text.
Text(
'Hello World',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
textAlign: TextAlign.center,
maxLines: 2,
overflow: TextOverflow.ellipsis,
)Displays a Material Design icon.
Icon(
Icons.star,
size: 48,
color: Colors.yellow,
)Available Icons:
Icons.add,Icons.removeIcons.home,Icons.settings,Icons.menuIcons.favorite,Icons.starIcons.search,Icons.close- And many more from Material Icons
Displays an image.
// Network image
Image.network(
'https://example.com/image.jpg',
width: 200,
height: 200,
)
// Asset image
Image.asset(
'assets/logo.png',
width: 100,
height: 100,
)Text input field.
TextField(
decoration: InputDecoration(
labelText: 'Enter your name',
hintText: 'John Doe',
border: OutlineInputBorder(),
),
onChanged: (value) {
print('Input: $value');
},
)Boolean checkbox input.
Checkbox(
value: isChecked,
onChanged: (bool? value) {
setState(() {
isChecked = value ?? false;
});
},
)Boolean switch toggle.
Switch(
value: isSwitched,
onChanged: (bool value) {
setState(() {
isSwitched = value;
});
},
)Manages app navigation. See Routing & Navigation Guide for details.
// Push new route
Navigator.push(
context,
MaterialPageRoute(builder: (context) => SecondScreen()),
);
// Pop route
Navigator.pop(context);Defines a route with Material Design transition.
MaterialPageRoute(
builder: (context) => MyScreen(),
)Detects various gestures.
GestureDetector(
onTap: () {
print('Tapped');
},
onDoubleTap: () {
print('Double tapped');
},
child: Container(
width: 100,
height: 100,
color: Colors.blue,
),
)Scrollable list of widgets.
ListView(
children: [
ListTile(title: Text('Item 1')),
ListTile(title: Text('Item 2')),
ListTile(title: Text('Item 3')),
],
)Efficiently builds long lists.
ListView.builder(
itemCount: 100,
itemBuilder: (context, index) {
return ListTile(
title: Text('Item $index'),
);
},
)Padding/margin values.
EdgeInsets.all(16.0) // All sides
EdgeInsets.symmetric(horizontal: 16.0) // Left & right
EdgeInsets.symmetric(vertical: 8.0) // Top & bottom
EdgeInsets.only(left: 8.0, top: 16.0) // Specific sidesAdvanced container styling.
BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(8.0),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4.0,
offset: Offset(0, 2),
),
],
)Warning
Not all Flutter widgets are supported yet. Focus is on commonly used widgets.
Planned additions:
ListView.separatedGridViewDrawerBottomNavigationBarTabBar/TabBarViewAlertDialogSnackBar
See the GitHub Issues for the latest widget roadmap.
- Learn State Management
- Explore Routing & Navigation
- Check out Examples