taki_popups_plugin 0.0.1 copy "taki_popups_plugin: ^0.0.1" to clipboard
taki_popups_plugin: ^0.0.1 copied to clipboard

Takipopups flutter Package for mobile applications .

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:taki_popups_plugin/taki_popups_plugin.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await dotenv.load(fileName: ".env");
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(430, 932),
      minTextAdapt: true,
      builder: (BuildContext context, child) {
        return MaterialApp(
          title: 'Popups Plugin',
          debugShowCheckedModeBanner: false,
          theme: ThemeData(
            colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
            useMaterial3: true,
          ),
          home: const HomePage(),
        );
      },
    );
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  late PopupsPlugin popupsPlugin;

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

    popupsPlugin = PopupsPlugin(
      context: context,
      metadata: {
        "division": "",
        "state": "",
        "affiliations": [""],
        "domainName": "",
        "subjects": [],
        "username": "",
        "userId": "",
        "levelIds": ["", ""],
        "nameOfUser": "",
        "phone": "",
        "email": "",
      },
      username: '',
      userId: '',
      appId: '',
    );
  }

  @override
  void dispose() {
    popupsPlugin.popupSocketManager.dispose();
    super.dispose();
  }

  Future<void> _refreshData() async {
    popupsPlugin.popupSocketManager.fetchCachedPopups();

    // Logic to refresh data goes here
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: const Color(0xFF25C4F4),
        title: const Text("Popup Plugin Test"),
      ),
      body: RefreshIndicator(
        onRefresh: _refreshData,
        child: ListView(
          children: [
            Padding(
              padding: const EdgeInsets.all(16.0),
              child: Center(
                child: Text(
                  "Pull down to refresh",
                  style: TextStyle(fontSize: 16.sp),
                ),
              ),
            ),
            // Add other widgets or data here
          ],
        ),
      ),
    );
  }
}