Skip to content

Instantly share code, notes, and snippets.

@matuella
Created May 31, 2021 15:06
Show Gist options
  • Save matuella/6b57991e4c09a7116a033bca79542476 to your computer and use it in GitHub Desktop.
Save matuella/6b57991e4c09a7116a033bca79542476 to your computer and use it in GitHub Desktop.
`Scaffold.bottomSheet` issues
import 'package:flutter/material.dart';
void main() => runApp(BottomSheetApp());
class BottomSheetApp extends StatefulWidget {
@override
_BottomSheetAppState createState() => _BottomSheetAppState();
}
class _BottomSheetAppState extends State<BottomSheetApp> {
bool showsSheet = false;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: ElevatedButton(
child: Text('Toggle sheet'),
onPressed: () => setState(() => showsSheet = !showsSheet),
),
),
bottomSheet: showsSheet ? Container(color: Colors.blue) : null,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment