Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
πŸ§‘β€πŸ’» Change the types of width, height to double
Browse files Browse the repository at this point in the history
The parameter for size is properly of type double
  • Loading branch information
tinyjin committed Mar 17, 2024
1 parent 965c6d3 commit a6959d3
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions lib/lottie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import 'package:lottie_thorvg/src/utils.dart';

class Lottie extends StatefulWidget {
final Future<String> data;
final int width;
final int height;
final double width;
final double height;

final bool animate;
final bool repeat;
Expand All @@ -32,8 +32,8 @@ class Lottie extends StatefulWidget {
static Lottie asset(
String name, {
Key? key,
int? width,
int? height,
double? width,
double? height,
bool? animate,
bool? repeat,
bool? reverse,
Expand All @@ -54,8 +54,8 @@ class Lottie extends StatefulWidget {
static Lottie file(
Object /*io.File|html.File*/ file, {
Key? key,
int? width,
int? height,
double? width,
double? height,
bool? animate,
bool? repeat,
bool? reverse,
Expand All @@ -77,8 +77,8 @@ class Lottie extends StatefulWidget {
static Lottie memory(
Uint8List bytes, {
Key? key,
int? width,
int? height,
double? width,
double? height,
bool? animate,
bool? repeat,
bool? reverse,
Expand All @@ -100,8 +100,8 @@ class Lottie extends StatefulWidget {
static Lottie network(
String src, {
Key? key,
int? width,
int? height,
double? width,
double? height,
bool? animate,
bool? repeat,
bool? reverse,
Expand Down Expand Up @@ -132,16 +132,16 @@ class _State extends State<Lottie> {
String errorMsg = "";

// Canvas size
int width = 0;
int height = 0;
double width = 0;
double height = 0;

// Original size (lottie)
int lottieWidth = 0;
int lottieHeight = 0;

// Render size (calculated)
int get renderWidth => lottieWidth > width ? width : lottieWidth;
int get renderHeight => lottieHeight > height ? height : lottieHeight;
double get renderWidth => (lottieWidth > width ? width : lottieWidth).toDouble();
double get renderHeight => (lottieHeight > height ? height : lottieHeight).toDouble();

@override
void initState() {
Expand Down Expand Up @@ -196,8 +196,8 @@ class _State extends State<Lottie> {
void _updateCanvasSize() {
if (widget.width == 0 || widget.height == 0) {
setState(() {
width = lottieWidth;
height = lottieHeight;
width = lottieWidth.toDouble();
height = lottieHeight.toDouble();
});
return;
}
Expand All @@ -214,7 +214,7 @@ class _State extends State<Lottie> {
*/
void _tvgLoad() {
try {
tvg!.load(data, renderWidth, renderHeight, widget.animate, widget.repeat,
tvg!.load(data, renderWidth.toInt(), renderHeight.toInt(), widget.animate, widget.repeat,
widget.reverse);
} catch (err) {
setState(() {
Expand Down Expand Up @@ -265,7 +265,7 @@ class _State extends State<Lottie> {
return;
}

final image = await decodeImage(buffer, renderWidth, renderHeight);
final image = await decodeImage(buffer, renderWidth.toInt(), renderHeight.toInt());
setState(() {
img = image;
});
Expand Down

0 comments on commit a6959d3

Please sign in to comment.