full app done
This commit is contained in:
+6
-21
@@ -1,13 +1,12 @@
|
||||
/// Application entry point: wires services, Provider, and [MaterialApp].
|
||||
/// Application entry point: wires Provider and the Values Sort practice.
|
||||
library;
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import 'providers/item_provider.dart';
|
||||
import 'providers/theme_provider.dart';
|
||||
import 'providers/values_sort_provider.dart';
|
||||
import 'screens/splash_screen.dart';
|
||||
import 'services/item_repository.dart';
|
||||
import 'services/storage_service.dart';
|
||||
import 'utils/app_theme.dart';
|
||||
import 'utils/constants.dart';
|
||||
@@ -18,25 +17,14 @@ Future<void> main() async {
|
||||
final storage = StorageService();
|
||||
await storage.init();
|
||||
|
||||
runApp(
|
||||
MyApp(
|
||||
storage: storage,
|
||||
repository: ItemRepository(useRemoteData: storage.useRemoteData),
|
||||
),
|
||||
);
|
||||
runApp(MyApp(storage: storage));
|
||||
}
|
||||
|
||||
/// Root widget. Theme and catalog controllers live here so every route
|
||||
/// can `context.watch` them.
|
||||
/// Root widget. Theme and sort session live here so every route can watch them.
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({
|
||||
super.key,
|
||||
required this.storage,
|
||||
required this.repository,
|
||||
});
|
||||
const MyApp({super.key, required this.storage});
|
||||
|
||||
final StorageService storage;
|
||||
final ItemRepository repository;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -44,10 +32,7 @@ class MyApp extends StatelessWidget {
|
||||
providers: [
|
||||
ChangeNotifierProvider(create: (_) => ThemeController(storage)),
|
||||
ChangeNotifierProvider(
|
||||
create: (_) => ItemController(
|
||||
repository: repository,
|
||||
storage: storage,
|
||||
)..loadItems(),
|
||||
create: (_) => ValuesSortController(storage: storage)..load(),
|
||||
),
|
||||
],
|
||||
child: const _MaterialRoot(),
|
||||
|
||||
Reference in New Issue
Block a user