flowconfig_flutter 1.1.0 copy "flowconfig_flutter: ^1.1.0" to clipboard
flowconfig_flutter: ^1.1.0 copied to clipboard

Official FlowConfig SDK. Remote configuration, feature flags, maintenance mode, force update, and dynamic UI for mobile apps. Update instantly without new releases.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flowconfig_flutter/flowconfig.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  
  try {
    await FlowConfig.initialize(
      sdkKey: 'test_key',
      debugMode: true,
    );
  } catch (e) {
    debugPrint('Failed to initialize FlowConfig: $e');
  }

  // 1. Maintenance Check before runApp
  if (FlowConfig.shouldShowMaintenance('1.0.0')) {
    runApp(const MaintenanceApp());
    return;
  }



  runApp(const MyApp());
}

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    // 7. Background sync listener
    FlowConfig.onConfigUpdated.listen((_) {
      if (mounted) setState(() {});
    });

    // Show Force Update or Announcement using the pre-built SDK UI components
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final status = FlowConfig.checkVersion('1.0.0');
      
      if (status == VersionStatus.updateRequired || status == VersionStatus.updateAvailable) {
        FcVersionDialog.show(context);
      } else if (FlowConfig.hasAnnouncement) {
        FcAnnouncementDialog.show(context);
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    // Check maintenance dynamically
    if (FlowConfig.shouldShowMaintenance('1.0.0')) {
      return const MaintenanceApp();
    }

    // 4. Config values usage
    final primaryColor = FlowConfig.getColor('primary_color', defaultValue: Colors.blue);
    final appTitle = FlowConfig.getString('app_title', defaultValue: 'FlowConfig Example');

    // 5. Feature flags usage
    final showNewFeature = FlowConfig.isEnabled('new_feature');

    return MaterialApp(
      title: appTitle,
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: primaryColor),
        useMaterial3: true,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text(appTitle),
          backgroundColor: primaryColor,
          foregroundColor: Colors.white,
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Welcome to $appTitle!'),
              const SizedBox(height: 20),
              if (showNewFeature)
                const Card(
                  child: Padding(
                    padding: EdgeInsets.all(16.0),
                    child: Text('🚀 New Feature Enabled!'),
                  ),
                ),
              const SizedBox(height: 20),
              ElevatedButton(
                onPressed: () {
                  // 8. Custom analytics tracking
                  FlowConfig.track('button_clicked', data: {'button': 'test'});
                },
                child: const Text('Track Event'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    final status = FlowConfig.maintenanceStatus;
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Icon(Icons.build, size: 64),
              const SizedBox(height: 16),
              Text(status.title, style: const TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
              const SizedBox(height: 8),
              Text(status.message),
            ],
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Icon(Icons.update, size: 64),
              const SizedBox(height: 16),
              const Text('Update Required', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
              const SizedBox(height: 8),
              Text(FlowConfig.customMessage ?? 'Please update to continue using the app.'),
              const SizedBox(height: 24),
              ElevatedButton(
                onPressed: () {
                  final url = FlowConfig.playStoreUrl ?? FlowConfig.appStoreUrl ?? 'https://store.example.com';
                  debugPrint('Opening Store URL: $url');
                  // In a real app, use url_launcher to open this URL
                },
                child: const Text('Update Now'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
65
downloads

Documentation

API reference

Publisher

verified publisherflowconfig.site

Weekly Downloads

Official FlowConfig SDK. Remote configuration, feature flags, maintenance mode, force update, and dynamic UI for mobile apps. Update instantly without new releases.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

crypto, flutter, hive, hive_flutter, http, package_info_plus, path_provider

More

Packages that depend on flowconfig_flutter