Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fluent UI is incompatible with Flutter Material #150

Closed
BugsOverBugs opened this issue Feb 4, 2022 · 3 comments
Closed

Fluent UI is incompatible with Flutter Material #150

BugsOverBugs opened this issue Feb 4, 2022 · 3 comments

Comments

@BugsOverBugs
Copy link

BugsOverBugs commented Feb 4, 2022

This package is great but it doesn't work in a single codebase with material.

As an example I want to build a custom class called AdaptiveCheckbox. This class decides which Checkbox should be used:

if(Platform.isWindows) return Checkbox(); //Fluent UI

if(Platform.isAndroid) return Checkbox(); //Material

Errors occurre at ThemeData, TextButton, Tab, Divider, Scrollbar, Tooltip, showDialog TextStyle or Colors.

The error message is:
The name 'ThemeData' is defined in the libraries 'package:fluent_ui/src/styles/theme.dart (via package:fluent_ui/fluent_ui.dart)' and 'package:flutter/src/material/theme_data.dart (via package:flutter/material.dart)'. (ambiguous_import at [demo] lib/src/constants/theme.dart:113)
or
'TextButton' isn't a function. (invocation_of_non_function at [demo] lib/src/widgets/buttons/blank_button.dart:136)

Solution
Could you please rename overlapping class names to something like FluentName or FlName.

That would be so helpful.

@jolleekin
Copy link

Did you try using library prefix? https://dart.dev/guides/language/language-tour#using-libraries

import 'package:lib2/lib2.dart' as lib2;

@BugsOverBugs
Copy link
Author

BugsOverBugs commented Feb 4, 2022

@jolleekin Thanks for your response.

No, I didn't.

It may work but the linter doesn't fully support it (regarding suggestions). Or is there a option to enable this.

@bdlukaa
Copy link
Owner

bdlukaa commented Feb 4, 2022

Hello! You can use the as keyword when importing the package:

import 'package:fluent_ui/fluent_ui.dart' as fluent_ui;
import 'package:flutter/material.dart';

And use it using the prefix fluent_ui:

if(Platform.isWindows) return fluent_ui.Checkbox(); //Fluent UI

if(Platform.isAndroid) return Checkbox(); //Material

@bdlukaa bdlukaa closed this as completed Feb 4, 2022
@bdlukaa bdlukaa pinned this issue Feb 4, 2022
Repository owner locked as resolved and limited conversation to collaborators Nov 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants