gpt4 book ai didi

flutter - 如何绘制文字的形状?

转载 作者:行者123 更新时间:2023-12-03 03:10:08 26 4
gpt4 key购买 nike

我正在尝试为抖动的标题文本制作动画前景,或者更准确地说,我希望用类似这样的 GIF 来显示文本 enter image description here我什至不知道该怎么做,但我想如果我设法使堆栈充满 GIF,然后将最后一层设为 CustomClipper<Path>填充整个空间但文本形状然后它看起来像它,问题是我不知道如何制作文本形状!另外我不知道如何制作一条路径来填充整个尺寸除了我将提供的文字形状,请提供任何帮助,或者如果您有任何想法可以做到这一点,但我也有兴趣以不同的方式提前致谢。

最佳答案

啊,我来晚了..好吧,顺其自然

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(title: const Text('Title')),
body: Stack(
children: [
FakeAnimatedBackground(),
ShaderMask(
blendMode: BlendMode.srcOut,
shaderCallback: (bounds) => LinearGradient(colors: [Colors.black], stops: [0.0]).createShader(bounds),
child: SizedBox.expand(
child: Container(
color: Colors.transparent,
alignment: Alignment.center,
child: const Text('SOME TEXT', style: TextStyle(fontSize: 60, fontWeight: FontWeight.bold)),
),
),
),
],
),
),
);
}
}

class FakeAnimatedBackground extends StatefulWidget {
@override
_FakeAnimatedBackgroundState createState() => _FakeAnimatedBackgroundState();
}

class _FakeAnimatedBackgroundState extends State<FakeAnimatedBackground> with TickerProviderStateMixin {
AnimationController _controller;

@override
void initState() {
super.initState();
_controller = AnimationController(duration: const Duration(milliseconds: 5000), vsync: this)..repeat();
}

@override
Widget build(BuildContext context) {
return RotationTransition(
alignment: Alignment.center,
turns: Tween(begin: 0.0, end: 1.0).animate(_controller),
child: Container(
decoration: BoxDecoration(
gradient: SweepGradient(colors: [Colors.red, Colors.green, Colors.blue, Colors.red]),
),
),
);
}
}

FakeAnimationBackground类无所谓,只是模拟背景移动

enter image description here

关于flutter - 如何绘制文字的形状?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58237174/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com