This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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)!; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| PreviewLocalizationsData arabicLocalizations() { | |
| return PreviewLocalizationsData( | |
| locale: Locale('ar', 'SA'), | |
| supportedLocales: [Locale('ar', 'SA')], | |
| localizationsDelegates: [ | |
| AppLocalizations.delegate, | |
| ], | |
| ); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Preview( | |
| name: 'Simple Widget', | |
| size: Size(401, 300) // <-- 2. Pass size | |
| ) | |
| Widget previewSimpleWidget() { | |
| return Center( | |
| child: SimpleWidget( | |
| text: "Settings", | |
| icon: Icons.settings, | |
| ), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Preview( | |
| name: 'Simple Widget', | |
| ) | |
| Widget previewSimpleWidget() { | |
| return Center( | |
| child: SimpleWidget( | |
| text: "Settings", | |
| icon: Icons.settings, | |
| ), | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class SimpleWidget extends StatelessWidget { | |
| final String text; | |
| final IconData icon; | |
| const SimpleWidget({ | |
| super.key, | |
| required this.text, | |
| required this.icon, | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Your Website Title</title> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <script type="text/javascript"> | |
| window.onload = function() { | |
| var isAndroid = /android/i.test(navigator.userAgent); | |
| var isiOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; | |
| if (isAndroid) { |
NewerOlder