playx_core 0.5.4 copy "playx_core: ^0.5.4" to clipboard
playx_core: ^0.5.4 copied to clipboard

Core package for playx eco system contains shared classes and utilities.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:playx_core/playx_core.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await PlayxCore.bootCore();
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Playx Core',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Playx Core'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = PlayxPrefs.getInt('counter', fallback: 0);

  void _incrementCounter() {
    setState(() {
      _counter++;
      PlayxPrefs.setInt('counter', _counter);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: SizedBox(
          height: context.height * .3,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'You have pushed the button this many times:',
              ),
              Text(
                '$_counter',
                style: context.textTheme.headlineMedium,
              ),
            ],
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
1
likes
150
points
430
downloads

Publisher

verified publisherplayx.sourcya.io

Weekly Downloads

Core package for playx eco system contains shared classes and utilities.

Repository (GitHub)
View/report issues

Topics

#playx #ecosystem #core #prefs #env

Documentation

API reference

License

MIT (license)

Dependencies

equatable, flutter, flutter_dotenv, flutter_secure_storage, get_it, shared_preferences, sprintf

More

Packages that depend on playx_core