flutter_foldable_kit ๐ฑ๐
๐ฎ๐ฉ Bahasa Indonesia | ๐ฌ๐ง English
๐ฎ๐ฉ Deskripsi (Indonesian)
Library Flutter siap pakai (plug-and-play) untuk mengembangkan aplikasi modern pada perangkat Foldable (Samsung Galaxy Z Fold, Google Pixel Fold), Flip (Galaxy Z Flip, Motorola Razr), Dual-Screen (Surface Duo), dan Tablet.
Tidak perlu lagi menghitung bounding box DisplayFeature atau menulis logika MediaQuery yang rumit secara manual. Cukup panggil widget dari library ini!
๐ฌ๐ง Description (English)
A plug-and-play Flutter library for building modern apps on Foldable (Samsung Galaxy Z Fold, Google Pixel Fold), Flip (Galaxy Z Flip, Motorola Razr), Dual-Screen (Surface Duo), and Tablet devices.
No more manually calculating DisplayFeature bounding boxes or writing complex MediaQuery logic. Just call the widgets from this library!
๐ Fitur Utama / Key Features
| Widget | ๐ฎ๐ฉ Deskripsi | ๐ฌ๐ง Description |
|---|---|---|
FoldableSplitView |
Layout dua panel otomatis di kedua sisi lipatan fisik. Fallback ke single pane pada layar kecil. | Automatic two-pane layout aligned to the physical hinge. Falls back to single pane on small screens. |
OnHingeChange |
Listener reaktif saat engsel ditekuk atau dibuka (Book Mode, Tabletop/Flex Mode, Flat). | Reactive listener when the hinge is bent or straightened (Book Mode, Tabletop/Flex Mode, Flat). |
FoldableTabView |
Tab navigation cerdas: Bottom Bar saat tertutup, Navigation Rail saat terbuka, Flex Control saat tabletop. | Smart tab navigation: Bottom Bar when folded, Navigation Rail when opened, Flex Control in tabletop mode. |
FoldableNavigationSplitView |
Pola Master-Detail: dua kolom di layar terbuka, stack push/pop di layar kecil. | Master-Detail pattern: two-column on wide screens, push/pop stack on compact screens. |
BuildContext Extensions |
context.isFoldable, context.isTabletop, context.isBookMode, context.hingeBounds, dll. |
context.isFoldable, context.isTabletop, context.isBookMode, context.hingeBounds, etc. |
๐ Instalasi / Installation
๐ฎ๐ฉ Tambahkan ke pubspec.yaml Anda:
๐ฌ๐ง Add to your pubspec.yaml:
dependencies:
flutter_foldable_kit: ^1.1.0
๐ฎ๐ฉ Lalu impor di file Dart Anda:
๐ฌ๐ง Then import in your Dart file:
import 'package:flutter_foldable_kit/flutter_foldable_kit.dart';
๐ Panduan Penggunaan / Usage Guide
1. BuildContext Extensions
๐ฎ๐ฉ Dapatkan status lipatan di widget mana saja tanpa boilerplate:
๐ฌ๐ง Access fold state anywhere in your widget tree without boilerplate:
Widget build(BuildContext context) {
if (context.isTabletop) {
// ๐ฎ๐ฉ Mode laptop/flex (Z Flip atau Z Fold ditekuk horizontal di atas meja)
// ๐ฌ๐ง Flex/tabletop mode (Z Flip or Z Fold bent horizontally on a table)
return buildTabletopLayout();
} else if (context.isBookMode) {
// ๐ฎ๐ฉ Mode buku (Z Fold dibuka vertikal)
// ๐ฌ๐ง Book mode (Z Fold opened vertically)
return buildBookModeLayout();
}
return buildStandardLayout();
}
๐ฎ๐ฉ Tersedia juga / ๐ฌ๐ง Also available:
context.isFoldable/context.hasHingeโ ๐ฎ๐ฉ Apakah perangkat memiliki lipatan aktif / ๐ฌ๐ง Whether device has an active fold.context.devicePostureโDevicePosture.flat,DevicePosture.halfOpened,DevicePosture.foldedcontext.hingeBoundsโ ๐ฎ๐ฉ Bounding box area engsel (Rect) / ๐ฌ๐ง Hinge area bounding box (Rect).context.hingeThicknessโ ๐ฎ๐ฉ Ketebalan lipatan fisik dalam pixel logika / ๐ฌ๐ง Physical hinge thickness in logical pixels.
2. FoldableSplitView
๐ฎ๐ฉ Membagi tampilan ke dua sisi engsel fisik secara presisi:
๐ฌ๐ง Splits the view across the physical hinge precisely:
FoldableSplitView(
startPane: ListView(
children: [
// ๐ฎ๐ฉ Daftar Produk / ๐ฌ๐ง Product List
Text('Items'),
],
),
endPane: Center(
// ๐ฎ๐ฉ Detail Produk / ๐ฌ๐ง Product Detail
child: Text('Detail'),
),
// ๐ฎ๐ฉ Rasio saat di layar tablet tanpa engsel (default: 0.4)
// ๐ฌ๐ง Ratio on tablet screen without hinge (default: 0.4)
ratio: 0.4,
)
3. OnHingeChange
๐ฎ๐ฉ Merespon secara instan saat pengguna menekuk atau meluruskan ponsel:
๐ฌ๐ง Responds instantly when the user bends or straightens the phone:
OnHingeChange(
onTabletopEnter: () {
// ๐ฎ๐ฉ Ponsel diletakkan di meja (Tabletop Mode)!
// ๐ฌ๐ง Phone placed on table (Tabletop Mode)!
print('Entered Tabletop Mode');
},
onTabletopExit: () {
print('Exited Tabletop Mode');
},
onPostureChange: (posture) {
// ๐ฎ๐ฉ Postur berubah / ๐ฌ๐ง Posture changed
print('Posture: $posture');
},
child: MyMainScreen(),
)
4. FoldableTabView
๐ฎ๐ฉ Secara cerdas berganti antara Bottom Navigation Bar, Navigation Rail, dan Flex Mode:
๐ฌ๐ง Intelligently switches between Bottom Navigation Bar, Navigation Rail, and Flex Mode:
FoldableTabView(
tabs: [
FoldableTabItem(
label: 'Home',
icon: Icon(Icons.home_outlined),
activeIcon: Icon(Icons.home),
content: HomeView(),
),
FoldableTabItem(
label: 'Chat',
icon: Icon(Icons.chat_bubble_outline),
activeIcon: Icon(Icons.chat_bubble),
content: ChatView(),
),
FoldableTabItem(
label: 'Profile / Profil',
icon: Icon(Icons.person_outline),
activeIcon: Icon(Icons.person),
content: ProfileView(),
),
],
)
5. FoldableNavigationSplitView
๐ฎ๐ฉ Menampilkan daftar dan detail berdampingan di layar besar, otomatis menjadi stack push/pop di layar kecil:
๐ฌ๐ง Shows list and detail side-by-side on large screens, automatically becomes push/pop stack on small screens:
FoldableNavigationSplitView<EmailItem>(
initialItem: sampleEmails.first,
masterBuilder: (context, selectedItem, onSelect) {
return ListView.builder(
itemCount: emails.length,
itemBuilder: (context, index) {
final email = emails[index];
return ListTile(
selected: selectedItem?.id == email.id,
title: Text(email.sender),
subtitle: Text(email.subject),
onTap: () => onSelect(email),
);
},
);
},
detailBuilder: (context, item, isSplitMode) {
return Scaffold(
appBar: AppBar(
title: Text(item.subject),
// ๐ฎ๐ฉ Tombol Back otomatis hanya muncul jika berada di layar single
// ๐ฌ๐ง Back button automatically shown only on single-screen mode
leading: isSplitMode ? null : const BackButton(),
),
body: EmailDetailView(email: item),
);
},
)
๐งช Pengujian / Testing
๐ฎ๐ฉ Jalankan test suite bawaan:
๐ฌ๐ง Run the built-in test suite:
flutter test
๐ฎ๐ฉ Semua komponen dilengkapi dengan unit test dan widget test untuk memastikan integritas layout di berbagai resolusi layar dan status engsel.
๐ฌ๐ง All components come with unit tests and widget tests to ensure layout integrity across various screen resolutions and hinge states.
๐ Lisensi / License
๐ฎ๐ฉ Dilisensikan di bawah MIT License.
๐ฌ๐ง Licensed under the MIT License.
๐ค Penghargaan & Pengakuan / Acknowledgements
Note
๐ฎ๐ฉ Ide, Konsep, & Visi Produk: Digagas oleh Ryansyah Putra.
๐ฎ๐ฉ Implementasi & Penulisan Kode: Dibangun dan dibantu sepenuhnya oleh AI Coding Assistant (Antigravity / Gemini).
Project ini dibuat berlandaskan ide untuk mempermudah ekosistem pengembang Flutter dalam mendukung perangkat foldable dan flip secara plug-and-play tanpa kerumitan kode boilerplate.
๐ฌ๐ง Product Idea, Concept & Vision: Conceived by Ryansyah Putra.
๐ฌ๐ง Implementation & Code Writing: Built and fully assisted by AI Coding Assistant (Antigravity / Gemini).
This project was created with the goal of simplifying the Flutter developer ecosystem to support foldable and flip devices in a plug-and-play fashion, without boilerplate code complexity.
Libraries
- flutter_foldable_kit
- A comprehensive, zero-boilerplate Flutter library for Foldable, Flip, and Dual-Screen devices.