Add full app source

Adds the Flutter inventory app source, cleaned up for a shared repo:
generic package name, no hardcoded ERP endpoints (moved to gitignored
local config), no dead auth code, no debug logging of session data.
This commit is contained in:
BACHIR SOULDI
2026-07-16 14:37:28 +01:00
parent 37b0762921
commit 5a483da01d
110 changed files with 8081 additions and 0 deletions

37
lib/auth.dart Normal file
View File

@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:get_storage/get_storage.dart';
import 'package:inventory_app/views/splash_screen.dart';
import 'package:inventory_app/my_app.dart';
import 'package:inventory_app/views/login_view.dart';
import 'package:inventory_app/service/axelor_client.dart';
class Auth extends StatelessWidget {
const Auth({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
final box = GetStorage();
String? sessionId = box.read('sessionId');
if (sessionId == null) {
return const LoginView();
}
// Session exists on disk — validate it with the server before granting access
return FutureBuilder<bool>(
future: AxelorClient.create().then((client) => client.isSessionValid()),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const SplashScreen();
} else if (snapshot.hasError || !(snapshot.data ?? false)) {
// Session is expired or invalid — clear it and force re-login
box.remove('sessionId');
box.remove('username');
return const LoginView();
} else {
return MyApp();
}
},
);
}
}