remote_widget_hideable 0.0.1
remote_widget_hideable: ^0.0.1 copied to clipboard
A Flutter widget to remotely show or hide UI components using Cloud Firestore real-time updates. Useful for feature flagging and review.
Remote Widget Hideable #
A simple Flutter widget to show or hide UI components remotely using Cloud Firestore. Useful for feature flagging, hiding components during app review, or A/B testing.
Repository: https://github.com/kedirinesia/remote-hideable-widget-
Features #
- Real-time Updates: Listens to Firestore document changes.
- Null Safety: Robust error handling and default values.
- Custom placeholders: Show a specific widget (or nothing) when hidden.
Installation #
Add dependencies to pubspec.yaml:
dependencies:
cloud_firestore: latest_version
remote_widget_hideable:
path: ./ # or git path
Usage #
import 'package:flutter/material.dart';
import 'package:remote_widget_hideable/remote_widget_hideable.dart';
class MyPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: RemoteHideable(
collection: 'app_config',
document: 'checkout_settings',
field: 'enable_promo_banner',
initialValue: false, // Default while loading
placeholder: Text('Promo is currently disabled'), // Optional
child: Container(
color: Colors.red,
padding: EdgeInsets.all(20),
child: Text(' BIG PROMO! '),
),
),
),
);
}
}
Firestore Structure #
Ensure you have a document in Firestore matching the path:
- Collection:
app_config - Document:
checkout_settings - Field:
enable_promo_banner(boolean)
If true, the child widget is shown. If false, it's hidden.
Configuration Example #
A .env.example file is included in the package root to help you structure your environment variables if needed:
# Firestore Remote Config Example
REMOTE_COLLECTION=app_config
REMOTE_DOCUMENT=global_settings
REMOTE_FIELD=enable_feature_x