diff --git a/.template/integration_test/my_home_page_test.dart b/.template/integration_test/my_home_page_test.dart index 7ebe8040..2b6dce67 100644 --- a/.template/integration_test/my_home_page_test.dart +++ b/.template/integration_test/my_home_page_test.dart @@ -10,7 +10,7 @@ void main() { testWidgets('My Home Page widget', (WidgetTester tester) async { await tester - .pumpWidget(TestUtil.pumpWidgetWithShellApp(const MyHomePage())); + .pumpWidget(TestUtil.pumpWidgetWithShellApp(const HomeScreen())); await tester.pumpAndSettle(); expect(find.widgetWithText(AppBar, 'Flutter templates testing'), diff --git a/.template/integration_test/utils/test_util.dart b/.template/integration_test/utils/test_util.dart index 5def520b..829f192e 100644 --- a/.template/integration_test/utils/test_util.dart +++ b/.template/integration_test/utils/test_util.dart @@ -9,7 +9,7 @@ class TestUtil { /// localization, routes, etc) static Widget pumpWidgetWithRealApp(String initialRoute) { _initDependencies(); - return MyApp(initialRoute: initialRoute); + return MyApp(); } /// We normally use this function to test a specific [widget] without diff --git a/.template/lib/main.dart b/.template/lib/main.dart index 376b8356..f6326f6a 100644 --- a/.template/lib/main.dart +++ b/.template/lib/main.dart @@ -2,40 +2,57 @@ import 'package:flutter/material.dart'; import 'package:flutter_config/flutter_config.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_templates/gen/assets.gen.dart'; +import 'package:go_router/go_router.dart'; import 'package:package_info_plus/package_info_plus.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await FlutterConfig.loadEnvVariables(); - runApp(const MyApp()); + runApp(MyApp()); } +const routePathRootScreen = '/'; +const routePathSecondScreen = 'second'; + class MyApp extends StatelessWidget { - // TODO: implement Routes then remove `home: MyHomePage()` and use initialRoute instead. - final String initialRoute; + MyApp({Key? key}) : super(key: key); - const MyApp({ - Key? key, - this.initialRoute = '/', - }) : super(key: key); + final GoRouter _router = GoRouter( + routes: [ + GoRoute( + path: routePathRootScreen, + builder: (BuildContext context, GoRouterState state) => + const HomeScreen(), + routes: [ + GoRoute( + path: routePathSecondScreen, + builder: (BuildContext context, GoRouterState state) => + const SecondScreen(), + ), + ], + ), + ], + ); @override Widget build(BuildContext context) { - return MaterialApp( + return MaterialApp.router( theme: ThemeData( primarySwatch: Colors.blue, brightness: Brightness.light, fontFamily: Assets.fonts.neuzeit, ), - home: const MyHomePage(), localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, + routeInformationProvider: _router.routeInformationProvider, + routeInformationParser: _router.routeInformationParser, + routerDelegate: _router.routerDelegate, ); } } -class MyHomePage extends StatelessWidget { - const MyHomePage({Key? key}) : super(key: key); +class HomeScreen extends StatelessWidget { + const HomeScreen({Key? key}) : super(key: key); @override Widget build(BuildContext context) { @@ -65,10 +82,30 @@ class MyHomePage extends StatelessWidget { Text( FlutterConfig.get('SECRET'), style: const TextStyle(color: Colors.black, fontSize: 24), - ) + ), + const SizedBox(height: 24), + ElevatedButton( + onPressed: () => context.go('/$routePathSecondScreen'), + child: const Text("Navigate to Second Screen"), + ), ], ), ), ); } } + +class SecondScreen extends StatelessWidget { + const SecondScreen({ + Key? key, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text("Second Screen"), + ), + ); + } +} diff --git a/.template/pubspec.lock b/.template/pubspec.lock index 037098ca..f3d3ff87 100644 --- a/.template/pubspec.lock +++ b/.template/pubspec.lock @@ -21,7 +21,7 @@ packages: name: archive url: "https://pub.dartlang.org" source: hosted - version: "3.1.6" + version: "3.1.11" args: dependency: transitive description: @@ -63,7 +63,7 @@ packages: name: build_daemon url: "https://pub.dartlang.org" source: hosted - version: "3.0.1" + version: "3.1.0" build_resolvers: dependency: transitive description: @@ -77,7 +77,7 @@ packages: name: build_runner url: "https://pub.dartlang.org" source: hosted - version: "2.1.7" + version: "2.1.11" build_runner_core: dependency: transitive description: @@ -140,7 +140,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" color: dependency: transitive description: @@ -168,7 +168,7 @@ packages: name: cupertino_icons url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" dart_style: dependency: transitive description: @@ -189,14 +189,14 @@ packages: name: dio url: "https://pub.dartlang.org" source: hosted - version: "4.0.4" + version: "4.0.6" fake_async: dependency: transitive description: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -241,21 +241,21 @@ packages: name: flutter_gen_core url: "https://pub.dartlang.org" source: hosted - version: "4.1.6" + version: "4.3.0" flutter_gen_runner: dependency: "direct dev" description: name: flutter_gen_runner url: "https://pub.dartlang.org" source: hosted - version: "4.1.6" + version: "4.3.0" flutter_lints: dependency: "direct dev" description: name: flutter_lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "2.0.1" flutter_localizations: dependency: "direct main" description: flutter @@ -277,14 +277,14 @@ packages: name: freezed url: "https://pub.dartlang.org" source: hosted - version: "1.1.1" + version: "2.0.3+1" freezed_annotation: dependency: "direct main" description: name: freezed_annotation url: "https://pub.dartlang.org" source: hosted - version: "1.1.0" + version: "2.0.3" frontend_server_client: dependency: transitive description: @@ -304,6 +304,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.2" + go_router: + dependency: "direct main" + description: + name: go_router + url: "https://pub.dartlang.org" + source: hosted + version: "4.1.0" graphs: dependency: transitive description: @@ -357,28 +364,28 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: "direct main" description: name: json_annotation url: "https://pub.dartlang.org" source: hosted - version: "4.4.0" + version: "4.5.0" json_serializable: dependency: "direct dev" description: name: json_serializable url: "https://pub.dartlang.org" source: hosted - version: "6.1.5" + version: "6.2.0" lints: dependency: transitive description: name: lints url: "https://pub.dartlang.org" source: hosted - version: "1.0.1" + version: "2.0.0" logging: dependency: transitive description: @@ -399,7 +406,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -420,7 +427,7 @@ packages: name: mockito url: "https://pub.dartlang.org" source: hosted - version: "5.1.0" + version: "5.2.0" package_config: dependency: transitive description: @@ -434,14 +441,14 @@ packages: name: package_info_plus url: "https://pub.dartlang.org" source: hosted - version: "1.4.0" + version: "1.4.2" package_info_plus_linux: dependency: transitive description: name: package_info_plus_linux url: "https://pub.dartlang.org" source: hosted - version: "1.0.3" + version: "1.0.5" package_info_plus_macos: dependency: transitive description: @@ -462,21 +469,21 @@ packages: name: package_info_plus_web url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" package_info_plus_windows: dependency: transitive description: name: package_info_plus_windows url: "https://pub.dartlang.org" source: hosted - version: "1.0.4" + version: "1.0.5" path: dependency: transitive description: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" petitparser: dependency: transitive description: @@ -586,7 +593,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -635,7 +642,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" time: dependency: transitive description: @@ -670,14 +677,14 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" vm_service: dependency: transitive description: name: vm_service url: "https://pub.dartlang.org" source: hosted - version: "7.5.0" + version: "8.2.2" watcher: dependency: transitive description: @@ -721,5 +728,5 @@ packages: source: hosted version: "3.1.0" sdks: - dart: ">=2.16.1 <3.0.0" - flutter: ">=1.20.0" + dart: ">=2.17.5 <3.0.0" + flutter: ">=3.0.0" diff --git a/.template/pubspec.yaml b/.template/pubspec.yaml index 205f3ca2..0562d404 100644 --- a/.template/pubspec.yaml +++ b/.template/pubspec.yaml @@ -15,36 +15,37 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 0.9.0+10 +version: 1.0.0+11 environment: - sdk: ">=2.16.1 <3.0.0" + sdk: ">=2.17.5 <3.0.0" dependencies: - cupertino_icons: ^1.0.4 - dio: ^4.0.4 + cupertino_icons: ^1.0.5 + dio: ^4.0.6 flutter: sdk: flutter + flutter_config: ^2.0.0 flutter_localizations: sdk: flutter - flutter_config: ^2.0.0 - freezed_annotation: ^1.1.0 - json_annotation: ^4.4.0 + freezed_annotation: ^2.0.3 + go_router: ^4.1.0 intl: ^0.17.0 + json_annotation: ^4.5.0 + package_info_plus: ^1.4.2 retrofit: ^3.0.1+1 - package_info_plus: ^1.4.0 dev_dependencies: - build_runner: ^2.1.7 - flutter_gen_runner: ^4.1.6 - flutter_lints: ^1.0.4 + build_runner: ^2.1.11 + flutter_gen_runner: ^4.3.0 + flutter_lints: ^2.0.1 flutter_test: sdk: flutter - freezed: ^1.1.1 + freezed: ^2.0.3+1 integration_test: sdk: flutter - json_serializable: ^6.1.5 - mockito: ^5.1.0 + json_serializable: ^6.2.0 + mockito: ^5.2.0 retrofit_generator: ^4.0.1 # For information on the generic Dart part of this file, see the