draggable_home 1.0.2 draggable_home: ^1.0.2 copied to clipboard
Draggable is a library for adding a beautiful draggable home page
import 'package:draggable_home/draggable_home.dart';
import 'package:flutter/material.dart';
import 'camera_preview.dart';
void main() => runApp(
MyApp(),
);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: "Draggable Home",
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return DraggableHome(
leading: Icon(Icons.arrow_back_ios),
title: Text("Draggable Home"),
actions: [
IconButton(onPressed: () {}, icon: Icon(Icons.settings)),
],
headerWidget: headerWidget(context),
headerBottomBar: headerBottomBarWidget(),
body: [
listView(),
],
fullyStretchable: true,
expandedBody: CameraPreview(),
);
}
Container headerBottomBarWidget() {
return Container(
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Icon(
Icons.settings,
color: Colors.white,
),
],
),
);
}
Container headerWidget(BuildContext context) => Container(
child: Center(
child: Text("Title",
style: Theme.of(context)
.textTheme
.headline2!
.copyWith(color: Colors.white70)),
),
);
ListView listView() {
return ListView.builder(
padding: EdgeInsets.only(top: 0),
physics: NeverScrollableScrollPhysics(),
itemCount: 20,
shrinkWrap: true,
itemBuilder: (context, index) => Card(
color: Colors.white70,
child: ListTile(
leading: CircleAvatar(
child: Text("$index"),
),
title: Text("Title"),
subtitle: Text("Subtitile"),
),
),
);
}
}