This file contains 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 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 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 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 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 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 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(); |
This file contains 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
<manifest> | |
<application> | |
<meta-data | |
android:name="com.google.android.gms.ads.APPLICATION_ID" | |
android:value="ca-app-pub-3940256099942544~3347511713"/> | |
</application> | |
</manifest> |
This file contains 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
Future<void> main() async { | |
WidgetsFlutterBinding.ensureInitialized(); | |
final initFuture = MobileAds.instance.initialize(); | |
final adState = AdState(initFuture); | |
runApp(Provider.value( | |
value: adState, | |
builder: (context, child) => const MyApp(), | |
)); | |
} |