dust_flutter 0.1.0
dust_flutter: ^0.1.0 copied to clipboard
Flutter annotations and runtime APIs for Dust-generated routing, state management, and i18n.
dust_flutter #
Flutter annotations and runtime APIs for Dust-generated routing, state management, and i18n.
You focus on product. We focus on performance.
Status #
0.1.0is the first public Flutter runtime release.- Routing, state management, and i18n APIs are beta and may still receive compatibility-preserving refinements before stabilization.
- Generated code can improve while app widgets and product logic stay focused.
- No external routing or state-management package is required by Dust.
Install #
Add dust_flutter to Flutter apps that use Dust-generated Flutter code:
dependencies:
dust_flutter: ^0.1.0
Most projects also use dust_dart for model derives and serialization:
dependencies:
dust_dart: ^0.1.0
dust_flutter: ^0.1.0
Run Dust from your package root after adding annotations:
dust build
Imports #
package:dust_flutter/route.dart: Navigator 2.0 annotations and runtime.package:dust_flutter/state.dart: ViewModel annotations and runtime.package:dust_flutter/i18n.dart: i18n runtime scope, controller, and widgets.package:dust_flutter/dust_flutter.dart: convenience export for all Flutter-only APIs.
Routing #
import 'package:dust_flutter/route.dart';
@AppRouter(initial: '/', notFound: '/404')
final class RootRouter extends $RootRouter {
RootRouter({required this.auth});
final AuthViewModel auth;
@override
AppRoutePath? redirect(AppRoutePath route) {
if (!auth.isLoggedIn && route.requiresAuth) {
return LoginRoute(from: route.location);
}
return null;
}
}
State #
import 'package:dust_flutter/state.dart';
@ViewModel(state: CounterState)
final class CounterViewModel extends $CounterViewModel {
CounterViewModel(super.args);
void increment() {
emit(state.copyWith(count: state.count + 1));
}
}
i18n #
import 'package:dust_flutter/i18n.dart';
final i18n = I18nController(
config: const I18nConfig(
locales: ['en', 'my'],
fallbackLocale: 'en',
),
);
await i18n.loadAssetBundles();
I18nScope(
controller: i18n,
child: const TranslatedText('home_title'),
);
Runtime keys use a namespace prefix followed by an underscore. For example,
home_title loads from assets/i18n/{locale}/home.arb and reads the ARB
message key title. home_title_name reads the title_name key from the same
file.
Documentation #
See the canonical guides in docs/usage/routing.md, docs/usage/state.md,
and docs/usage/i18n.md.