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

Flutter package thats helps you to patch your widget/code with json data.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: FutureBuilder<void>(
            future: PatchPal.setUp(
              'https://raw.githubusercontent.com/yeasin50/AssetsFor_/master/apps/patch_pal/test.json',
            ),
            builder: (context, snapshot) {
              if (snapshot.connectionState == ConnectionState.done) {
                if (snapshot.hasError) {
                  return const Center(
                    child: Text('Error'),
                  );
                } else {
                  return Column(
                    mainAxisSize: MainAxisSize.max,
                    children: [
                      PatchPal.switcher(
                        patchItemName: 'rain',
                        onPatch: const Text('It is raining'),
                        onNoPatch: const Text('This is a text'),
                      ),
                      PatchPal.switcher(
                        patchItemName: 'rain',
                        onNoPatch: const Text('This is a text'),
                      ),
                      PatchPal.switcher(
                        patchItemName: 'unknown',
                        onNoPatch: const Text('This is a text'),
                        tristate: true,
                      ),
                      const Divider(),
                      const Text("Overlay"),
                      Container(
                        height: 200,
                        width: 200,
                        color: Colors.red,
                        child: PatchPal.overlay(
                          patchItemName: 'rain',
                          alignment: Alignment.bottomCenter,
                          child: const Text('Beta test,raining'),
                        ),
                      ),
                      const Divider(),
                      const Text("Dialog"),
                      Builder(builder: (ctx) {
                        PatchPal.dialog(
                          context: context,
                          patchItemName: 'rain',
                          title: 'Rain',
                          message: 'It is raining',
                          positiveText: 'Ok',
                          negativeText: 'Cancel',
                          onPositive: () {
                            Navigator.pop(context);
                          },
                          onNegative: () {
                            Navigator.pop(context);
                          },
                        );

                        return const Text('auto show dialog');
                      }),
                      const Divider(),
                      const Text("View"),
                      PatchPal.view(
                        patchItemName: 'rain',
                        onPositive: const Text('It is raining'),
                        child: const Text('This is a text'),
                      ),
                      PatchPal.view(
                        patchItemName: 'rain',
                        child: const Text('This is a text'),
                      ),
                      PatchPal.view(
                        patchItemName: 'unknown',
                        child: const Text('This is a text'),
                      ),
                    ],
                  );
                }
              } else {
                return const Center(
                  child: CircularProgressIndicator(),
                );
              }
            },
          ),
        ),
      ),
    );
  }
}
4
likes
160
points
14
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter package thats helps you to patch your widget/code with json data.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, http, mockito

More

Packages that depend on patch_pal