This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() { | |
| runApp(const MyApp()); | |
| } | |
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key}) : super(key: key); | |
| @override |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyHomePage extends StatefulWidget { | |
| const MyHomePage({Key? key, this.themeMode, this.onThemeMode}) | |
| : super(key: key); | |
| final ThemeMode? themeMode; // | |
| final ValueChanged<ThemeMode>? onThemeMode; // | |
| @override | |
| State<MyHomePage> createState() => _MyHomePageState(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| class CustomDrawer extends StatefulWidget { | |
| const CustomDrawer({ | |
| Key? key, | |
| required this.themeMode, | |
| required this.onThemeMode, | |
| }) : super(key: key); | |
| final ThemeMode? themeMode; | |
| final ValueChanged<ThemeMode>? onThemeMode; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class _MyAppState extends State<MyApp> { | |
| //Keeps track of theme | |
| late ThemeMode? themeMode = widget.savedThemeMode; | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
| //Add themeMode as themeMode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyApp extends StatefulWidget { | |
| const MyApp({Key? key, this.savedThemeMode}) : super(key: key); | |
| final ThemeMode? savedThemeMode; | |
| @override | |
| State<MyApp> createState() => _MyAppState(); | |
| } | |
| class _MyAppState extends State<MyApp> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class MyApp extends StatelessWidget { | |
| const MyApp({Key? key, this.savedThemeMode}) : super(key: key); | |
| final ThemeMode? savedThemeMode; | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Flutter Demo', | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| import 'package:flutter_dark_mode_demo/sharedPreferences/app_theme_shared_preferences.dart'; | |
| Future<void> main() async { | |
| WidgetsBinding widgetsBinding = WidgetsFlutterBinding.ensureInitialized(); | |
| int? retrieveSavedThemeModeIndex = await retrieveSavedThemeMode(); | |
| final ThemeMode savedThemeMode = retrieveSavedThemeModeIndex == 0 | |
| ? ThemeMode.system | |
| : retrieveSavedThemeModeIndex == 1 | |
| ? ThemeMode.light |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Dart 18 hrs 40 mins βββββββββββββββββββββ 94.5% | |
| TypeScript 31 mins βββββββββββββββββββββ 2.6% | |
| Ezhil 13 mins βββββββββββββββββββββ 1.2% | |
| JavaScript 10 mins βββββββββββββββββββββ 0.9% | |
| YAML 7 mins βββββββββββββββββββββ 0.7% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:connectivity_plus/connectivity_plus.dart'; | |
| import 'package:flutter/cupertino.dart'; | |
| import 'package:flutter/services.dart'; | |
| // Platform messages are asynchronous, so we initialize in an async method. | |
| Future<ConnectivityResult?> initConnectivity( | |
| {required Connectivity connectivity}) async { | |
| // Platform messages may fail, so we use a try/catch PlatformException. | |
| try { | |
| return await connectivity.checkConnectivity(); |