import
'package:flutter/material.dart'
;
void
main() {
runApp(
const
MyApp());
}
class
MyApp extends StatelessWidget {
const
MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return
MaterialApp(
debugShowCheckedModeBanner:
false
,
title:
'Flutter Demo'
,
theme: ThemeData(
primarySwatch: Colors.green,
),
home:
const
HomePage(),
);
}
}
class
HomePage extends StatefulWidget {
const
HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class
_HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
title:
const
Text(
"Bottom Sheet"
),
),
body: Center(
child: Container(
child:
const
Text(
"Hello"
),
),
),
floatingActionButton: FloatingActionButton(
child:
const
Icon(Icons.add, color: Colors.white),
onPressed: () {
showModalBottomSheet(
context: context,
builder: (context) {
return
SingleChildScrollView(
child: Container(
padding: EdgeInsets.only(
bottom: MediaQuery.of(context).viewInsets.bottom),
child: Container(
padding:
const
EdgeInsets.all(20),
decoration:
const
BoxDecoration(
borderRadius: BorderRadius.only(
topRight: Radius.circular(20),
topLeft: Radius.circular(20),
),
),
child: Column(
children: [
const
Text(
"Add Data"
,
style: TextStyle(
fontWeight: FontWeight.w600,
color: Colors.green,
fontSize: 20),
),
const
SizedBox(height: 10.0),
const
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.green),
),
hintText:
"Add Item"
,
hintStyle: TextStyle(color: Colors.grey),
),
),
const
SizedBox(height: 10),
ElevatedButton(
onPressed: null,
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.red),
textStyle: MaterialStateProperty.all(
const
TextStyle(fontSize: 30))),
child:
const
Text(
"Add"
),
)
],
),
),
),
);
});
},
),
);
}
}