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

A collection of useful Flutter and Dart extensions to simplify common tasks.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:mplix/mplix.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Mplix Extensions Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.deepPurple),
      home: const DemoHomePage(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    final name = 'flutter dev';
    final emojiText = 'I love :pizza: and :coffee: from :india:!'.withEmojis();
    final now = DateTime.now();

    return Scaffold(
      appBar: AppBar(title: const Text('🧩 Mplix Demo')),
      body: SingleChildScrollView(
        padding: 16.0.toAll,
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            _sectionTitle('πŸ“ String Extensions'),
            Text('Original: $name'),
            Text('Capitalize: ${name.capitalize()}'),
            Text('Title Case: ${name.toTitleCase()}'),
            Text(
              'Sentence Case: ${'hello world. this is flutter.'.capitalizeSentences()}',
            ),
            Text('To Int: ${'123'.toInt()}'),
            Text('To Double: ${'12.34'.toDouble()}'),

            20.spacingY(),
            _sectionTitle('πŸ’¬ Emoji Extension'),
            Text(emojiText),

            20.spacingY(),
            _sectionTitle('πŸ§ͺ Nullable Extension'),
            Text('Is null or blank: ${null.isNullOrBlank}'),

            20.spacingY(),
            _sectionTitle('πŸ“† DateTime Extensions'),
            Text('Formatted: ${now.format()}'),
            Text('Short: ${now.short}'),
            Text('Time: ${now.time}'),
            Text('Full: ${now.fullDateTime}'),
            Text('Is today: ${now.isToday}'),

            20.spacingY(),
            _sectionTitle('🎨 Color Extension'),
            Container(
              height: 40,
              width: 120,
              color: Colors.teal,
              alignment: Alignment.center,
              child: Text(
                Colors.teal.toHex(),
                style: const TextStyle(color: Colors.white),
              ),
            ),

            20.spacingY(),
            _sectionTitle('πŸ“¦ Iterable Extension'),
            ...[
              'One',
              'Two',
              'Three',
            ].mapIndexed((i, val) => Text('$i β†’ $val')),

            20.spacingY(),
            _sectionTitle('πŸ“ Context Extensions'),
            Text('Width: ${context.width}'),
            Text('Height: ${context.height}'),
            Text('Primary color: ${context.theme.primaryColor.toHex()}'),

            20.spacingY(),
            _sectionTitle('πŸ“Ž Clipboard & Snackbar'),
            ElevatedButton(
              onPressed: () {
                context.copyToClipboard(
                  'Copied via Mplix!',
                  successMessage: 'βœ… Copied to clipboard',
                );
              },
              child: const Text('Copy Text'),
            ),

            10.spacingY(),
            ElevatedButton(
              onPressed: () {
                context.showSnackbar('Hello from snackbar!');
              },
              child: const Text('Show Snackbar'),
            ),

            20.spacingY(),
            _sectionTitle('πŸ” Navigation & Loader'),
            ElevatedButton(
              onPressed: () {
                context
                    .withLoadingDialog(
                      Future.delayed(const Duration(seconds: 2), () => 'Done'),
                      message: 'Loading demo...',
                    )
                    .then((result) {
                      context.showSnackbar('Loaded result: $result');
                    });
              },
              child: const Text('Show Loader and Then Snackbar'),
            ),

            20.spacingY(),
            _sectionTitle('πŸ“ Widget Extensions'),
            Container(
              padding: 8.0.toAll,
              color: Colors.orange,
              child: const Text(
                'Tap Me',
              ).onTap(() => 'Tapped!'.log(tag: 'WIDGET')).paddingAll(8),
            ),

            20.spacingY(),
            _sectionTitle('πŸ›  Utility Extensions'),
            ElevatedButton(
              onPressed: () {
                'Logged from Mplix'.log(tag: 'DEBUG');
              },
              child: const Text('Log to Debug Console'),
            ),
          ],
        ),
      ),
    );
  }

  Widget _sectionTitle(String title) {
    return Text(
      title,
      style: const TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
    );
  }
}
1
likes
0
points
192
downloads

Publisher

verified publishermplifytech.com

Weekly Downloads

A collection of useful Flutter and Dart extensions to simplify common tasks.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_spinkit, intl

More

Packages that depend on mplix