better_dynamic_icon 0.0.1+1 copy "better_dynamic_icon: ^0.0.1+1" to clipboard
better_dynamic_icon: ^0.0.1+1 copied to clipboard

A plugin which allows you to change app icon and view all the app icons available for the application.

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';

import 'package:better_dynamic_icon/better_dynamic_icon.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  final _betterDynamicIconPlugin = BetterDynamicIcon();

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: [
            FutureBuilder(
                future: _betterDynamicIconPlugin.getAllIcons(),
                builder: (context, snapshot) {
                  if (snapshot.hasData) {
                    List<IconAndActivityName> iconAndActivityName = [];
                    snapshot.data?.forEach((value) {
                      iconAndActivityName.add(IconAndActivityName(
                        value: value,
                        betterDynamicIcon: _betterDynamicIconPlugin,
                      ));
                    });

                    return Expanded(
                        child: ListView(
                      children: iconAndActivityName,
                    ));
                  }
                  return Text('Fetching');
                }),
          ],
        ),
      ),
    );
  }
}

class IconAndActivityName extends StatelessWidget {
  const IconAndActivityName(
      {super.key, required this.value, required this.betterDynamicIcon});
  final IconDetails value;
  final BetterDynamicIcon betterDynamicIcon;

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: Image.memory(
        value.iconData,
        height: 24,
        width: 24,
      ),
      title: Row(
        children: [
          Text(value.label),
          ColoredBox(
            color: value.enabled ? Colors.green : Colors.grey,
            child: SizedBox(
              height: 10,
              width: 10,
            ),
          ),
        ],
      ),
      subtitle: Text(value.accessName),
      trailing: value.enabled
          ? null
          : FilledButton(
              onPressed: () {
                betterDynamicIcon.changeAppIcon(value.accessName).then((value) {
                  print(value);
                });
              },
              child: Text('Use')),
    );
  }
}
5
likes
150
points
0
downloads

Publisher

verified publisherflutterartist.com

Weekly Downloads

A plugin which allows you to change app icon and view all the app icons available for the application.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on better_dynamic_icon

Packages that implement better_dynamic_icon