Fintasys / emoji_picker_flutter

A Flutter package that provides an Emoji picker widget with 1500+ emojis in 8 categories.
MIT License
154 stars 114 forks source link

Bug: multiple tabs shown #162

Closed agufagit closed 8 months ago

agufagit commented 8 months ago

When switching between keyboard and emoji picker panel multiple times, following flutter error is shown

FlutterError (Controller's length property (9) does not match the number of tabs (17) present in TabBar's tabs property.)

tabs

Fintasys commented 8 months ago

Seen that around a few times, can you check if your widgets used in config are 'const'?

agufagit commented 8 months ago

Seen that around a few times, can you check if your widgets used in config are 'const'?

Here is my code

EmojiPicker(
      textEditingController: textController,
      onBackspacePressed: () {},
      config: Config(
            columns: 7,
            emojiSizeMax: 32 * (Platform.isIOS ? 1.30 : 1.0), // Issue: https://github.com/flutter/flutter/issues/28894
            verticalSpacing: 0,
            horizontalSpacing: 0,
            gridPadding: EdgeInsets.zero,
            initCategory: Category.RECENT,
            bgColor: colorScheme.background,
            indicatorColor: Colors.blue,
            iconColor: Colors.grey,
            iconColorSelected: Colors.blue,
            backspaceColor: Colors.blue,
            skinToneDialogBgColor: Colors.white,
            skinToneIndicatorColor: Colors.grey,
            enableSkinTones: true,
            recentTabBehavior: RecentTabBehavior.RECENT,
            recentsLimit: 28,
            noRecents: Text(
                  t.noRecents,
                  style: textTheme.titleLarge?.copyWith(color: colorScheme.onBackground),
                  textAlign: TextAlign.center,
            ), // Needs to be const Widget
            loadingIndicator: const SizedBox.shrink(), // Needs to be const Widget
            tabIndicatorAnimDuration: kTabScrollDuration,
            categoryIcons: const CategoryIcons(),
            buttonMode: ButtonMode.MATERIAL,
      ),
)
Fintasys commented 8 months ago
            noRecents: Text(
                  t.noRecents,
                  style: textTheme.titleLarge?.copyWith(color: colorScheme.onBackground),
                  textAlign: TextAlign.center,
            ), // Needs to be const Widget

As it is already written here, it needs to be const. If you use localization here then you need to wrap it into a Stateless Widget.

e.g.

class NoRecents extends StatelessWidget {
    @override
   void build() {
       return Text(
                  t.noRecents,
                  style: textTheme.titleLarge?.copyWith(color: colorScheme.onBackground),
                  textAlign: TextAlign.center,
            );
   }
}

and

noRecents: const NoRecents()