sheet 0.0.3 sheet: ^0.0.3 copied to clipboard
A new Flutter package project.
import 'package:example/examples/bouncing_sheet.dart';
import 'package:example/examples/fit_resizable_sheet.dart';
import 'package:example/examples/fit_sheet.dart';
import 'package:example/examples/resizable_sheet.dart';
import 'package:example/examples/scrollable_sheet.dart';
import 'package:example/examples/simple_sheet.dart';
import 'package:example/examples/snap_sheet.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sheet/sheet.dart';
import 'examples/clamped_sheet.dart';
import 'examples/complex_snap_sheet.dart';
import 'examples/fit_sheet_snap.dart';
import 'examples/sheet_without_momentum.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS),
title: 'BottomSheet Modals',
home: MyHomePage(title: 'Flutter Demo Home Page'),
debugShowCheckedModeBanner: false,
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Material(
child: Scaffold(
body: CupertinoPageScaffold(
backgroundColor: Colors.white,
child: SizedBox.expand(
child: SingleChildScrollView(
primary: true,
child: SafeArea(
bottom: false,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
const SectionTitle('SHEET'),
ListTile(
title: const Text('Simple sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => SimpleSheetPage(),
),
),
),
ListTile(
title: const Text('Snap sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => SnapSheet(),
),
),
),
ListTile(
title: const Text('Fit sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => FitSheet(),
),
),
),
ListTile(
title: const Text('Clamped sheet (min and max extent)'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => ClampedSheetPage(),
),
),
),
ListTile(
title: const Text('Sheet with Bouncing at top'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => BouncingSheetPage(),
),
),
),
ListTile(
title: const Text('Fit Snap sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => FitSnapSheet(),
),
),
),
ListTile(
title: const Text('Resizable sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => ResizableSheetExample(),
),
),
),
ListTile(
title: const Text('Fit Resizable Bouncing sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => FitResizableSheet(),
),
),
),
ListTile(
title: const Text('Scrollabe Sheet'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => ScrollableSheet(),
),
),
),
ListTile(
title: const Text('Advanced SnapSheet '),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => AdvancedSnapSheetPageExample(),
),
),
),
ListTile(
title: const Text('Sheet without momemtum'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => NoMomentumSheet(),
),
),
),
SizedBox(height: 60)
],
),
),
),
),
navigationBar: CupertinoNavigationBar(
transitionBetweenRoutes: false,
middle: Text('Sheets'),
),
),
),
);
}
}
class SectionTitle extends StatelessWidget {
final String title;
// ignore: sort_constructors_first
const SectionTitle(
this.title, {
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.fromLTRB(16, 20, 16, 8),
child: Text(
title,
style: Theme.of(context).textTheme.caption,
),
);
}
}
extension ListUtils<T> on List<T> {
List<T> addItemInBetween(T item) => length <= 1
? this
: sublist(1).fold(
<T>[first],
(r, element) => [...r, item, element],
);
}