xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Floating Action Button Position'),
),
body: Center(
child: Text('Content'),
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
child: Icon(Icons.add),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
),
);
}
}
xxxxxxxxxx
Scaffold(
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your onPressed code here!
},
child: const Icon(Icons.navigation),
),
//BUTTON LOCATION
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
);
xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Floating Button Example'),
),
body: Center(
child: Text(
'Floating Button Example',
style: TextStyle(fontSize: 20),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Perform some action when the button is pressed
print('Floating button pressed!');
},
child: Icon(Icons.add),
),
),
);
}
}
xxxxxxxxxx
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: Text('Floating Action Button Demo')),
body: Center(child: Text('Tap the FAB!')),
floatingActionButton: FloatingActionButton(
onPressed: () {
// Add your desired functionality here
print('Floating Action Button pressed');
},
child: Icon(Icons.add),
),
),
);
}
}