flutter_cupernino_bottom_sheet
フルスクリーンのCupertinoスタイルのボトムシートを模倣するパッケージ
- スター
- 10
- フォーク
- 3
- 最終プッシュ(UTC)
- 2024/10/14
- プロジェクト状態
- 公開中
元の README
以下は英語原文のスナップショットです。最新版は GitHub をご覧ください。
A package that mimics a Cupertino bottom sheet like this VERY EASILY
Unlike existing packages that can mimic the same behavior flutter_cupertino_bottom_sheet does not require a scaffold for this purpose and can be used from any place and any time. You don't have to use any special code except for wrapping your MaterialApp with CupertinoBottomSheetRepaintBoundary() at the beginning. And that's it. That simple. You don't even need a specific context for it to work
How it works.
It's very simple. Internally it uses a repaint boundary to create a screenshot of the whole screen and make a RawImage out of it. So it doesn't matter if the previous route maintains its state or not. It doesn't really need to know anything about the previous route as it uses a screenshot instead of a widget snapshot
Getting started
import the package where you initialize your app
import 'package:flutter_cupertino_bottom_sheet/flutter_cupertino_bottom_sheet.dart';
And then wrap your MaterialApp or whatever type you use with CupertinoBottomSheetRepaintBoundary
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return CupertinoBottomSheetRepaintBoundary(
child: MaterialApp(
...
),
);
}
}
This will provide a necessary RenderRepaintBoundary for the library to work.
Then you can use a Navigator to push this route like this:
Navigator.of(context).push(
CupertinoBottomSheetRoute(
args: const CupertinoBottomSheetRouteArgs(
swipeSettings: SwipeSettings(
canCloseBySwipe: true,
),
),
builder: (context) {
return const TestPage();
},
),
);
Want less code? No problem.
Pass a cupertinoBottomSheetNavigatorKey to your App initialization
@override
Widget build(BuildContext context) {
return CupertinoBottomSheetRepaintBoundary(
child: MaterialApp(
navigatorKey: cupertinoBottomSheetNavigatorKey,
...
),
);
}
And then call openCupertinoBottomSheet() from any place, regardless of context
openCupertinoBottomSheet(builder: (c) {
return const TestPage();
args: CupertinoBottomSheetRouteArgs(
appBar: CupertinoBottomSheetAppBar.withCloseButton(
title: 'Cupertino Actionsheet',
buttonText: 'Done',
headerStyle: Theme.of(context).textTheme.bodyMedium,
onClosePressed: Navigator.of(context).pop,
),
),
});
使用している依存関係
依存関係一覧 4 件
- flutter
{"sdk":"flutter"} - flutter_keyboard_visibility
^5.0.2 - flutter_test開発用
{"sdk":"flutter"} - flutter_lints開発用
^2.0.0
プロジェクトに合うリポジトリを選ぶには?
用途で絞り込み、開発状況を比較し、採用前に元のリポジトリで要件を確認しましょう。
- 名前・作者・説明で検索し、技術トピックで絞り込みます。
- スター、フォーク、最近のプッシュを比較します。スターは関心の目安であり、品質の保証ではありません。
- 利用前に GitHub で README、ライセンス、Issues を確認します。
情報源と管理
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗
