my_cus_pug_you 0.0.2 copy "my_cus_pug_you: ^0.0.2" to clipboard
my_cus_pug_you: ^0.0.2 copied to clipboard

PlatformiOS

Flutter plugin for intelligent device-adaptive content display with splash screen functionality.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:go_router/go_router.dart';
import 'package:my_cus_pug_you/my_cus_pug_you.dart';

void main() {
  runApp(MyApp());
}

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

  final GoRouter _router = GoRouter(
    initialLocation: '/splash',
    routes: [
      GoRoute(
        path: '/splash',
        builder: (context, state) => const SplashScreen(),
      ),
      GoRoute(
        path: '/home',
        builder: (context, state) => const HomeScreen(),
      ),
      GoRoute(
        path: '/lin',
        name: '/lin',
        builder: (context, state) => const GreyScreen(),
      ),
    ],
  );

  @override
  Widget build(BuildContext context) {
    return MaterialApp.router(
      title: 'My Cus Pug You Plugin Example',
      routerConfig: _router,
    );
  }
}

class SplashScreen extends StatefulWidget {
  const SplashScreen({super.key});

  @override
  State<SplashScreen> createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  bool _isInitializing = true;
  String _status = 'Initializing plugin...';

  @override
  void initState() {
    super.initState();
    _initializePlugin();
  }

  Future<void> _initializePlugin() async {
    try {
      setState(() {
        _status = 'Initializing plugin...';
      });

      // First initialize the plugin with required API keys
      await MyCusPugYou.initialize(
        apiKey: 'key',
        apiUrl: 'url',
      );
      
      setState(() {
        _status = 'Calling greyInit...';
      });

      // Call greyInit from your plugin with required parameters  
      if (mounted) {
        await MyCusPugYou.greyInit(
          goToGame: () {
            if (mounted) {
              context.go('/home');
            }
          },
          context: context,
        );
      }
      
      setState(() {
        _status = 'Plugin initialized successfully!';
      });

      // Wait a bit to show the success message
      await Future.delayed(const Duration(seconds: 2));


    } catch (e) {
      setState(() {
        _status = 'Error initializing plugin: $e';
        _isInitializing = false;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.flash_on,
              size: 80,
              color: Colors.blue,
            ),
            const SizedBox(height: 24),
            const Text(
              'My Cus Pug You Plugin',
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 24),
            if (_isInitializing) 
              const CircularProgressIndicator(),
            const SizedBox(height: 16),
            Text(
              _status,
              textAlign: TextAlign.center,
              style: const TextStyle(fontSize: 16),
            ),
            if (!_isInitializing)
              Padding(
                padding: const EdgeInsets.only(top: 16),
                child: ElevatedButton(
                  onPressed: () => context.go('/home'),
                  child: const Text('Go to Home'),
                ),
              ),
          ],
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Home Screen'),
        backgroundColor: Colors.blue,
        foregroundColor: Colors.white,
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Icon(
              Icons.home,
              size: 80,
              color: Colors.green,
            ),
            const SizedBox(height: 24),
            const Text(
              'Welcome to Home Screen!',
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
            ),
            const SizedBox(height: 16),
            const Text(
              'Plugin has been successfully initialized.',
              style: TextStyle(fontSize: 16),
            ),
            const SizedBox(height: 32),
            ElevatedButton(
              onPressed: () => context.go('/grey'),
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.grey,
                foregroundColor: Colors.white,
                padding: const EdgeInsets.symmetric(
                  horizontal: 32,
                  vertical: 16,
                ),
              ),
              child: const Text(
                'Open Grey Screen',
                style: TextStyle(fontSize: 18),
              ),
            ),
            const SizedBox(height: 16),
            TextButton(
              onPressed: () => context.go('/splash'),
              child: const Text('Back to Splash'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
130
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter plugin for intelligent device-adaptive content display with splash screen functionality.

Homepage

Documentation

API reference

License

MIT (license)

Dependencies

device_info_plus, flutter, go_router, http, native_webview, shared_preferences, uuid

More

Packages that depend on my_cus_pug_you

Packages that implement my_cus_pug_you