I am currently working on the Flutter package and want to add an outlined wavy liquid text as below.
Is there any feature to add this in the Text widget?
there is this flutter package animated_text_kit 2.2.0. Which could be used to give a wavy animation to the text. I am leaving the link down below
https://pub.dev/packages/animated_text_kit
width: 250.0,
child: TextLiquidFill(
text: 'LIQUIDY',
waveColor: Colors.blueAccent,
boxBackgroundColor: Colors.redAccent,
textStyle: TextStyle(
fontSize: 80.0,
fontWeight: FontWeight.bold,
),
boxHeight: 300.0,
),
);
Related
I am fairly new to flutter and just stumbled across something that seems odd to me with regards to how style is affecting widgets further down the tree.
Consider the following example:
ElevatedButton(
style: ElevatedButton.styleFrom(
textStyle: const TextStyle(
fontSize: 17.0,
fontWeight: FontWeight.bold,
color: Colors.red,
)
),
onPressed: () { print("testados"); },
child: const Text(
"some testadorian text",
style: TextStyle(color: Colors.red),
),
);
I could verify that changing fontSize and fontWeight in lines 4 and 5 did produce the
expected effect. But setting the color inside the textStyle of ElevatedButton.styleFrom didn't have any visible effect at all.
Setting the color inside style of Text did produce the expected result.
What I understood so far was that Text-widgets take what is available as default-theming further up the widget tree and override those defaults when a specific property is directly set on themselves.
What am I missing out to understand this behaviour?
Do you have any pointers on how to animate TextSpan or part of a text in Flutter to achieve the same effect than in this game screenshot?
I know how to animate a whole text with typewriter effect but not how to animate only part of the text.
Any help will be appreciated. Thanks so much!
There are packages that can do that, for example https://www.geeksforgeeks.org/animated-text-in-flutter/ using the animated_text_kit
AnimatedTextKit(
animatedTexts: [
TyperAnimatedText('This is Animated text,',
textStyle: const TextStyle(
color: Colors.white,
fontSize: 30,
backgroundColor: Colors.purple)),
TyperAnimatedText('You are viewing it here.',
textStyle: const TextStyle(
fontSize: 20, fontWeight: FontWeight.bold)),
],
onTap: () {
print("I am executing");
},
),
As showing the given image After applying underline decoration text style to the text it shows line above text instead of below in flutter 2.2.
TextButton(
onPressed: () {},
child: Text(
getLocalValue(context, txtTermsNConditions),
style: TextStyle(
fontSize: 12.sp,
fontWeight: fwMedium,
color: Color(clrPrimary),
decoration: TextDecoration.underline),
),
)
style: TextStyle(decoration: TextDecoration.overline) will do the trick see this link for more information.
You can do with a shortcut just use a Stack and place both Text and a Divider Widget in it and gave then position according to your Requirements that's all.
That was a problem with fonts I have used, using another font it has been resolved.
I'm searching for a way to display a Google Font in small caps.
I'm using the google_fonts package.
You can use the FontFeature property inside a TextStyle like this:
Text('This is a Google Font',
style: GoogleFonts.lato(
textStyle: TextStyle(fontFeatures:[FontFeature.enable('smcp')], color: Colors.blue, letterSpacing: .5),
//smcp as in small caps
),
),
I am developing on a Pixel 2 simulator and of course, the font size that I use are very good for that phone.
When going on a iPhone 5S, I was expecting to see the font size to be reduced and be proportional to that screen resolution. Maybe Flutter does something, but is it not easy to see at the first place.
I found 'flutter_screenutil' plugin, but not working as expected. Probably because I don't put the right values for the ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context); The values are the 'screen size of the device in the design' of a iphone 6 (based on the example).
If I use the plugin with font size 100 on my Blackberry Motion(1080x1794), the result is what I expect. Using the same code with an iphone 6(750x1334), I should use font size 70. Not very useful.
Anybody has a nice way to handle the font size for different resolution without changing the font size value put in the code?
You can try using Google fonts. As Flutter works with custom fonts and you can apply a custom font across an entire app or to individual widgets. I was not able to see any issues while running ‘Pacifico’ family with font size 20. I also tested the following test code on Pixel 3 and Iphone 11, and do not see any issues.
Steps are simple as described in the flutter documentation:
Import the font files.
Declare the font in the pubspec. In may case I downloaded the
Pacifico from https://fonts.google.com/specimen/Pacifico?selection.family=Pacifico
Use a font in a specific widget.
My pubspec.yaml file:
flutter:
fonts:
- family: Pacifico
fonts:
- asset: fonts/Pacifico-Regular.ttf
My main.dart file :
` Widget build(BuildContext context) {
return MaterialApp(
title: 'Font test',
home: Scaffold(
backgroundColor: Colors.white,
body: SafeArea(
child: Column(
children: <Widget>[
Container(
height: 100.0,
width: 100.0,
color: Colors.red,
child: Text(
'container one',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 20.0,
),
),
),
Container(
height: 100.0,
width: 100.0,
color: Colors.blue,
child: Text(
'container two',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 20.0,
),
),
),
Container(
height: 100.0,
width: 100.0,
color: Colors.purple,
child: Text(
'container three',
style: TextStyle(
fontFamily: 'Pacifico',
fontSize: 20.0,
),
),
),
],
),
),
)
);
}
If you are having any issues with the fonts let me know, Also, as you see it’s the basic sample app. I would appreciate if you can help me out with the code sample to reproduce the issue. I do not have my Mac machine to help you with the screen shot. I will update this thread with the screen shot, once I have my Maclaptop