Skip to content

Instantly share code, notes, and snippets.

@vyachin
Created October 27, 2021 21:33
Show Gist options
  • Save vyachin/3d250c5b935ed605e03d8dc520ad539d to your computer and use it in GitHub Desktop.
Save vyachin/3d250c5b935ed605e03d8dc520ad539d to your computer and use it in GitHub Desktop.
flutter bottom sheet
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,
);
},
),
),
],
);
},
),
),
),
);
}
@vyachin
Copy link
Author

vyachin commented Oct 27, 2021

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment