sheet 0.0.1 sheet: ^0.0.1 copied to clipboard
A new Flutter package project.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sheet/sheet.dart';
import 'examples/complex_snap_sheet.dart';
import 'examples/snap_sheet copy.dart';
import 'examples/snap_sheet.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('SnapSheet without route'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => SnapSheetPageExample(),
),
),
),
ListTile(
title: const Text('SnapSheet half route'),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => HalfSheetPageExample(),
),
),
),
ListTile(
title: const Text('Advanced SnapSheet without route '),
onTap: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) => AdvancedSnapSheetPageExample(),
),
),
),
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],
);
}