TextTheme fields not match Sketch project text styles - flutter

I use material design plugin for Sketch to design my app. Now I need to set up my app theme to completely satisfy my prototype. There is no issues with colors. But with text I see mismatch of fields of TextTheme class and generated by plugin styles
Material typography:
headline1
headline2
headline3
headline4
headline5
headline6
subtitle1
subtitle2
body1
body2
button
caption
overline
TextTheme fields:
body1
body2
button
caption
display1
display2
display3
display4
headline
overline
subhead
subtitle
title
What is the correct fields matching here?

Found in reference:
NAME SIZE WEIGHT SPACING 2018 NAME
display4 112.0 thin 0.0 headline1
display3 56.0 normal 0.0 headline2
display2 45.0 normal 0.0 headline3
display1 34.0 normal 0.0 headline4
headline 24.0 normal 0.0 headline5
title 20.0 medium 0.0 headline6
subhead 16.0 normal 0.0 subtitle1
body2 14.0 medium 0.0 body1
body1 14.0 normal 0.0 body2
caption 12.0 normal 0.0 caption
button 14.0 medium 0.0 button
subtitle 14.0 medium 0.0 subtitle2
overline 10.0 normal 0.0 overline

Related

body2 is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. - warning message in flutter

If you update flutter SDK from version v1.12.13 to any version after v1.13.8, you will receive several warning messages related to textTheme usage. For example, one of them given below.
info: body2 is deprecated and shouldn't be used. This is the term used in the 2014 version of material design. The modern term is bodyText1. This feature was deprecated after v1.13.8..
what are the changes in the new version? how to migrate?
What are differences between text theme of material specification 2014 and text theme of material specification 2018?
The TextTheme API was originally based on the original material (2014)
design spec, which used different text style names.
Both values are given below.
The 2018 spec - Text styles
NAME SIZE WEIGHT SPACING
headline1 96.0 light -1.5
headline2 60.0 light -0.5
headline3 48.0 regular 0.0
headline4 34.0 regular 0.25
headline5 24.0 regular 0.0
headline6 20.0 medium 0.15
subtitle1 16.0 regular 0.15
subtitle2 14.0 medium 0.1
body1 16.0 medium 0.5 (bodyText1)
body2 14.0 regular 0.25 (bodyText2)
button 14.0 medium 1.25
caption 12.0 regular 0.4
overline 10.0 regular 1.5
The 2014 spec - Text style
NAME SIZE WEIGHT SPACING 2018 NAME
display4 112.0 thin 0.0 headline1
display3 56.0 normal 0.0 headline2
display2 45.0 normal 0.0 headline3
display1 34.0 normal 0.0 headline4
headline 24.0 normal 0.0 headline5
title 20.0 medium 0.0 headline6
subhead 16.0 normal 0.0 subtitle1
body2 14.0 medium 0.0 body1 (bodyText1)
body1 14.0 normal 0.0 body2 (bodyText2)
caption 12.0 normal 0.0 caption
button 14.0 medium 0.0 button
subtitle 14.0 medium 0.0 subtitle2
overline 10.0 normal 0.0 overline
How to use the new TextTheme attributes? (flutter version v1.13.8 and above)
You can use the desired attribute as shown below.
Theme.of(context).textTheme.headline1
Theme.of(context).textTheme.headline2
Theme.of(context).textTheme.headline3
Theme.of(context).textTheme.headline4
Theme.of(context).textTheme.headline5
Theme.of(context).textTheme.headline6
Theme.of(context).textTheme.subtitle1
Theme.of(context).textTheme.subtitle2
Theme.of(context).textTheme.body1
Theme.of(context).textTheme.body2
Theme.of(context).textTheme.button
Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline
What are attribute names that does not changed?
Only the following two attribute names are common in both Theme classes.
Theme.of(context).textTheme.caption
Theme.of(context).textTheme.overline

How to change text color of TextFormField according to theme

I want to change inputted text color as per the current theme, as text color is not a part of InputDecorationTheme.
As of now the only possible way to change inputted text color is to give style to TextFormField but that also not work when theme gets changed + in that way I need to repeat the similar code for each of my text field available in the app.
You can do by setting ThemeData as below .
MaterialApp(
theme: ThemeData(
textTheme: TextTheme(
subtitle1: TextStyle(fontSize: 50, fontWeight: FontWeight.bold),
),
)
...
you can do by using property subhead inside the TextTheme
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.orange,
accentColor: Colors.green,
textTheme: TextTheme(
subhead: TextStyle(color: Colors.blue),
),
),
Or by using this :
theme: ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.orange,
accentColor: Colors.green,
textTheme: Theme.of(context)
.textTheme
.apply(bodyColor: Colors.red)`enter code here`
),
A blog on Text Styling in Flutter https://medium.com/flutter-
community/beginners-guide-to-text-styling-in-flutter-3939085d6607
NOTE: The Material Design typography scheme was significantly changed in the
current (2018) version of the specification
more info https://material.io/design/typography.
The 2018 spec has thirteen text styles:
NAME SIZE WEIGHT SPACING
headline1 96.0 light -1.5
headline2 60.0 light -0.5
headline3 48.0 regular 0.0
headline4 34.0 regular 0.25
headline5 24.0 regular 0.0
headline6 20.0 medium 0.15
subtitle1 16.0 regular 0.15
subtitle2 14.0 medium 0.1
body1 16.0 regular 0.5 (bodyText1)
body2 14.0 regular 0.25 (bodyText2)
button 14.0 medium 1.25
caption 12.0 regular 0.4
overline 10.0 regular 1.5
where "light" is FontWeight.w300, "regular" is FontWeight.w400 and
"medium" is FontWeight.w500.
The [TextTheme] API was originally based on the original material (2014)
design spec, which used different text style names. For backwards
compatibility's sake, this API continues to expose the old names. The table
below should help with understanding the mapping of the API's old names and
the new names (those in terms of the 2018 material specification).
Each of the [TextTheme] text styles corresponds to one of the
styles from 2018 spec. By default, the font sizes, font weights
and letter spacings have not changed from their original,
2014, values.
NAME SIZE WEIGHT SPACING 2018 NAME
display4 112.0 thin 0.0 headline1
display3 56.0 normal 0.0 headline2
display2 45.0 normal 0.0 headline3
display1 34.0 normal 0.0 headline4
headline 24.0 normal 0.0 headline5
title 20.0 medium 0.0 headline6
subhead 16.0 normal 0.0 subtitle1
body2 14.0 medium 0.0 body1 (bodyText1)
body1 14.0 normal 0.0 body2 (bodyText2)
caption 12.0 normal 0.0 caption
button 14.0 medium 0.0 button
subtitle 14.0 medium 0.0 subtitle2
overline 10.0 normal 0.0 overline
You seem to be looking in the InputDecorationTheme instead of the TextTheme.
The color property you are looking for should be textTheme.body1.color as in:
Theme.of(context).textTheme.body1.color
If not this one, it should be another of the textTheme properties.

How to put opacity for container in flutter

I want to put opacity for container which contain hexadecimal color code. How can it be done?
Here is my current code:
final body = Container(
width: MediaQuery.of(context).size.width,
margin: const EdgeInsets.only(left: 40.0, right: 40.0),
padding: EdgeInsets.all(28.0),
decoration: new BoxDecoration(
color: const Color(0xFF0E3311),//here i want to add opacity
border: new Border.all(color: Colors.black54,
),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(40.0),
topRight: const Radius.circular(40.0),
bottomLeft: const Radius.circular(40.0),
bottomRight:const Radius.circular(40.0) )
),
child: Column(
children: <Widget>[ email, password,loginButton],
),
);
Change the line
const Color(0xFF0E3311)
to
const Color(0xFF0E3311).withOpacity(0.5)
or any value you want.
If you just want to set an opacity to your color it's simple as adding 2 hex numbers before your color code. Check this answer to know all the values.
But if you want to change the opacity of all the widget, in your case a Container, you can wrap it into a Opacity widget like this:
double _opacityValue = 0.50;//This value goes from 0.0 to 1.0. In this case the opacity is from 50%
final Widget _bodyWithOpacity = Opacity(
opacity: _opacityValue,
child: body,
);
Check here the Opacity's documentation and this quick video if you want to know more about it!
Flutter uses hexadecimal ARGB values for colors, which are formatted as const Color(0xAARRGGBB). That first pair of letters, the AA, represent the alpha channel. You must convert your decimal opacity values to a hexadecimal value.
Hex Opacity Values:
100% — FF
95% — F2
90% — E6
85% — D9
80% — CC
75% — BF
70% — B3
65% — A6
60% — 99
55% — 8C
50% — 80
45% — 73
40% — 66
35% — 59
30% — 4D
25% — 40
20% — 33
15% — 26
10% — 1A
5% — 0D
0% — 00
For instance:
static const Color mainColor = Color(0xff0097A7);
to:
static Color accentColor = Color(0x1A0097A7);
will change the opacity to 10%.
We can use Color.fromRGBO(255, 255, 255, 0.5) for opacity as well.
Flutter uses a 32 bit color value in ARGB format, where A = Alpha, R = RED, G = GREEN and B = BLUE.
So to control the opacity you can change the values of first two digits of the hex value in const Color(0xFF0E3311), you can use values ranging from 0x000E3311,0x010E3311....0xFF0E3311.
Hope that helps!
here in code
const Color(0xFF0E3311)
after 0x two values (in above code 'FF') are for opacity. 'FF' for opaque and '00' for fully transparent. so by altering this value you can change color opacity.
Also we get by Colors class diff opacity value color for white and black. for example
Colors.white70 means white color with 70% opacity

coordinate outside allowed range iText exception

The llx, lly , urx, ury of co-ordinates are mentioned below
401.74042 747.38 406.18842 753.91815
405.9332 747.38 410.3812 753.91815
410.126 747.38 414.574 753.91815
I am trying to clean up the text in these locations using iText. Only text exists in these locations since I have got these co-ordinates using the renderText method of RenderListener.
The page size is Rectangle: 595.0x842.0 (rot: 0 degrees)
I am getting a "java.lang.IllegalStateException: Coordinate outside allowed range" exception only with this PDF with iText 5.5.11
I found "Exception occur :Reason : Coordinate outside allowed range java.lang.IllegalStateException: Coordinate outside allowed range" and it does not seem to help. Any help would be appreciated
stack trace
java.lang.IllegalStateException: Coordinate outside allowed range
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.rangeTest(ClipperBase.java:119)
at com.itextpdf.text.pdf.parser.clipper.ClipperBase.addPath(ClipperBase.java:192)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.addRect(PdfCleanUpRegionFilter.java:423)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterFillPath(PdfCleanUpRegionFilter.java:176)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRegionFilter.filterStrokePath(PdfCleanUpRegionFilter.java:160)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.filterCurrentPath(PdfCleanUpRenderListener.java:387)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpRenderListener.renderPath(PdfCleanUpRenderListener.java:224)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.paintPath(PdfContentStreamProcessor.java:400)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.access$6300(PdfContentStreamProcessor.java:83)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor$PaintPath.invoke(PdfContentStreamProcessor.java:1218)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpContentOperator.invoke(PdfCleanUpContentOperator.java:139)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.invokeOperator(PdfContentStreamProcessor.java:310)
at com.itextpdf.text.pdf.parser.PdfContentStreamProcessor.processContent(PdfContentStreamProcessor.java:448)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUpPage(PdfCleanUpProcessor.java:159)
at com.itextpdf.text.pdf.pdfcleanup.PdfCleanUpProcessor.cleanUp(PdfCleanUpProcessor.java:134)
(also here)
graphics state
The graphics state at the time of the exception:
Page Number: 1
Horizontal scaling:1.0
Render Mode: 0
Transformation matrix: 1.0 0.0 0.0
0.0 1.0 0.0
0.0 0.0 1.0
Character spacing: 0.0
Font size: 0.0
Leading: 0.0
Line Cap Style: 0
Line join style: 0
Line wodth: 1.0
Miter limit: 10.0
Rise: 0.0
Word Spacing: 0.0
Color space fill: null
Color space stroke: null
Fill color: null
Font: null
Line dash pattern: null
Stroke color: null
Is knockout: true
(also here)

UITableViewCell layoutMargin and separatorInset not "in sync" when in PageSheet

Simple scenario, but the problem is driving me crazy..
What I want to achieve:
UITableViewCell's contentView to be aligned with separatorInset in each and every scenario.
Result: The layoutMargin.left is different from separatorInset when shown in a Popover as page sheet (i.e. iPhone 6/6S Plus) with iOS 8.1-8.2 and iOS 9.x. iOS 8.3 and 8.4 work fine.
Cell Settings:
preservesSuperviewLayoutMargins and contentView.preservesSuperviewLayoutMargins are true
autoLayout of Label is pinned to superView margins with constant 0
Investigations:
If found this post from matt, explaining the underlying problem a bit:
https://stackoverflow.com/a/29712427/844907
I implemented a layoutDidChange method to check the margins:
override func layoutMarginsDidChange() {
debugPrint("layoutMarginsDidChange: ", layoutMargins.left, contentView.layoutMargins.left, separatorInset.left)
}
Some of the returned values after a few rotations from PageSheet to FullScreen:
"layoutMarginsDidChange: " 16.0 16.0 20.0 ("real" popOver on 6+ with 8.2)
"layoutMarginsDidChange: " 20.0 20.0 20.0 (FullScreen 6+ with 8.2)
Or on iPhone 6+ 9.3:
FullScreen (both lines!):
"layoutMarginsDidChange: " 8.0 8.0 20.0
"layoutMarginsDidChange: " 20.0 20.0 20.0
After rotation to pageSheet:
"layoutMarginsDidChange: " 16.0 16.0 20.0
Last value is the separator.left, first two are the layoutMargins.left and contentView.layoutMargins.left.
Any idea how to fix this?
I though of setting layoutMargins.left to separatorInset.left but this doesn't felt right without knowing the source of the problem..
See images below: