brix_getx 1.0.4
brix_getx: ^1.0.4 copied to clipboard
GetX controllers for every brix account screen: login, signup, email code, reset, profile and delete account, with fields, form key and loading state.
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'config/app_config.dart';
import 'config/dependencies.dart';
import 'data/repositories/account_repository_remote.dart';
import 'data/repositories/auth_repository_remote.dart';
import 'dev/local_backend.dart'; // local test backend
import 'ui/core/themes/theme.dart';
import 'ui/settings/view_models/appearance_viewmodel.dart';
import 'ui/setup/widgets/setup_error_screen.dart';
/// Runs on your API (`lib/config/app_config.dart`).
///
/// Without an API, debug builds run on a local test backend (`lib/dev`) so
/// every screen works on day one. Release builds never contain it: the
/// compiler drops code behind `kDebugMode`.
void main() {
WidgetsFlutterBinding.ensureInitialized();
if (kDebugMode && AppConfig.apiUrl.isEmpty) {
startWithLocalBackend(); // local test backend
runApp(const App());
return;
}
final problem = AppConfig.problem();
if (problem != null) {
runApp(SetupErrorScreen(message: problem));
return;
}
Dependencies.init(
apiUrl: AppConfig.apiUrl,
backend: (api, session) => (
auth: AuthRepositoryRemote(api),
account: AccountRepositoryRemote(api),
),
);
runApp(const App());
}
class App extends StatelessWidget {
const App({super.key});
@override
Widget build(BuildContext context) {
final appearance = Get.find<AppearanceViewModel>();
return Obx(
() => MaterialApp.router(
title: 'brix_getx_example',
debugShowCheckedModeBanner: false,
theme: AppTheme.light,
darkTheme: AppTheme.dark,
themeMode: appearance.mode.value,
routerConfig: Dependencies.router,
),
);
}
}