forked from X-Wei/flutter_catalog
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:fluttertoast/fluttertoast.dart'; | ||
|
||
class BottomSheetExample extends StatefulWidget { | ||
const BottomSheetExample({Key key}) : super(key: key); | ||
|
||
@override | ||
_BottomSheetExampleState createState() => _BottomSheetExampleState(); | ||
} | ||
|
||
class _BottomSheetExampleState extends State<BottomSheetExample> { | ||
// GlobalKey is needed to show bottom sheet. | ||
final GlobalKey<ScaffoldState> _scaffoldKey = GlobalKey<ScaffoldState>(); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
key: this._scaffoldKey, | ||
body: Center( | ||
child: Column( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: <Widget>[ | ||
RaisedButton( | ||
child: Text('show bottom sheet'), | ||
onPressed: () => this | ||
._scaffoldKey | ||
.currentState | ||
.showBottomSheet((ctx) => _buildBottomSheet(ctx)), | ||
), | ||
RaisedButton( | ||
child: Text('show modal bottom sheet'), | ||
onPressed: () => showModalBottomSheet( | ||
context: context, builder: (ctx) => _buildBottomSheet(ctx)), | ||
), | ||
], | ||
), | ||
), | ||
floatingActionButton: FloatingActionButton( | ||
child: Icon(Icons.add), | ||
onPressed: () => | ||
Fluttertoast.showToast(msg: 'Dummy floating action button'), | ||
), | ||
); | ||
} | ||
|
||
Container _buildBottomSheet(BuildContext context) { | ||
return Container( | ||
height: 300, | ||
padding: EdgeInsets.all(8.0), | ||
decoration: BoxDecoration( | ||
border: Border.all(color: Colors.blue, width: 2.0), | ||
borderRadius: BorderRadius.circular(8.0), | ||
), | ||
child: ListView( | ||
children: <Widget>[ | ||
ListTile(title: Text('Bottom sheet')), | ||
TextField( | ||
keyboardType: TextInputType.number, | ||
decoration: InputDecoration( | ||
border: OutlineInputBorder(), | ||
icon: Icon(Icons.attach_money), | ||
labelText: 'Enter an integer', | ||
), | ||
), | ||
Container( | ||
alignment: Alignment.center, | ||
child: RaisedButton.icon( | ||
icon: Icon(Icons.save), | ||
label: Text('Save and close'), | ||
onPressed: () => Navigator.pop(context), | ||
), | ||
) | ||
], | ||
), | ||
); | ||
} | ||
} |