Skip to content

Commit 45b0b48

Browse files
committed
Example app updates.
1 parent 1955f1c commit 45b0b48

4 files changed

Lines changed: 37 additions & 69 deletions

File tree

example/lib/pages/basic_ltr.dart

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class BasicLtr extends StatelessWidget {
1111
@override
1212
Widget build(BuildContext context) {
1313
final scale =
14-
(((MediaQuery.of(context).size.width / 600.0) - 1.0) * 0.6) + 1.0;
14+
(((MediaQuery.of(context).size.width / 600.0) - 1.0) * 0.3) + 1.0;
1515

1616
return DefaultTextStyle(
1717
style: const TextStyle(fontSize: 18, color: Colors.black, height: 1.5),
@@ -76,8 +76,8 @@ TextSpan _text(BuildContext context, double textScaleFactor) => TextSpan(
7676
child: Floatable(
7777
float: FCFloat.end,
7878
clear: FCClear.both,
79-
clearMinSpacing: 16,
80-
maxWidthPercentage: 0.33,
79+
clearMinSpacing: -50 * textScaleFactor,
80+
maxWidthPercentage: 0.33 / textScaleFactor,
8181
padding: const EdgeInsetsDirectional.only(start: 8),
8282
child: Img(
8383
assetName: _name('walt_whitman.jpg'), title: 'Walt Whitman'),
@@ -87,7 +87,7 @@ TextSpan _text(BuildContext context, double textScaleFactor) => TextSpan(
8787
child: Floatable(
8888
float: FCFloat.start,
8989
clear: FCClear.start,
90-
clearMinSpacing: 220,
90+
clearMinSpacing: 65 * textScaleFactor,
9191
maxWidthPercentage: 0.25 / textScaleFactor,
9292
padding: const EdgeInsetsDirectional.only(end: 12),
9393
child: Img(
@@ -108,8 +108,10 @@ TextSpan _text(BuildContext context, double textScaleFactor) => TextSpan(
108108
),
109109
recognizer: TapGestureRecognizer()
110110
..onTap = () {
111-
ScaffoldMessenger.of(context).showSnackBar(
112-
const SnackBar(content: Text('Tapped on "Love"')));
111+
ScaffoldMessenger.of(context)
112+
..removeCurrentSnackBar()
113+
..showSnackBar(
114+
const SnackBar(content: Text('Tapped on "Love"')));
113115
},
114116
),
115117
const TextSpan(
@@ -125,9 +127,11 @@ TextSpan _text(BuildContext context, double textScaleFactor) => TextSpan(
125127
),
126128
recognizer: TapGestureRecognizer()
127129
..onTap = () {
128-
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
129-
content:
130-
Text('Tapped on "stand up for the stupid and crazy"')));
130+
ScaffoldMessenger.of(context)
131+
..removeCurrentSnackBar()
132+
..showSnackBar(const SnackBar(
133+
content:
134+
Text('Tapped on "stand up for the stupid and crazy"')));
131135
},
132136
),
133137
const TextSpan(
@@ -189,8 +193,10 @@ TextSpan _text(BuildContext context, double textScaleFactor) => TextSpan(
189193
),
190194
recognizer: TapGestureRecognizer()
191195
..onTap = () {
192-
ScaffoldMessenger.of(context).showSnackBar(
193-
const SnackBar(content: Text('Tapped on "Song of Myself"')));
196+
ScaffoldMessenger.of(context)
197+
..removeCurrentSnackBar()
198+
..showSnackBar(const SnackBar(
199+
content: Text('Tapped on "Song of Myself"')));
194200
},
195201
),
196202
],

example/lib/pages/basic_rtl.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class BasicRtl extends StatelessWidget {
1313
// const crossAxisAlignment = CrossAxisAlignment.stretch;
1414

1515
const boxHeight = 40.0;
16-
final scale =
17-
(((MediaQuery.of(context).size.width / 600.0) - 1.0) * 0.6) + 1.0;
1816

1917
return DefaultTextStyle(
2018
style: const TextStyle(fontSize: 18, color: Colors.black, height: 1.5),
@@ -50,8 +48,7 @@ class BasicRtl extends StatelessWidget {
5048
clearMinSpacing: 100,
5149
maxWidthPercentage: 0.333,
5250
child: Container(height: boxHeight, color: Colors.green)),
53-
WrappableText(
54-
text: _text, textScaler: TextScaler.linear(scale)),
51+
WrappableText(text: _text),
5552
],
5653
),
5754
),

example/lib/shared/drop_cap.dart

Lines changed: 18 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import 'package:flutter/material.dart';
2+
import 'package:intrinsic_size_overflow_box/intrinsic_size_overflow_box.dart';
23

34
class DropCap extends StatelessWidget {
45
const DropCap(this.text, {super.key, this.size = 2.0, this.textScaleFactor});
@@ -10,62 +11,27 @@ class DropCap extends StatelessWidget {
1011
@override
1112
Widget build(BuildContext context) {
1213
final style = DefaultTextStyle.of(context).style;
14+
final scaler = textScaleFactor == null
15+
? MediaQuery.textScalerOf(context)
16+
: TextScaler.linear(textScaleFactor!);
17+
final fontSize =
18+
(style.fontSize ?? 16.0) * (style.height ?? 1.0) * size * 1.1;
19+
final scaledSize = scaler.scale(fontSize);
1320

1421
return Padding(
15-
padding: Directionality.of(context) == TextDirection.ltr
16-
? const EdgeInsets.only(right: 10)
17-
: const EdgeInsets.only(left: 10),
18-
// ignore: avoid_unnecessary_containers
19-
child: Container(
20-
// color: Colors.yellow,
21-
child: Text(
22-
text,
23-
textScaler: textScaleFactor == null
24-
? MediaQuery.textScalerOf(context)
25-
: TextScaler.linear(textScaleFactor!),
26-
style: style.copyWith(
27-
fontSize: (style.fontSize ?? 16.0) *
28-
(style.height ?? 1.0) *
29-
size *
30-
0.99,
31-
height: 1),
22+
padding: const EdgeInsetsDirectional.only(end: 10),
23+
child: SizedBox(
24+
// color: Colors.orange,
25+
height: scaledSize * 0.75,
26+
child: IntrinsicSizeOverflowBox(
27+
maxHeight: scaledSize * 1.5,
28+
child: Text(
29+
text,
30+
textScaler: scaler,
31+
style: style.copyWith(fontSize: fontSize, height: 1),
32+
),
3233
),
3334
),
3435
);
3536
}
3637
}
37-
38-
/*
39-
TextStyle textStyleWithGoogleFont([String? fontFamily]) {
40-
try {
41-
return GoogleFonts.getFont(fontFamily ?? _fonts[1]);
42-
} catch (_) {
43-
return const TextStyle();
44-
}
45-
}
46-
47-
// cspell: disable
48-
const _fonts = [
49-
'Great Vibes',
50-
'Sevillana',
51-
'Oleo Script',
52-
'Oleo Script Swash Caps',
53-
'Seaweed Script',
54-
'Lobster',
55-
'Alfa Slab One',
56-
'Playball',
57-
'Monoton',
58-
'Londrina Shadow',
59-
'Rye',
60-
'UnifrakturMaguntia',
61-
'Frijole',
62-
'Creepster',
63-
'Sail',
64-
'Faster One',
65-
'Shojumaru',
66-
'UnifrakturCook',
67-
'Nosifer',
68-
'Akronim',
69-
'Ewert',
70-
];
71-
*/

example/pubspec.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ dependencies:
1212
path: ../
1313
flutter:
1414
sdk: flutter
15-
flutter_animate: ^4.5.2
16-
google_fonts: ^6.2.1
15+
intrinsic_size_overflow_box: ^0.1.1
1716

1817
dev_dependencies:
1918
flutter_lints_plus: ^3.2.0

0 commit comments

Comments
 (0)