1+ import 'dart:async' ;
2+ import 'package:mark922_flutter_lottie/mark922_flutter_lottie.dart' ;
13import 'package:flutter/material.dart' ;
24import 'package:share/share.dart' ;
35import 'dart:math' ;
4- // import 'package:fluttie/fluttie.dart';
56import 'package:toughest/textStyle.dart' ;
67
78class ShowDetail extends StatefulWidget {
@@ -31,45 +32,21 @@ class ShowDetail extends StatefulWidget {
3132}
3233
3334class ShowDetailState extends State <ShowDetail > {
34- // FluttieAnimationController controller ;
35- // bool ready = false ;
35+ LottieController controller2 ;
36+ StreamController < double > newProgressStream ;
3637
37- // @override
38- // void initState() {
39- // super.initState();
40- // prepareAnimation();
41- // }
42-
43- // @override
44- // void dispose() {
45- // controller.dispose();
46- // super.dispose();
47- // }
38+ @override
39+ void initState () {
40+ super .initState ();
41+ newProgressStream= StreamController <double >();
42+ }
4843
49- // ///prepare for lottie animation.
50- // prepareAnimation() async {
51- // // Checks if the platform we're running on is supported by the animation plugin
52- // bool canBeUsed = await Fluttie.isAvailable();
53- // if (!canBeUsed) {
54- // print("Animations are not supported on this platform");
55- // return;
56- // }
44+ @override
45+ void dispose () {
46+ newProgressStream.close ();
47+ super .dispose ();
48+ }
5749
58- // var instance = new Fluttie();
59- // var emojiComposition = await instance.loadAnimationFromAsset(
60- // "assets/confetti.json", //Replace this string with your actual file
61- // );
62- // controller = await instance.prepareAnimation(emojiComposition,
63- // duration: const Duration(seconds: 2),
64- // repeatCount: const RepeatCount.nTimes(1),
65- // repeatMode: RepeatMode.START_OVER);
66- // if (mounted) {
67- // setState(() {
68- // ready = true; // The animations have been loaded, we're ready
69- // controller.start(); //start our looped emoji animation
70- // });
71- // }
72- // }
7350
7451 share (String question, String answer) {
7552 Share .share ("Q:" +
@@ -82,7 +59,6 @@ class ShowDetailState extends State<ShowDetail> {
8259 }
8360
8461 Widget _card = new Container (
85- // child: Text(text, style: TextStyle(fontSize: 15.0)),
8662 height: 170.0 ,
8763 margin: new EdgeInsets .all (8.0 ),
8864 decoration: new BoxDecoration (
@@ -124,6 +100,7 @@ class ShowDetailState extends State<ShowDetail> {
124100 title: Text ('Answer' ),
125101 ),
126102 body: ListView (
103+ padding: EdgeInsets .all (8 ),
127104 children: < Widget > [
128105 Container (
129106 margin: EdgeInsets .all (8.0 ),
@@ -151,21 +128,28 @@ class ShowDetailState extends State<ShowDetail> {
151128 style: Style .regularTextStyle,
152129 ),
153130 ),
154- // ready
155- // ? Center(
156- // child: FluttieAnimation(controller,
157- // size: Fluttie.kDefaultSize))
158- // : Container(
159- // height: 1.0,
160- // ),
131+ Center (
132+ child: Container (
133+ height: 300 ,
134+ width: 300 ,
135+ child: LottieView .fromFile (
136+ filePath: 'assets/confetti.json' ,
137+ autoPlay: true ,
138+ loop: false ,
139+ reverse: false ,
140+ onViewCreated: onViewCreatedFile,
141+ ),
142+
143+ ),
144+ )
161145 ]),
162146 SizedBox (
163147 height: 20.0 ,
164148 ),
165149 RaisedButton (
166- shape: BeveledRectangleBorder (borderRadius: new BorderRadius .circular (5.0 )),
150+ shape: OutlineInputBorder (borderRadius: new BorderRadius .circular (5.0 ),borderSide : BorderSide .none ),
167151 splashColor: const Color (0xff382151 ),
168- elevation: 20 .0 ,
152+ elevation: 10 .0 ,
169153 child: Text ("Share answer with your friends" ,style: Style .regularTextStyle,),
170154 color: Color (0xFF56cfdf ),
171155 onPressed: () => share (widget.quest, widget.ans),
@@ -175,4 +159,12 @@ class ShowDetailState extends State<ShowDetail> {
175159 ),
176160 );
177161 }
162+
163+ void onViewCreatedFile (LottieController controller) {
164+ this .controller2 = controller;
165+ newProgressStream.stream.listen ((double progress) {
166+ this .controller2.setAnimationProgress (progress);
167+ });
168+ }
169+
178170}
0 commit comments