fab_speed_dial 0.0.8 fab_speed_dial: ^0.0.8 copied to clipboard
Speed dail FAB
example/lib/main.dart
import 'package:fab_speed_dial/speed_dial_options.dart';
import 'package:flutter/material.dart';
import 'package:fab_speed_dial/fab_speed_dial.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool _isFabOpen = false;
void _toggleFab() {
setState(() {
_isFabOpen = !_isFabOpen;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('FabSpeedDial Example'),
),
body: Center(
child: Text('Press the button to open the speed dial.'),
),
floatingActionButton: Expanded(
child: FabSpeedDial(
children: [
SpeedDialOption(
onPressed: () {
// Handle first action
},
icon: Icon(Icons.message),
text: Text("Hello"),
),
SpeedDialOption(
onPressed: () {
// Handle second action
},
icon: Icon(Icons.message),
text: Text("Hello"),
),
],
closedForegroundColor: Colors.white,
openedForegroundColor: Colors.white,
closedBackgroundColor: Colors.blue,
openedBackgroundColor: Colors.black,
closedElevation: 0,
openedElevation: 0,
visible: true,
isDialVisible: _isFabOpen,
toggleDial: _toggleFab,
),
)
);
}
}