-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
change copy/paste menu theme and text style #42122
Comments
CC @justinmc |
This is confusing because the selection menu is in the top level Overlay, so it doesn't necessarily receive the Theme nearest to its TextField in the tree. Here is an example of setting different themes for the selection menu and the app background. import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
// This theme will apply to the text selection menu.
theme: ThemeData(
canvasColor: Color.fromRGBO(0, 0, 255, 1),
),
home: Theme(
// This theme will apply to the app background.
data: ThemeData(
canvasColor: Color.fromRGBO(10, 10, 10, 1),
),
child: Scaffold(
body: Center(
child: TextField(),
),
),
),
);
}
} |
hi @justinmc, thank you very much for your time, but i was looking forward to change the textstyle of the copy/paste menu, not only the background color. I think this shouldn't be closed yet |
Hmm it looks like |
a menú like this white letters over black background already used this MaterialColor on primarySwatch
but the best i got is replacing the blueish circles and shadow selection to white circles and shadow i'm getting near, actually that white shadow looks better on the dark background, but i still can't accomplish white letters *note: i changed the canvas color to red, so you can see that the cut/copy/paste words are still in black color this is my full theme data:
and this is the color palette
thanks for the patience 🙇 |
I just tried quickly and couldn't get it to change the text color. I'm going to try to figure out what the long term idea is for this sort of thing at the end of the week. In the meantime, the actual buttons are created here as FlatButtons with Text inside of them. If you were open to hacking your copy of the Flutter framework, you could definitely pass in color and textColor there. Or you could also fully customize the menu by implementing your own TextSelectionControls to pass in to EditableText: https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/widgets/editable_text.dart#L739 Long term, we have some things with theming that we'd like to clean up, and some known issues with theming inside of an Overlay (as the text selection menu is). We also would like to provide a better interface for customization of the selection menu. None of this is likely to solve your problem in the next few days, though. |
for your problem, you just need to add brightness to ThemeData.
|
Here is a design document for upcoming theme work that discusses potential changes to selection menu theming: https://docs.google.com/document/d/1kzIOQN4QYfVsc5lMZgy_A-FWGXBAJBMySGqZqsJytcE/edit#heading=h.odkaoncg37sq |
The primarySwatch didn't seem to work for me, but changing |
Is there a more direct way of changing the text colour other than changing the brightness parameter in the main theme |
You can also define a ThemeData get lightTheme => const ColorScheme(
brightness: Brightness.light,
onSurface: CustomColors.black,
surface: CustomColors.white,
....
);
ThemeData theme(ColorScheme colorScheme) => ThemeData(
textSelectionTheme : TextSelectionThemeData(
cursorColor: colorScheme.onSurface,
selectionColor: colorScheme.brightness == Brightness.light
? Colors.black.withOpacity(0.4)
: Colors.white.withOpacity(0.4),
selectionHandleColor: colorScheme.secondary,
),
);
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: lightTheme,
...
);
}
} |
Hey, any updates concerning this problem? It's like we have no high level control over the copy / paste menu |
Lately there have been many changes in theming, could this feature be implemented in the near future? Would be nice to post an update. Thanks :) |
You can now completely customize the text selection toolbar on mobile. Sorry, I should have updated this issue earlier. TextSelectionToolbar, a public widget that imitates the native Android text selection toolbar: https://master-api.flutter.dev/flutter/material/TextSelectionToolbar-class.html TextSelectionToolbarTextButton, a public widget that imitates the buttons in that widget: https://master-api.flutter.dev/flutter/material/TextSelectionToolbarTextButton-class.html |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
I changed the global theme data, specifically the canvasColor property to a black color,
but now the copy/paste menu shows black words over a black background, making it unreadable
How can i change the textstyle of this menu?
The text was updated successfully, but these errors were encountered: