Skip to content

Instantly share code, notes, and snippets.

View shafayathossain's full-sized avatar

Shafayat Hossain shafayathossain

  • Dhaka, Bangladesh
View GitHub Profile
@shafayathossain
shafayathossain / flutter_3.35_preview_function_5.dart
Last active October 20, 2025 22:54
Flutter Preview - Preview Function
@Preview(
name: 'Simple Widget',
size: Size(401, 200),
localizations: arabicLocalizations,
wrapper: materialAppWrapper,
textScaleFactor: 4.0 // <-- 5. Adjust text scale factor
)
Widget previewSimpleWidget() {
return Builder(
builder: (context) {
@shafayathossain
shafayathossain / flutter_3.35_preview_function_4.dart
Last active October 20, 2025 22:54
Flutter Preview - Preview Function
@Preview(
name: 'Simple Widget',
size: Size(401, 200),
localizations: arabicLocalizations, // <-- 4.1. Use proper preview localization data
wrapper: materialAppWrapper,
)
Widget previewSimpleWidget() {
return Builder(
builder: (context) {
final localizations = AppLocalizations.of(context)!;
Widget materialAppWrapper(Widget child) {
return Builder( // <-- Wrap with Builder
builder: (context) {
final locale = Localizations.maybeLocaleOf(context); // <-- Access localizations
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
@shafayathossain
shafayathossain / flutter_3.35_preview_arabic_localization_data.dart
Created October 20, 2025 13:46
Flutter Preview - Preview Localization Data Function
PreviewLocalizationsData arabicLocalizations() {
return PreviewLocalizationsData(
locale: Locale('ar', 'SA'),
supportedLocales: [Locale('ar', 'SA')],
localizationsDelegates: [
AppLocalizations.delegate,
],
);
}
@shafayathossain
shafayathossain / flutter_3.35_preview_function_3.dart
Last active October 20, 2025 13:38
Flutter Preview - Preview Function
@Preview(
name: 'Simple Widget',
size: Size(401, 300),
wrapper: materialAppWrapper, // <---- 3. Add widget wrapper
)
Widget previewSimpleWidget() {
return Center(
child: SimpleWidget(
text: "Settings",
icon: Icons.settings,
@shafayathossain
shafayathossain / flutter_3.35_preview_material_app_function.dart
Last active October 20, 2025 13:37
Flutter Preview - Preview Material App Wrapper Function
Widget materialAppWrapper(Widget child) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.deepPurple,
brightness: Brightness.dark,
@shafayathossain
shafayathossain / flutter_3.35_preview_function_2.dart
Last active October 20, 2025 14:17
Flutter Preview - Preview Function
@Preview(
name: 'Simple Widget',
size: Size(401, 300) // <-- 2. Pass size
)
Widget previewSimpleWidget() {
return Center(
child: SimpleWidget(
text: "Settings",
icon: Icons.settings,
),
@shafayathossain
shafayathossain / flutter_3.35_preview_function_1.dart
Created October 20, 2025 13:19
Flutter Preview - Preview Function
@Preview(
name: 'Simple Widget',
)
Widget previewSimpleWidget() {
return Center(
child: SimpleWidget(
text: "Settings",
icon: Icons.settings,
),
);
@shafayathossain
shafayathossain / flutter_3.35_preview_example_widget.dart
Created October 20, 2025 13:10
Flutter Preview - Example Widget
class SimpleWidget extends StatelessWidget {
final String text;
final IconData icon;
const SimpleWidget({
super.key,
required this.text,
required this.icon,
});