flutter_share_pro 0.0.3 copy "flutter_share_pro: ^0.0.3" to clipboard
flutter_share_pro: ^0.0.3 copied to clipboard

Advanced sharing functionality with custom share sheets and content preview

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_share_pro/features/sharing/domain/bloc/sharing_bloc.dart';
import 'package:flutter_share_pro/features/sharing/domain/bloc/sharing_state.dart';
import 'package:flutter_share_pro/features/sharing/presentation/widgets/content_preview.dart';
import 'package:flutter_share_pro/features/sharing/presentation/widgets/share_button.dart';

void main() {
  runApp(const ExampleApp());
}

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

  @override
  Widget build(BuildContext context) => MaterialApp(
        title: 'Flutter Share Pro - Example',
        theme: ThemeData(
          useMaterial3: true,
          colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
        ),
        home: const ExampleHomePage(),
        debugShowCheckedModeBanner: false,
      );
}

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

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: const Text('Flutter Share Pro Example'),
          backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        ),
        body: BlocProvider(
          create: (context) => SharingBloc(),
          child: const ExampleContent(),
        ),
      );
}

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

  @override
  Widget build(BuildContext context) => Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            const Text(
              'Advanced Sharing Functionality Example',
              style: TextStyle(
                fontSize: 24,
                fontWeight: FontWeight.bold,
              ),
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 16),
            const Text(
              'This example demonstrates the powerful sharing capabilities '
              'of Flutter Share Pro',
              style: TextStyle(fontSize: 16),
              textAlign: TextAlign.center,
            ),
            const SizedBox(height: 32),
            const ContentPreview(),
            const SizedBox(height: 24),
            const ShareButton(),
            const SizedBox(height: 16),
            BlocBuilder<SharingBloc, SharingState>(
              builder: (context, state) {
                if (state is SharingLoading) {
                  return const Center(child: CircularProgressIndicator());
                } else if (state is SharingSuccess) {
                  return const Card(
                    child: Padding(
                      padding: EdgeInsets.all(16.0),
                      child: Text(
                        'Content shared successfully!',
                        style: TextStyle(color: Colors.green),
                        textAlign: TextAlign.center,
                      ),
                    ),
                  );
                } else if (state is SharingError) {
                  return Card(
                    child: Padding(
                      padding: const EdgeInsets.all(16.0),
                      child: Text(
                        'Error: ${state.message}',
                        style: const TextStyle(color: Colors.red),
                        textAlign: TextAlign.center,
                      ),
                    ),
                  );
                }
                return const SizedBox.shrink();
              },
            ),
            const SizedBox(height: 24),
            const Card(
              child: Padding(
                padding: EdgeInsets.all(16.0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(
                      'Features Demonstrated:',
                      style: TextStyle(
                        fontSize: 18,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    SizedBox(height: 8),
                    Text('• Custom share sheets'),
                    Text('• Content preview'),
                    Text('• BLoC state management'),
                    Text('• Cross-platform sharing'),
                    Text('• Material Design 3'),
                  ],
                ),
              ),
            ),
          ],
        ),
      );
}
2
likes
160
points
38
downloads

Publisher

verified publisherbechattaoui.dev

Weekly Downloads

Advanced sharing functionality with custom share sheets and content preview

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

cupertino_icons, equatable, flutter, flutter_bloc

More

Packages that depend on flutter_share_pro