Skip to main content

taki_popups_plugin 0.0.3 copy "taki_popups_plugin: ^0.0.3" to clipboard
taki_popups_plugin: ^0.0.3 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": "Bac Sciences Exp",
        "state": "منوبة",
        "affiliations": [],
        "student_levels": [],
        "domaineName": "app.takiacademy.com",
        "name": "iyed sebai",
        "email": "iyedsebai789@gmail.com",
        "phone": "93681987",
        "gift_code": null
      },
      username: 'iyed sebai',
      userId: '154084',
      appId: '672b9ce26e32455831f9192d',
    );
  }

  @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
          ],
        ),
      ),
    );
  }
}