floatingActionButton
MaterialApp({ title,theme, home: Scaffold({ appBar, body, floatingActionButton, floatingActionButtonLocation, floatingActionButtonAnimator, persistentFooterButtons, drawer, endDrawer, bottomNavigationBar, bottomSheet, backgroundColor, resizeToAvoidBottomPadding, resizeToAvoidBottomInset }), })
açıklama
Ekranda yüzen bir buton oluşturur.
konum
MaterialApp({ title,theme, home: Scaffold({ appBar, body, floatingActionButton,...}), })
parametreler
MaterialApp({
title,
theme,
home: Scaffold({
appBar,
body,
floatingActionButton,
floatingActionButtonLocation,
floatingActionButtonAnimator,
persistentFooterButtons,
drawer,
endDrawer,
bottomNavigationBar,
bottomSheet,
backgroundColor,
resizeToAvoidBottomPadding,
resizeToAvoidBottomInset..
}),
})
örnek uygulama

import 'package:flutter/material.dart';
void main() =>
runApp(MaterialApp(title: "FloatingButton", home: MainActivity()));
class MainActivity extends StatefulWidget {
@override
_MainActivityState createState() => _MainActivityState();
}
class _MainActivityState extends State<MainActivity> {
String msg = 'Flutter FloatingButton Example';
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.yellow,
appBar: AppBar(
title: Text('Floating Button'),
),
body: bodyWidget(),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.refresh),
onPressed: _changeText,
backgroundColor: Colors.red,
foregroundColor: Colors.black,
),
);
}
bodyWidget() {
return Container(
child: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
msg,
style: TextStyle(fontSize: 20, fontStyle: FontStyle.italic),
),
],
),
),
);
}
_changeText() {
setState(() {
if (msg.startsWith('F')) {
msg = 'I have learned FloatingButton';
} else {
msg = 'Flutter FloatingButton Example';
}
});
}
}