simple_notes/lib/main.dart

40 lines
1.2 KiB
Dart

import 'package:flutter/material.dart';
import 'package:notes_app/screens/home/home.dart';
import 'package:notes_app/components/storage.dart';
import 'package:adaptive_theme/adaptive_theme.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
final savedThemeMode = await AdaptiveTheme.getThemeMode();
runApp(MyApp(savedThemeMode: savedThemeMode));
}
class MyApp extends StatelessWidget {
const MyApp({ Key? key, required this.savedThemeMode }) : super(key: key);
final savedThemeMode;
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return AdaptiveTheme(
light: ThemeData(
brightness: Brightness.light,
primaryColor: Colors.white,
accentColor: Colors.black,
),
dark: ThemeData(
brightness: Brightness.dark,
primarySwatch: Colors.red,
accentColor: Colors.amber,
),
initial: savedThemeMode ?? AdaptiveThemeMode.system,
builder: (theme, darkTheme) => MaterialApp(
title: 'Simple Notes',
theme: theme,
darkTheme: darkTheme,
home: MyHomePage(storage: CounterStorage(),),
),
);
}
}