Skip to content

Instantly share code, notes, and snippets.

@collinjackson
Last active July 7, 2017 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save collinjackson/ec8ad3708bcfafd1ab12c2e2760ec023 to your computer and use it in GitHub Desktop.
Save collinjackson/ec8ad3708bcfafd1ab12c2e2760ec023 to your computer and use it in GitHub Desktop.
Marquee example - simplified test case for Pixel text rendering issue
import 'package:flutter/material.dart';
class MyHomePage extends StatefulWidget {
MyHomePageState createState() => new MyHomePageState();
}
class MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
AnimationController _controller;
Animation<FractionalOffset> _animation;
@override
void initState() {
_controller = new AnimationController(
vsync: this,
duration: const Duration(seconds: 2),
);
_animation = new FractionalOffsetTween(
begin: FractionalOffset.centerLeft,
end: FractionalOffset.centerRight,
).animate(_controller);
_animate();
}
void _animate() async {
await _controller.forward();
await _controller.reverse();
_animate();
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new AnimatedBuilder(
child: new Text(
'<marquee>Hello Pixel</marquee>',
style: Theme.of(context).textTheme.title,
),
animation: _animation,
builder: (BuildContext context, Widget child) {
return new Align(
alignment: _animation.value,
child: child,
);
},
),
);
}
}
void main() {
runApp(new MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.deepPurple,
),
home: new MyHomePage(),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment