Skip to content

Instantly share code, notes, and snippets.

@omenejoseph
Created January 2, 2020 18:12
Show Gist options
  • Save omenejoseph/91c9c749d8e992f0d08bcbcb6dff2e29 to your computer and use it in GitHub Desktop.
Save omenejoseph/91c9c749d8e992f0d08bcbcb6dff2e29 to your computer and use it in GitHub Desktop.
main dart file
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(title: const Text('Modal bottom sheet')),
body: new Center(
child: new RaisedButton(
child: const Text('SHOW BOTTOM SHEET'),
onPressed: () {
showModalBottomSheet<void>(context: context, builder: (BuildContext context) {
return new Container(
child: new Padding(
padding: const EdgeInsets.all(32.0),
child: new Text('This is the modal bottom sheet. Click anywhere to dismiss.',
textAlign: TextAlign.center,
style: new TextStyle(
color: Theme.of(context).accentColor,
fontSize: 24.0
)
)
)
);
});
}
)
)
)
);
}
}
@pratikpwr
Copy link

@omenejoseph I think you are right

@bjavier9
Copy link

hi, The showModalBottomSheet should not have the same context as the materialapp, so it must be separated in a statelesswidget as you can see in this example. https://gist.github.com/bjavier9/1ac85432cae7531376cdad90492b58cf

@shrikantpardhi
Copy link

I find the problem with new version.

hi, The showModalBottomSheet should not have the same context as the materialapp, so it must be separated in a statelesswidget as you can see in this example. https://gist.github.com/bjavier9/1ac85432cae7531376cdad90492b58cf

Page not Found!

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