mirror of
https://github.com/inventree/inventree-app.git
synced 2025-07-04 04:40:51 +00:00
Format code
This commit is contained in:
lib
api.dartapi_form.dartapp_colors.dart
tasks.pybarcode
barcode.dartcamera_controller.dartcontroller.darthandler.dartpurchase_order.dartsales_order.dartstock.darttones.dartwedge_controller.dart
dsn.darthelpers.dartinventree
bom.dartcompany.dartmodel.dartnotification.dartorders.dartpart.dartproject_code.dartpurchase_order.dartsales_order.dartsentry.dartstatus_codes.dartstock.dart
l10.dartlabels.dartmain.dartpreferences.dartsettings
about.dartapp_settings.dartbarcode_settings.darthome_settings.dartlogin.dartpart_settings.dartpurchase_order_settings.dartrelease.dartsales_order_settings.dartselect_server.dartsettings.dart
user_profile.dartwidget
attachment_widget.dartback.dart
company
company_detail.dartcompany_list.dartmanufacturer_part_detail.dartsupplier_part_detail.dartsupplier_part_list.dart
dialogs.dartdrawer.dartfields.darthome.dartnotes_widget.dartnotifications.dartorder
extra_line_detail.dartpo_extra_line_list.dartpo_line_detail.dartpo_line_list.dartpurchase_order_detail.dartpurchase_order_list.dartsales_order_detail.dartsales_order_list.dartso_extra_line_list.dartso_line_detail.dartso_line_list.dartso_shipment_list.dart
paginator.dartpart
bom_list.dartcategory_display.dartcategory_list.dartpart_detail.dartpart_image_widget.dartpart_list.dartpart_parameter_widget.dartpart_pricing.dartpart_suppliers.dart
progress.dartrefreshable_state.dartsearch.dartsnacks.dartspinner.dartstock
test
102
lib/main.dart
102
lib/main.dart
@ -18,15 +18,12 @@ import "package:inventree/l10n/collected/app_localizations.dart";
|
||||
import "package:inventree/settings/release.dart";
|
||||
import "package:inventree/widget/home.dart";
|
||||
|
||||
|
||||
Future<void> main() async {
|
||||
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
final savedThemeMode = await AdaptiveTheme.getThemeMode();
|
||||
|
||||
await runZonedGuarded<Future<void>>(() async {
|
||||
|
||||
PackageInfo info = await PackageInfo.fromPlatform();
|
||||
String pkg = info.packageName;
|
||||
String version = info.version;
|
||||
@ -46,20 +43,18 @@ Future<void> main() async {
|
||||
|
||||
// Pass any flutter errors off to the Sentry reporting context!
|
||||
FlutterError.onError = (FlutterErrorDetails details) async {
|
||||
|
||||
// Ensure that the error gets reported to sentry!
|
||||
await sentryReportError(
|
||||
"FlutterError.onError",
|
||||
details.exception, details.stack,
|
||||
context: {
|
||||
"context": details.context.toString(),
|
||||
"summary": details.summary.toString(),
|
||||
"library": details.library ?? "null",
|
||||
}
|
||||
);
|
||||
"FlutterError.onError", details.exception, details.stack,
|
||||
context: {
|
||||
"context": details.context.toString(),
|
||||
"summary": details.summary.toString(),
|
||||
"library": details.library ?? "null",
|
||||
});
|
||||
};
|
||||
|
||||
final int orientation = await InvenTreeSettingsManager().getValue(INV_SCREEN_ORIENTATION, SCREEN_ORIENTATION_SYSTEM) as int;
|
||||
final int orientation = await InvenTreeSettingsManager()
|
||||
.getValue(INV_SCREEN_ORIENTATION, SCREEN_ORIENTATION_SYSTEM) as int;
|
||||
|
||||
List<DeviceOrientation> orientations = [];
|
||||
|
||||
@ -78,15 +73,11 @@ Future<void> main() async {
|
||||
}
|
||||
|
||||
SystemChrome.setPreferredOrientations(orientations).then((_) {
|
||||
runApp(
|
||||
InvenTreeApp(savedThemeMode)
|
||||
);
|
||||
runApp(InvenTreeApp(savedThemeMode));
|
||||
});
|
||||
|
||||
}, (Object error, StackTrace stackTrace) async {
|
||||
sentryReportError("main.runZonedGuarded", error, stackTrace);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
class InvenTreeApp extends StatefulWidget {
|
||||
@ -99,13 +90,11 @@ class InvenTreeApp extends StatefulWidget {
|
||||
@override
|
||||
InvenTreeAppState createState() => InvenTreeAppState(savedThemeMode);
|
||||
|
||||
static InvenTreeAppState? of(BuildContext context) => context.findAncestorStateOfType<InvenTreeAppState>();
|
||||
|
||||
static InvenTreeAppState? of(BuildContext context) =>
|
||||
context.findAncestorStateOfType<InvenTreeAppState>();
|
||||
}
|
||||
|
||||
|
||||
class InvenTreeAppState extends State<StatefulWidget> {
|
||||
|
||||
InvenTreeAppState(this.savedThemeMode) : super();
|
||||
|
||||
// Custom _locale (default = null; use system default)
|
||||
@ -123,16 +112,16 @@ class InvenTreeAppState extends State<StatefulWidget> {
|
||||
|
||||
// Run app init routines in the background
|
||||
Future<void> runInitTasks() async {
|
||||
|
||||
// Set the app locale (language)
|
||||
Locale? locale = await InvenTreeSettingsManager().getSelectedLocale();
|
||||
setLocale(locale);
|
||||
|
||||
// Display release notes if this is a new version
|
||||
final String version = await InvenTreeSettingsManager().getValue("recentVersion", "") as String;
|
||||
final String version = await InvenTreeSettingsManager()
|
||||
.getValue("recentVersion", "") as String;
|
||||
|
||||
final PackageInfo info = await PackageInfo.fromPlatform();
|
||||
|
||||
|
||||
if (version != info.version) {
|
||||
// Save latest version to the settings database
|
||||
await InvenTreeSettingsManager().setValue("recentVersion", info.version);
|
||||
@ -142,8 +131,7 @@ class InvenTreeAppState extends State<StatefulWidget> {
|
||||
|
||||
// Show the release notes
|
||||
OneContext().push(
|
||||
MaterialPageRoute(builder: (context) => ReleaseNotesWidget(notes))
|
||||
);
|
||||
MaterialPageRoute(builder: (context) => ReleaseNotesWidget(notes)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -158,37 +146,35 @@ class InvenTreeAppState extends State<StatefulWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return AdaptiveTheme(
|
||||
light: ThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorSchemeSeed: Colors.lightBlueAccent,
|
||||
useMaterial3: true,
|
||||
),
|
||||
dark: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: Colors.blue,
|
||||
useMaterial3: true,
|
||||
),
|
||||
initial: savedThemeMode ?? AdaptiveThemeMode.light,
|
||||
builder: (light, dark) => MaterialApp(
|
||||
theme: light,
|
||||
darkTheme: dark,
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: OneContext().builder,
|
||||
navigatorKey: OneContext().key,
|
||||
onGenerateTitle: (BuildContext context) => "InvenTree",
|
||||
home: InvenTreeHomePage(),
|
||||
localizationsDelegates: [
|
||||
I18N.delegate,
|
||||
LocaleNamesLocalizationsDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: supported_locales,
|
||||
locale: _locale,
|
||||
)
|
||||
);
|
||||
light: ThemeData(
|
||||
brightness: Brightness.light,
|
||||
colorSchemeSeed: Colors.lightBlueAccent,
|
||||
useMaterial3: true,
|
||||
),
|
||||
dark: ThemeData(
|
||||
brightness: Brightness.dark,
|
||||
colorSchemeSeed: Colors.blue,
|
||||
useMaterial3: true,
|
||||
),
|
||||
initial: savedThemeMode ?? AdaptiveThemeMode.light,
|
||||
builder: (light, dark) => MaterialApp(
|
||||
theme: light,
|
||||
darkTheme: dark,
|
||||
debugShowCheckedModeBanner: false,
|
||||
builder: OneContext().builder,
|
||||
navigatorKey: OneContext().key,
|
||||
onGenerateTitle: (BuildContext context) => "InvenTree",
|
||||
home: InvenTreeHomePage(),
|
||||
localizationsDelegates: [
|
||||
I18N.delegate,
|
||||
LocaleNamesLocalizationsDelegate(),
|
||||
GlobalMaterialLocalizations.delegate,
|
||||
GlobalCupertinoLocalizations.delegate,
|
||||
GlobalWidgetsLocalizations.delegate,
|
||||
],
|
||||
supportedLocales: supported_locales,
|
||||
locale: _locale,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user