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

outdated

A new flutter plugin project.

example/lib/main.dart

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

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

void main() => runApp(MyApp());

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

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

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

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String googleMapsApiKey;
    try {
      googleMapsApiKey = await FlutterNativeConfig.getConfig(name: 'CFBundleName');
    } on PlatformException {
      googleMapsApiKey = 'Failed to get CFBundleName.';
    }

    if (mounted) {
      setState(() {
        _googleMapsApiKey = googleMapsApiKey;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('CFBundleName: $_googleMapsApiKey\n'),
        ),
      ),
    );
  }
}
2
likes
30
pub points
36%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_native_config