Created
October 27, 2021 21:33
-
-
Save vyachin/3d250c5b935ed605e03d8dc520ad539d to your computer and use it in GitHub Desktop.
flutter bottom sheet
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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp( | |
MaterialApp( | |
home: Scaffold( | |
body: Builder( | |
builder: (BuildContext context) { | |
final size = MediaQuery.of(context).size; | |
return Stack( | |
children: [ | |
Image.network( | |
'https://source.unsplash.com/random', | |
width: size.width, | |
height: size.height, | |
fit: BoxFit.cover, | |
), | |
Center( | |
child: ElevatedButton( | |
child: const Text('showBottomSheet'), | |
onPressed: () { | |
Scaffold.of(context).showBottomSheet<void>( | |
(_) => Container( | |
margin: const EdgeInsets.all(20), | |
height: size.height * 0.4, | |
width: size.width, | |
decoration: const BoxDecoration( | |
borderRadius: BorderRadius.all(Radius.circular(32)), | |
color: Colors.white, | |
), | |
child: const Center(child: Text("Hi modal sheet")), | |
), | |
backgroundColor: Colors.transparent, | |
); | |
}, | |
), | |
), | |
], | |
); | |
}, | |
), | |
), | |
), | |
); | |
} |
Author
vyachin
commented
Oct 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment