formigas GoRouter Brick
A brick that provides the structure how we implement go_router
at formigas in our Flutter projects.
Usage š ļø
See BrickHub for usage instructions.
Requirements
For the brick to work, the Widget used as home route needs to be in a file named the same as the Widget but in snake_case.
The app.dart
file must use the MaterialApp
widget and the homeRoute must either be initialized directly in the constructor or as a variable inside this file.
If there is another widget than the MaterialApp
the goRouter file is still created, but the app.dart
file is not modified accordingly.
A valid app.dart
file can look like this:
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:counter_app/common/theme/custom_themes.dart';
import 'package:counter_app/features/counter/counter_controller_implementation.dart';
import 'package:counter_app/features/counter/counter_view.dart';
class App extends StatelessWidget {
const App({super.key});
@override
build(context) => MaterialApp(
title: 'Counter App',
home: home,
theme: CustomTheme().light,
darkTheme: CustomTheme().dark,
themeMode: ThemeMode.light,
supportedLocales: L10n.delegate.supportedLocales,
);
}
Widget home = const CounterView(
controller: CounterControllerImplementation(),
);
Output š¦
āāā app
ā āāā view
ā ā āāā app.dart(modified)
āāā services
ā āāā navigation_service
ā ā āāā go_router.dart
Dependencies
Following dependencies will be installed for this brick if not already present: