Last active
July 7, 2017 21:12
-
-
Save collinjackson/ec8ad3708bcfafd1ab12c2e2760ec023 to your computer and use it in GitHub Desktop.
Marquee example - simplified test case for Pixel text rendering issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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