Flutter adapter for inertia.js. Know more about inertia on inertiajs.com.
Add the dependency to your flutter app:
inertia_flutter:
Set the Inertia.baseUrl
in your main.dart
's main
function.
void main() {
Inertia.baseUrl = 'https://demo.inertiajs.com/';
runApp(MyApp());
}
Update the MaterialApp:
- Set the
navigatorKey
toInertia.navigator
- Return the
Route
withInertiaScreen
inonGenerateRoute
- Implement a
pageMaker
, which displays the appropriate content for loading, success, and error states of a screen. Check the example app for inspiration.
@override
Widget build(BuildContext context) {
return MaterialApp(
initialRoute: '',
navigatorKey: Inertia.navigator,
onGenerateRoute: (route) =>
MaterialPageRoute(
builder: (_) =>
InertiaScreen(
settings: route,
pageMaker: _makePage,
),
),
);
}
Validations should happen on the backend. The form helper helps you with form submissions and server side validation errors.
Please see example/lib/pages/login.dart
for an example of form helper usage.