This commit is contained in:
cxc
2023-02-08 17:20:16 +08:00
parent 06ff4a41f4
commit 53ff2fc59b
23 changed files with 458 additions and 104 deletions

View File

@ -2,9 +2,13 @@ import 'dart:io';
import 'package:fluent_ui/fluent_ui.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
// import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:momo/material/app.dart';
import 'package:momo/provider/token.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:window_manager/window_manager.dart';
import 'package:tray_manager/tray_manager.dart';
// import 'package:tray_manager/tray_manager.dart';
void main() async {
if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
@ -24,14 +28,38 @@ void main() async {
await windowManager.focus();
});
}
runApp(const ProviderScope(child: MyApp()));
final prefs = await SharedPreferences.getInstance();
String? tk = prefs.getString("token");
final container = ProviderContainer();
container.read(tokenProvider.notifier).setToken(tk);
runApp(
UncontrolledProviderScope(
container: container,
child: const MyApp(),
),
);
// runApp((child: MyApp(token: tk)));
// runApp(MultiProvider(
// providers: [
// ChangeNotifierProvider(
// create: (context) => Secret(),
// ),
// ],
// child: MyApp(
// token: tk,
// ),
// ));
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
const MyApp({super.key, this.token});
final String? token;
@override
Widget build(BuildContext context) {
// Provider.of<Secret>(context, listen: false).setToken(token);
return const MyMaterialApp();
}
}