Skip to content

Commit

Permalink
Merge pull request #5 from SandroMaglione/1_environment_variables
Browse files Browse the repository at this point in the history
Routing (`auto_route`) + Environmental variables
  • Loading branch information
SandroMaglione authored Sep 24, 2022
2 parents 6251749 + 638f904 commit 5ab4a61
Show file tree
Hide file tree
Showing 7 changed files with 329 additions and 6 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ app.*.map.json
/android/app/release

# Environment
.env.local
.env.local

# Generated files
lib/**/*.g.dart
lib/**/*.gr.dart
lib/**/*.freezed.dart
10 changes: 6 additions & 4 deletions lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import 'package:flutter/material.dart';
import 'package:flutter_supabase_complete/core/routes/app_router.dart';

/// Entry widget of the app
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
App({Key? key}) : super(key: key);
final _appRouter = AppRouter();

@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Supabase Complete',
home: Placeholder(),
return MaterialApp.router(
routerDelegate: _appRouter.delegate(),
routeInformationParser: _appRouter.defaultRouteParser(),
);
}
}
12 changes: 12 additions & 0 deletions lib/app/home_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import 'package:flutter/material.dart';

class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return const Scaffold(
body: Placeholder(),
);
}
}
14 changes: 14 additions & 0 deletions lib/core/routes/app_router.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/// Make sure to import `auto_route` and `material` (required)
import 'package:auto_route/auto_route.dart';
import 'package:flutter/material.dart';
import 'package:flutter_supabase_complete/app/home_page.dart';

part 'app_router.gr.dart';

@MaterialAutoRouter(
replaceInRouteName: 'Page,Route',
routes: <AutoRoute>[
AutoRoute(page: HomePage, initial: true),
],
)
class AppRouter extends _$AppRouter {}
2 changes: 1 addition & 1 deletion lib/main_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Future<void> mainCommon() async {
anonKey: Constants.supabaseAnnonKey,
);

runApp(const App());
runApp(App());
}
Loading

0 comments on commit 5ab4a61

Please sign in to comment.