Skip to content

Instantly share code, notes, and snippets.

@sixtusagbo
Last active October 22, 2023 04:07
Show Gist options
  • Save sixtusagbo/959b2c4ff677e068f91c52b9ef5cd260 to your computer and use it in GitHub Desktop.
Save sixtusagbo/959b2c4ff677e068f91c52b9ef5cd260 to your computer and use it in GitHub Desktop.
Flutter ModalBottomSheet
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'FooBar',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
bottomSheetTheme: const BottomSheetThemeData(showDragHandle: true), // Added drag handle
),
home: const FooWidget(),
debugShowCheckedModeBanner: false,
);
}
}
class FooWidget extends StatelessWidget {
const FooWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text('FooBar'),
),
body: Center(
child: ElevatedButton(
onPressed: () => showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return SizedBox(
height: MediaQuery.of(context).size.height * .4,
child: const Center(child: Text('FooBar')),
);
},
),
child: const Text('Trigger Panel'),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment