iconoir-icons / iconoir

An open source icons library with 1600+ icons, supporting React, React Native, Flutter, Vue, Figma, and Framer.
https://iconoir.com
MIT License
3.88k stars 169 forks source link

[FEAT] On flutter, try to get color from IconTheme closest context #450

Open ceopaludetto opened 5 months ago

ceopaludetto commented 5 months ago

Is your feature request related to a problem? Please describe. Right now you need to manually change the icon color when using the flutter package

Describe the solution you'd like The template should use the following order:

final colorToUse = color ?? IconTheme.of(context).color

Describe alternatives you've considered Right now I'm using a really simple builder to get the current color in the context and send to the icon

import 'package:flutter/material.dart';

class WithContextColor extends StatelessWidget {
  const WithContextColor({super.key, required this.builder});

  final Widget Function(Color?) builder;

  @override
  Widget build(BuildContext context) {
    final color = IconTheme.of(context).color;
    return builder(color);
  }
}

Usage

NavigationDestination(
  label: "Home",
  icon: WithContextColor(builder: (color) => HomeSimple(color: color)),
),

Upvote & Fund

Fund with Polar