feat: add device preview package to the example app

With Device Preview it is easy to view the userstory on different kinds of devices and change settings like language
This commit is contained in:
Freek van de Ven 2024-07-05 13:59:40 +02:00 committed by Joey Boerwinkel
parent 31aa3e8bd5
commit 637b614654
3 changed files with 21 additions and 2 deletions

View file

@ -1,8 +1,19 @@
import "package:device_preview/device_preview.dart";
import "package:flutter/material.dart";
import "package:flutter_availability/flutter_availability.dart";
void main() {
runApp(const App());
runApp(
DevicePreview(
enabled: true,
isToolbarVisible: true,
availableLocales: const [
Locale("en_US"),
Locale("nl_NL"),
],
builder: (_) => const App(),
),
);
}
class App extends StatelessWidget {
@ -10,6 +21,14 @@ class App extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
builder: DevicePreview.appBuilder,
locale: DevicePreview.locale(context),
supportedLocales: const [
Locale("en", "US"),
Locale("nl", "NL"),
],
theme: ThemeData.light(),
darkTheme: ThemeData.dark(),
home: AvailabilityUserStory(
userId: "",
options: AvailabilityOptions(),

View file

@ -9,6 +9,7 @@ environment:
dependencies:
flutter:
sdk: flutter
device_preview: ^1.2.0
flutter_availability:
path: ../../packages/flutter_availability

View file

@ -17,7 +17,6 @@ class AvailabilityOverview extends StatelessWidget {
/// Callback for when the user wants to navigate to the overview of templates
final VoidCallback onViewTemplates;
/// Callback invoked when a user attempts to go back
final VoidCallback onBack;