Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 3.3.2
- Remove usages of deprecated methods in `package:vector_math`

## 3.3.1
- Update `package:archive` to `>=4.0.0` constraint

Expand Down
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ class MyApp extends StatelessWidget {

// Load a Lottie file from a remote url
Lottie.network(
'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json'),
'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/example/assets/Mobilo/A.json',
),

// Load an animation and its images from a zip file
Lottie.asset('assets/lottiefiles/angel.zip'),
Expand Down Expand Up @@ -193,7 +194,7 @@ class _Painter extends CustomPainter {
final LottieDrawable drawable;

_Painter(LottieComposition composition)
: drawable = LottieDrawable(composition);
: drawable = LottieDrawable(composition);

@override
void paint(Canvas canvas, Size size) {
Expand Down Expand Up @@ -228,18 +229,20 @@ class _Animation extends StatelessWidget {
delegates: LottieDelegates(
text: (initialText) => '**$initialText**',
values: [
ValueDelegate.color(
const ['Shape Layer 1', 'Rectangle', 'Fill 1'],
value: Colors.red,
),
ValueDelegate.color(const [
'Shape Layer 1',
'Rectangle',
'Fill 1',
], value: Colors.red),
ValueDelegate.opacity(
const ['Shape Layer 1', 'Rectangle'],
callback: (frameInfo) => (frameInfo.overallProgress * 100).round(),
),
ValueDelegate.position(
const ['Shape Layer 1', 'Rectangle', '**'],
relative: const Offset(100, 200),
),
ValueDelegate.position(const [
'Shape Layer 1',
'Rectangle',
'**',
], relative: const Offset(100, 200)),
],
),
);
Expand Down Expand Up @@ -291,18 +294,19 @@ class Example extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Lottie.asset(
'assets/cat.lottie',
decoder: customDecoder,
);
return Lottie.asset('assets/cat.lottie', decoder: customDecoder);
}
}

Future<LottieComposition?> customDecoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, filePicker: (files) {
return files.firstWhereOrNull(
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'));
});
return LottieComposition.decodeZip(
bytes,
filePicker: (files) {
return files.firstWhereOrNull(
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'),
);
},
);
}
````

Expand Down
1 change: 0 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ linter:
unnecessary_parenthesis: true
unnecessary_statements: true
unnecessary_to_list_in_spreads: true
unsafe_html: true
use_enums: true
use_if_null_to_convert_nulls_to_bools: true
use_named_constants: true
Expand Down
3 changes: 2 additions & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class MyApp extends StatelessWidget {

// Load a Lottie file from a remote url
Lottie.network(
'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/sample_app/assets/Mobilo/A.json'),
'https://raw.githubusercontent.com/xvrh/lottie-flutter/master/sample_app/assets/Mobilo/A.json',
),
],
),
),
Expand Down
32 changes: 32 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldb_helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Generated file, do not edit.
#

import lldb

def handle_new_rx_page(frame: lldb.SBFrame, bp_loc, extra_args, intern_dict):
"""Intercept NOTIFY_DEBUGGER_ABOUT_RX_PAGES and touch the pages."""
base = frame.register["x0"].GetValueAsAddress()
page_len = frame.register["x1"].GetValueAsUnsigned()

# Note: NOTIFY_DEBUGGER_ABOUT_RX_PAGES will check contents of the
# first page to see if handled it correctly. This makes diagnosing
# misconfiguration (e.g. missing breakpoint) easier.
data = bytearray(page_len)
data[0:8] = b'IHELPED!'

error = lldb.SBError()
frame.GetThread().GetProcess().WriteMemory(base, data, error)
if not error.Success():
print(f'Failed to write into {base}[+{page_len}]', error)
return

def __lldb_init_module(debugger: lldb.SBDebugger, _):
target = debugger.GetDummyTarget()
# Caveat: must use BreakpointCreateByRegEx here and not
# BreakpointCreateByName. For some reasons callback function does not
# get carried over from dummy target for the later.
bp = target.BreakpointCreateByRegex("^NOTIFY_DEBUGGER_ABOUT_RX_PAGES$")
bp.SetScriptCallbackFunction('{}.handle_new_rx_page'.format(__name__))
bp.SetAutoContinue(True)
print("-- LLDB integration loaded --")
5 changes: 5 additions & 0 deletions example/ios/Flutter/ephemeral/flutter_lldbinit
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#
# Generated file, do not edit.
#

command script import --relative-to-command-file flutter_lldb_helper.py
4 changes: 1 addition & 3 deletions example/lib/examples/alert_dialog.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(body: _Page()),
);
return MaterialApp(home: Scaffold(body: _Page()));
}
}

Expand Down
4 changes: 1 addition & 3 deletions example/lib/examples/animation_full_control.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Animation control'),
),
appBar: AppBar(title: const Text('Animation control')),
body: Column(
children: <Widget>[
const SizedBox(height: 20),
Expand Down
11 changes: 5 additions & 6 deletions example/lib/examples/blur.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ class MyApp extends StatelessWidget {
Lottie.asset(
'assets/AndroidWave.json',
height: 300,
delegates: LottieDelegates(values: [
ValueDelegate.blurRadius(
['**'],
value: 20,
),
]),
delegates: LottieDelegates(
values: [
ValueDelegate.blurRadius(['**'], value: 20),
],
),
),
],
),
Expand Down
4 changes: 1 addition & 3 deletions example/lib/examples/cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(body: _Page()),
);
return MaterialApp(home: Scaffold(body: _Page()));
}
}

Expand Down
14 changes: 6 additions & 8 deletions example/lib/examples/custom_draw.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: MyWidget(),
),
);
return const MaterialApp(home: Scaffold(body: MyWidget()));
}
}

Expand All @@ -35,8 +31,9 @@ class _MyWidgetState extends State<MyWidget> {
}

Future<LottieComposition> _loadComposition() async {
var assetData = await rootBundle
.load('assets/lottiefiles/little_girl_jumping_-_loader.json');
var assetData = await rootBundle.load(
'assets/lottiefiles/little_girl_jumping_-_loader.json',
);
return LottieComposition.fromByteData(assetData);
}

Expand Down Expand Up @@ -75,7 +72,7 @@ class _Painter extends CustomPainter {
final LottieDrawable drawable;

_Painter(LottieComposition composition)
: drawable = LottieDrawable(composition);
: drawable = LottieDrawable(composition);

@override
void paint(Canvas canvas, Size size) {
Expand All @@ -94,4 +91,5 @@ class _Painter extends CustomPainter {
return true;
}
}

//---
7 changes: 2 additions & 5 deletions example/lib/examples/custom_load.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ class MyApp extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: MyWidget(),
),
);
return const MaterialApp(home: Scaffold(body: MyWidget()));
}
}

Expand Down Expand Up @@ -49,4 +45,5 @@ class _MyWidgetState extends State<MyWidget> {
);
}
}

//---
24 changes: 11 additions & 13 deletions example/lib/examples/dotlottie.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@ class App extends StatelessWidget {

@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: Example(),
),
);
return const MaterialApp(home: Scaffold(body: Example()));
}
}

Expand All @@ -23,17 +19,19 @@ class Example extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Lottie.asset(
'assets/cat.lottie',
decoder: customDecoder,
);
return Lottie.asset('assets/cat.lottie', decoder: customDecoder);
}
}

Future<LottieComposition?> customDecoder(List<int> bytes) {
return LottieComposition.decodeZip(bytes, filePicker: (files) {
return files.firstWhereOrNull(
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'));
});
return LottieComposition.decodeZip(
bytes,
filePicker: (files) {
return files.firstWhereOrNull(
(f) => f.name.startsWith('animations/') && f.name.endsWith('.json'),
);
},
);
}

//----
35 changes: 14 additions & 21 deletions example/lib/examples/draw_cache.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ void main() async {
// In a real app, we may want to defer choosing the size after an initial
// Layout (ie. using LayoutBuilder)
var cachedAnimation = CachedLottie(const Size(150, 200), animation);
runApp(_Example(
lottie: cachedAnimation,
));
runApp(_Example(lottie: cachedAnimation));
}

class _Example extends StatelessWidget {
Expand All @@ -31,9 +29,7 @@ class _Example extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Cache'),
),
appBar: AppBar(title: const Text('Cache')),
body: ListView(
children: [
for (var i = 0; i < 20; i++)
Expand All @@ -42,10 +38,8 @@ class _Example extends StatelessWidget {
for (var j = 0; j < 50; j++)
Transform.translate(
offset: Offset(j.toDouble() * 20, 0),
child: CachedLottiePlayer(
lottie: lottie,
),
)
child: CachedLottiePlayer(lottie: lottie),
),
],
),
],
Expand All @@ -62,7 +56,7 @@ class CachedLottie {
late final _drawable = LottieDrawable(composition);

CachedLottie(this.size, this.composition)
: images = List.filled(composition.durationFrames.ceil(), null);
: images = List.filled(composition.durationFrames.ceil(), null);

Duration get duration => composition.duration;

Expand All @@ -81,30 +75,29 @@ class CachedLottie {
..setProgress(progress)
..draw(canvas, Offset.zero & (size * devicePixelRatio));
var picture = recorder.endRecording();
return picture.toImageSync((size.width * devicePixelRatio).round(),
(size.height * devicePixelRatio).round());
return picture.toImageSync(
(size.width * devicePixelRatio).round(),
(size.height * devicePixelRatio).round(),
);
}
}

class CachedLottiePlayer extends StatefulWidget {
final CachedLottie lottie;
final AnimationController? controller;

const CachedLottiePlayer({
super.key,
required this.lottie,
this.controller,
});
const CachedLottiePlayer({super.key, required this.lottie, this.controller});

@override
State<CachedLottiePlayer> createState() => _CachedLottiePlayerState();
}

class _CachedLottiePlayerState extends State<CachedLottiePlayer>
with TickerProviderStateMixin {
late final AnimationController _autoController =
AnimationController(vsync: this, duration: widget.lottie.duration)
..repeat();
late final AnimationController _autoController = AnimationController(
vsync: this,
duration: widget.lottie.duration,
)..repeat();

@override
Widget build(BuildContext context) {
Expand Down
Loading