Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support for localization #62

Merged
merged 4 commits into from Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# Next

- feat: add support for slide deck localization

# 0.11.1

- fix: hot reload doesn't work on macOS
Expand Down
28 changes: 28 additions & 0 deletions lib/src/flutter_deck_app.dart
Expand Up @@ -39,6 +39,9 @@ class FlutterDeckApp extends StatefulWidget {
/// The [themeMode] argument can be used to provide a custom theme mode for
/// the slide deck.
///
/// The [locale], [localizationsDelegates] and [supportedLocales] arguments
/// are equivalent to those of [MaterialApp]'s.
///
/// See also:
///
/// * [FlutterDeckSlide], which represents a single slide.
Expand All @@ -56,6 +59,9 @@ class FlutterDeckApp extends StatefulWidget {
this.lightTheme,
this.darkTheme,
this.themeMode = ThemeMode.system,
this.locale,
this.localizationsDelegates,
this.supportedLocales = const <Locale>[Locale('en')],
super.key,
}) : assert(slides.length > 0, 'You must provide at least one slide');

Expand Down Expand Up @@ -96,6 +102,25 @@ class FlutterDeckApp extends StatefulWidget {
/// By default, the system theme mode is used.
final ThemeMode themeMode;

/// The initial locale for the slide deck.
///
/// See also:
/// * [MaterialApp.locale], which is equivalent to this argument.
final Locale? locale;

/// The delegates for the slide deck's localization.
///
/// See also:
/// * [MaterialApp.localizationsDelegates], which is equivalent to this
/// argument.
final Iterable<LocalizationsDelegate<dynamic>>? localizationsDelegates;

/// The list of locales that the slide deck has been localized for.
///
/// See also:
/// * [MaterialApp.supportedLocales], which is equivalent to this argument.
final Iterable<Locale> supportedLocales;

@override
State<FlutterDeckApp> createState() => _FlutterDeckAppState();
}
Expand Down Expand Up @@ -173,6 +198,9 @@ class _FlutterDeckAppState extends State<FlutterDeckApp> {
),
),
debugShowCheckedModeBanner: false,
locale: widget.locale,
localizationsDelegates: widget.localizationsDelegates,
supportedLocales: widget.supportedLocales,
);
},
);
Expand Down