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

PlatformAndroid

A highly customizable Flutter package for displaying a social media feed with pagination, detail views, media playback, and social sharing capabilities.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:social_media_list/social_media_list.dart';
import 'package:white_label_app/core/storage/shared_prefs.dart';
import 'package:white_label_app/core/config/flavor_config.dart';
import 'dart:async';
import 'package:white_label_app/core/config/env_config.dart';
import 'package:white_label_app/flavors/flavor.dart';
import 'package:white_label_app/helper/apiController/api_controller.dart';

class _ApiListener implements OnInterfaceCallbackListener {
  final Completer<Map<String, dynamic>?> completer;
  _ApiListener(this.completer);

  @override
  void onFetchProgress(int statusCode, dynamic responseData, String? apiNamePageRef) {
    if (statusCode == 200 && responseData != null) {
      if (!completer.isCompleted) completer.complete(responseData);
    }
  }

  @override
  void onFetchComplete(int statusCode, String statusMessage, String? apiNamePageRef) {
    if (statusCode != 200) {
      if (!completer.isCompleted) completer.completeError(statusMessage);
    }
  }
}

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await SharedPrefs.init();
  await SharedPrefs.setString('ACCESS_TOKEN', '614|EXfZI40gTJpt6XqqV1uZFDl84Ujr21sHvIuKvcTJ');

  FlavorConfig.initialize(
    FlavorConfig(
      flavor: Flavor.clientA,
      appName: 'Example App',
      bundleId: 'com.example.app',
      assetPath: 'assets/clients/client_a',
      envConfig: EnvConfig.dev(
        baseUrl: 'https://arb.com-expert.com/arb/app_server/api/v2',
      ),
      featureFlags: const FeatureFlags(),
      themeConfig: const ClientThemeConfig(
        primaryColor: Colors.blue,
        secondaryColor: Colors.blueAccent,
        accentColor: Colors.lightBlue,
      ),
    ),
  );

  // Initialize the configuration for the package before running the app
  SocialMediaModule.initialize(
    config: SocialMediaConfig(
      listEndpoint: '/socialmedia/list',
      detailEndpoint: '/socialmedia/detail',
      markAsReadEndpoint: '/socialmedia/save-read-status',
      saveShareCountEndpoint: '/socialmedia/save-share-count',
      fetchListApi: (page) {
        final completer = Completer<Map<String, dynamic>?>();
        ApiController().doPostMethod(_ApiListener(completer), {'page': page, 'per_page': 15}, '/socialmedia/list', 'FETCH_LIST');
        return completer.future;
      },
      fetchDetailApi: (id) {
        final completer = Completer<Map<String, dynamic>?>();
        ApiController().doPostMethod(_ApiListener(completer), {'id': int.parse(id)}, '/socialmedia/detail', 'FETCH_DETAIL');
        return completer.future;
      },
      markAsReadApi: (id) {
        final completer = Completer<Map<String, dynamic>?>();
        ApiController().doPostMethod(_ApiListener(completer), {'id': int.parse(id)}, '/socialmedia/save-read-status', 'MARK_READ');
        return completer.future;
      },
      sharePostApi: (platform, id) {
        final completer = Completer<Map<String, dynamic>?>();
        ApiController().doPostMethod(_ApiListener(completer), {'id': int.parse(id), 'type': platform}, '/socialmedia/save-share-count', 'SHARE');
        return completer.future;
      },
    ),
  );

  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Social Media Package Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        useMaterial3: true,
      ),
      home: const SocialMediaScreen(), // The main screen from the package
    );
  }
}
0
likes
140
points
13
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A highly customizable Flutter package for displaying a social media feed with pagination, detail views, media playback, and social sharing capabilities.

Repository (GitHub)

License

MIT (license)

Dependencies

cached_network_image, chewie, flutter, flutter_html, http, installed_apps, path_provider, permission_handler, provider, share_plus, shimmer, tutorial_coach_mark, url_launcher, video_player

More

Packages that depend on social_media_list