get_x_storage 0.0.7 copy "get_x_storage: ^0.0.7" to clipboard
get_x_storage: ^0.0.7 copied to clipboard

GetXStorage is a lightweight and efficient persistent storage solution for Flutter applications

example/lib/main.dart

import 'package:example/theme_controller.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get_storage/get_storage.dart';
import 'package:get_x_master/get_x_master.dart';
import 'package:get_x_storage/get_x_storage.dart';

import 'app_bindings.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await GetXStorage.init();
  await GetStorage.init(); // Initialize GetStorage instead of GetXStorage
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    final ThemeController themeController = Get.put(ThemeController());
    return Obx(
      () => GetMaterialApp(
        title: 'Flutter Demo',
        initialBinding: AppBindings(),
        theme: ThemeData.light(),
        darkTheme: ThemeData.dark(),
        themeMode:
            themeController.isDarkTheme.value
                ? ThemeMode.light
                : ThemeMode.dark,
        home: const Screen(),
      ),
    );
  }
}

class Screen extends StatelessWidget {
  const Screen({super.key});

  @override
  Widget build(BuildContext context) {
    final ThemeController themeController = Get.find();

    return Scaffold(
      appBar: AppBar(title: const Text('Theme Switcher')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            const Text('Dark Mode:'),
            Obx(
              () => CupertinoSwitch(
                value: !themeController.isDarkTheme.value,
                onChanged: (value) {
                  themeController.toggleTheme();
                },
              ),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
160
points
49
downloads

Publisher

verified publisherswanflutterdev.com

Weekly Downloads

GetXStorage is a lightweight and efficient persistent storage solution for Flutter applications

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

collection, crypto, encrypt, flutter, path_provider, rxdart, synchronized, universal_html

More

Packages that depend on get_x_storage