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

outdated

Plugin to support managed app configuration provided by a Mobile device management (MDM).

example/lib/main.dart

import 'dart:convert';

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

import 'package:flutter/services.dart';
import 'package:managed_configurations/managed_configurations.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _managedAppConfigurations = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String managedAppConfigurations;
    try {
      managedAppConfigurations = json.encode(
          await ManagedConfigurations.getManagedConfigurations ??
              'no managed app configurations');
    } on PlatformException {
      managedAppConfigurations = 'Failed to get managed app configurations.';
    }
    if (!mounted) return;

    setState(() {
      _managedAppConfigurations = managedAppConfigurations;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Managed App Config'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('Managed app config: $_managedAppConfigurations\n'),
              StreamBuilder<Map<String, dynamic>?>(
                stream: ManagedConfigurations.mangedConfigurationsStream,
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    return Text(json.encode(snapshot.data));
                  } else {
                    return Text("No changes at the moment");
                  }
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}
18
likes
0
points
23.5k
downloads

Publisher

unverified uploader

Weekly Downloads

Plugin to support managed app configuration provided by a Mobile device management (MDM).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on managed_configurations