Skip to content

Instantly share code, notes, and snippets.

@abhaysood
Created February 11, 2022 06:11
Show Gist options
  • Save abhaysood/c226da8e6289e861617a844045814cbc to your computer and use it in GitHub Desktop.
Save abhaysood/c226da8e6289e861617a844045814cbc to your computer and use it in GitHub Desktop.
Draggable scrollable sheet with static content on bottom
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: MyApp._title,
home: Scaffold(
appBar: AppBar(title: const Text(MyApp._title)),
body: Builder(builder: (context) {
return Stack(
children: [
Container(
color: Colors.blueGrey,
child: Center(
child: Text("Content behind card"),
),
),
DraggableScrollableSheet(
initialChildSize: 0.25,
maxChildSize: 0.75,
minChildSize: 0.25,
snap: true,
builder: (context, scrollController) {
return Container(
color: Colors.white,
child: SingleChildScrollView(
controller: scrollController,
child: Center(
child: Text("Scrollable card"),
),
),
);
},
),
Align(
alignment: Alignment.bottomCenter,
child: Container(
height: 56,
color: Colors.green,
child: Center(child: Text("Button")),
),
)
],
);
}),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment