Skip to content

Commit

Permalink
update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Mar 4, 2024
1 parent ee6348e commit 025d8e0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions lib/widget/anim_bubble_gum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class AnimBubbleGumDemoPage extends StatelessWidget {
}
}

final size = ui.window.physicalSize / ui.window.devicePixelRatio;

const frequency = Duration(milliseconds: 50);

const numCircles = 299;
Expand Down Expand Up @@ -51,6 +49,8 @@ class _AnimBubbleGumState extends State<AnimBubbleGum> {

final circles = <Circle>[];

late Size size;

Offset force = Offset(1, 1);

HSLColor hslColor = HSLColor.fromColor(Colors.pink[100]!);
Expand All @@ -66,6 +66,7 @@ class _AnimBubbleGumState extends State<AnimBubbleGum> {

@override
void initState() {
size = View.of(context).physicalSize / View.of(context).devicePixelRatio;
timer = Timer.periodic(
frequency,
(t) {
Expand Down Expand Up @@ -156,7 +157,7 @@ class Painter extends CustomPainter {
);
var light = Paint();
try {
if (Platform.isAndroid == true|| Platform.isIOS == true) {
if (Platform.isAndroid == true || Platform.isIOS == true) {
light = Paint()
..color = c.color
..shader = ui.Gradient.radial(
Expand Down
2 changes: 0 additions & 2 deletions lib/widget/gradient_text_demo_page.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:ui';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Expand Down
3 changes: 1 addition & 2 deletions lib/widget/matrix_custom_painter_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class TestCustomPainter extends CustomPainter {
shapesPaint.style = PaintingStyle.stroke;
ui.ParagraphBuilder builder = ui.ParagraphBuilder(ui.ParagraphStyle(
textAlign: TextAlign.center,
fontSize: Theme.of(context).textTheme.displaySmall!.fontSize! *
MediaQuery.textScalerOf(context).textScaleFactor,
fontSize: Theme.of(context).textTheme.displaySmall!.fontSize!,
))
..pushStyle(ui.TextStyle(
color: Colors.white,
Expand Down
9 changes: 6 additions & 3 deletions lib/widget/text_size_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class TextSizeDemoPage extends StatefulWidget {

class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
TextScaler textScaler = TextScaler.noScaling;
int scale = 1;

@override
void initState() {
Expand Down Expand Up @@ -44,9 +45,10 @@ class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
children: <Widget>[
new TextButton(
onPressed: () {
if (textScaler.textScaleFactor > 1) {
if (scale > 1) {
setState(() {
textScaler.scale(textScaler.textScaleFactor - 1);
textScaler.scale(scale - 1);
scale--;
});
}
},
Expand All @@ -60,7 +62,8 @@ class _TextSizeDemoPageState extends State<TextSizeDemoPage> {
new TextButton(
onPressed: () {
setState(() {
textScaler.scale(textScaler.textScaleFactor + 1);
textScaler.scale(scale + 1);
scale++;
});
},
style: TextButton.styleFrom(
Expand Down

0 comments on commit 025d8e0

Please sign in to comment.