Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
9584834956 | |||
d0edd1b3ee | |||
6831f475d4 | |||
bbfe04f00d | |||
5b7fde198a | |||
fe8847a5ba | |||
2360f643b7 | |||
1146e1f01d | |||
ba0bfcd126 | |||
cb8006d362 | |||
bf7d0ebf05 | |||
57faea6f5e | |||
548c77dc45 |
18
.github/workflows/analyze-and-test.yaml
vendored
@ -10,7 +10,7 @@ jobs:
|
||||
name: Flutter analyze
|
||||
strategy:
|
||||
matrix:
|
||||
flutter: ['stable', 'dev']
|
||||
flutter: ['beta']
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -32,4 +32,18 @@ jobs:
|
||||
|| (echo "##[error] found changed files after build. please run 'dart tool/prepare_submit.dart'" \
|
||||
"and check in all changes" \
|
||||
&& exit 1)
|
||||
shell: bash
|
||||
shell: bash
|
||||
build_web_version:
|
||||
name: Check that the web version compile
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: 'beta'
|
||||
- run: flutter config --enable-web
|
||||
- run: flutter precache web
|
||||
- run: flutter pub get
|
||||
working-directory: example
|
||||
- run: flutter build web
|
||||
working-directory: example
|
||||
|
5
.github/workflows/publish-on-pub.yaml
vendored
@ -10,12 +10,11 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: subosito/flutter-action@v1
|
||||
with:
|
||||
channel: 'stable'
|
||||
channel: 'beta'
|
||||
- run: flutter pub get
|
||||
- run: flutter pub run tool/publish/comment_dependency_overrides.dart
|
||||
- run: flutter pub get
|
||||
- run: echo ::set-env name=RELEASE_VERSION::${GITHUB_REF}
|
||||
- run: flutter pub run tool/publish/check_version.dart ${{ env.RELEASE_VERSION }}
|
||||
- run: flutter pub run tool/publish/check_version.dart ${GITHUB_REF}
|
||||
- name: Setup credentials
|
||||
run: |
|
||||
mkdir -p $FLUTTER_HOME/.pub-cache
|
||||
|
26
CHANGELOG.md
@ -1,3 +1,29 @@
|
||||
## [1.0.0]
|
||||
- Migrate to null safety
|
||||
- Fix some rendering bugs
|
||||
- Add an image delegate to dynamically change images
|
||||
- Allow to use an imageProviderFactory with a zip file
|
||||
|
||||
## [0.7.1]
|
||||
- Fix a crash for some lottie file with empty paths.
|
||||
|
||||
## [0.7.0+1]
|
||||
- Fix Flutter Web compilation error
|
||||
|
||||
## [0.7.0]
|
||||
- Performance improvement for complex animations.
|
||||
|
||||
## [0.6.0]
|
||||
- Runs the animation at the frame rate specified in the json file (ie. An animation encoded with a 20 FPS will only
|
||||
be paint 20 times per seconds even though the AnimationController will invalidate the widget 60 times per seconds).
|
||||
A new property `frameRate` allows to opt-out this behavior and have the widget to repaint at the device frame rate
|
||||
(`FrameRate.max`).
|
||||
- Automatically add a `RepaintBoundary` around the widget. Since `Lottie` animations are generally complex to paint, a
|
||||
`RepaintBoundary` will separate the animation with the rest of the app and improve performance. A new property `addRepaintBoundary`
|
||||
allows to opt-out this behavior.
|
||||
- Fix a bug where we would call `markNeedPaint` when the animation was not changing. This removes unnecessary paints in
|
||||
animations with static periods.
|
||||
|
||||
## [0.5.1]
|
||||
- Remove direct dependencies on dart:io to support Flutter Web
|
||||
|
||||
|
@ -8,7 +8,7 @@ animations exported as json with [Bodymovin](https://github.com/airbnb/lottie-we
|
||||
|
||||
This repository is a unofficial conversion of the [Lottie-android](https://github.com/airbnb/lottie-android) library in pure Dart.
|
||||
|
||||
It works on Android, iOS and macOS and web.
|
||||
It works on Android, iOS, macOS, linux, windows and web.
|
||||
|
||||
## Usage
|
||||
|
||||
@ -64,7 +64,7 @@ class MyApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -137,7 +137,7 @@ class MyWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyWidgetState extends State<MyWidget> {
|
||||
Future<LottieComposition> _composition;
|
||||
late final Future<LottieComposition> _composition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -176,7 +176,7 @@ a specific position and size.
|
||||
class CustomDrawer extends StatelessWidget {
|
||||
final LottieComposition composition;
|
||||
|
||||
const CustomDrawer(this.composition, {Key key}) : super(key: key);
|
||||
const CustomDrawer(this.composition, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -8,7 +8,7 @@ animations exported as json with [Bodymovin](https://github.com/airbnb/lottie-we
|
||||
|
||||
This repository is a unofficial conversion of the [Lottie-android](https://github.com/airbnb/lottie-android) library in pure Dart.
|
||||
|
||||
It works on Android, iOS and macOS and web.
|
||||
It works on Android, iOS, macOS, linux, windows and web.
|
||||
|
||||
## Usage
|
||||
|
||||
@ -17,7 +17,7 @@ This example shows how to display a Lottie animation in the simplest way.
|
||||
The `Lottie` widget will load the json file and run the animation indefinitely.
|
||||
|
||||
```dart
|
||||
import 'example/lib/examples/main.dart';
|
||||
import 'example/lib/main.dart';
|
||||
```
|
||||
|
||||
### Specify a custom `AnimationController`
|
||||
|
1
example/assets/battery_optimizations.json
Normal file
1
example/assets/camera_change.json
Normal file
7280
example/assets/envelope.json
Normal file
1
example/assets/lottiefiles/28861-connection-style-2.json
Normal file
BIN
example/assets/spinning_carrousel.zip
Normal file
@ -1,2 +1,3 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
@ -1,2 +1,3 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Generated.xcconfig"
|
||||
|
@ -23,7 +23,7 @@ class __PageState extends State<_Page> {
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) => _showLoader());
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) => _showLoader());
|
||||
}
|
||||
|
||||
void _showLoader() {
|
||||
|
@ -6,7 +6,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -9,7 +9,7 @@ class MyApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -17,7 +17,7 @@ class MyApp extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -86,7 +86,7 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 30),
|
||||
RaisedButton(
|
||||
ElevatedButton(
|
||||
child: Text('Loop between frames'),
|
||||
onPressed: () {
|
||||
// Loop between 2 specifics frames
|
||||
@ -97,7 +97,7 @@ class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
min: start,
|
||||
max: stop,
|
||||
reverse: true,
|
||||
period: _controller.duration * (stop - start),
|
||||
period: _controller.duration! * (stop - start),
|
||||
);
|
||||
},
|
||||
),
|
||||
|
@ -22,7 +22,7 @@ class MyWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyWidgetState extends State<MyWidget> {
|
||||
Future<LottieComposition> _composition;
|
||||
late final Future<LottieComposition> _composition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -57,7 +57,7 @@ class _MyWidgetState extends State<MyWidget> {
|
||||
class CustomDrawer extends StatelessWidget {
|
||||
final LottieComposition composition;
|
||||
|
||||
const CustomDrawer(this.composition, {Key key}) : super(key: key);
|
||||
const CustomDrawer(this.composition, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -23,7 +23,7 @@ class MyWidget extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _MyWidgetState extends State<MyWidget> {
|
||||
Future<LottieComposition> _composition;
|
||||
late final Future<LottieComposition> _composition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -8,7 +8,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppState createState() => _AppState();
|
||||
@ -50,7 +50,7 @@ class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
value: _useDelegates,
|
||||
onChanged: (newValue) {
|
||||
setState(() {
|
||||
_useDelegates = newValue;
|
||||
_useDelegates = newValue!;
|
||||
});
|
||||
},
|
||||
),
|
||||
|
@ -7,14 +7,14 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppState createState() => _AppState();
|
||||
}
|
||||
|
||||
class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
TextEditingController _textController;
|
||||
late final TextEditingController _textController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -6,14 +6,14 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppState createState() => _AppState();
|
||||
}
|
||||
|
||||
class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
AnimationController _animationController;
|
||||
late final AnimationController _animationController;
|
||||
bool _showAnimation = true;
|
||||
|
||||
@override
|
||||
|
@ -1,27 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ListView(
|
||||
children: [
|
||||
// Load a Lottie file from your assets
|
||||
Lottie.asset('assets/LottieLogo1.json'),
|
||||
|
||||
// Load a Lottie file from a remote url
|
||||
Lottie.network(
|
||||
'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'),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -9,14 +9,14 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppState createState() => _AppState();
|
||||
}
|
||||
|
||||
class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
Future<LottieComposition> _composition;
|
||||
late final Future<LottieComposition> _composition;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -35,9 +35,9 @@ class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
body: FutureBuilder<LottieComposition>(
|
||||
future: _composition,
|
||||
builder: (context, snapshot) {
|
||||
if (snapshot.hasError) return ErrorWidget(snapshot.error);
|
||||
if (snapshot.hasError) return ErrorWidget(snapshot.error!);
|
||||
if (!snapshot.hasData) return CircularProgressIndicator();
|
||||
return _LottieDetails(snapshot.data);
|
||||
return _LottieDetails(snapshot.data!);
|
||||
},
|
||||
),
|
||||
),
|
||||
@ -48,7 +48,7 @@ class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
class _LottieDetails extends StatefulWidget {
|
||||
final LottieComposition composition;
|
||||
|
||||
const _LottieDetails(this.composition, {Key key}) : super(key: key);
|
||||
const _LottieDetails(this.composition, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_LottieDetailsState createState() => _LottieDetailsState();
|
||||
@ -56,7 +56,7 @@ class _LottieDetails extends StatefulWidget {
|
||||
|
||||
class _LottieDetailsState extends State<_LottieDetails>
|
||||
with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late final AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@ -87,15 +87,15 @@ class _LottieDetailsState extends State<_LottieDetails>
|
||||
title: Text('Composition duration'),
|
||||
trailing: Text(widget.composition.durationFrames.toStringAsFixed(1)),
|
||||
),
|
||||
RaisedButton(
|
||||
ElevatedButton(
|
||||
child: Text('touchDownEnd - touchUpCancel'),
|
||||
onPressed: () => _playBetween('touchDownEnd', 'touchUpCancel'),
|
||||
),
|
||||
RaisedButton(
|
||||
ElevatedButton(
|
||||
child: Text('touchDownStart - touchDownEnd'),
|
||||
onPressed: () => _playBetween('touchDownStart', 'touchDownEnd'),
|
||||
),
|
||||
RaisedButton(
|
||||
ElevatedButton(
|
||||
child: Text('touchDownEnd - touchUpEnd'),
|
||||
onPressed: () => _playBetween('touchDownEnd', 'touchUpEnd'),
|
||||
),
|
||||
@ -112,8 +112,8 @@ class _LottieDetailsState extends State<_LottieDetails>
|
||||
}
|
||||
|
||||
void _playBetween(String marker1, String marker2) {
|
||||
var start = widget.composition.getMarker(marker1).start;
|
||||
var end = widget.composition.getMarker(marker2).start;
|
||||
var start = widget.composition.getMarker(marker1)!.start;
|
||||
var end = widget.composition.getMarker(marker2)!.start;
|
||||
|
||||
_controller.value = start;
|
||||
_controller.animateTo(end,
|
||||
|
63
example/lib/examples/repeat.dart
Normal file
@ -0,0 +1,63 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class MyApp extends StatefulWidget {
|
||||
@override
|
||||
_MyAppState createState() => _MyAppState();
|
||||
}
|
||||
|
||||
class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
|
||||
late final AnimationController _controller;
|
||||
int _repeatIndex = 0;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_controller = AnimationController(vsync: this)
|
||||
..addStatusListener((status) {
|
||||
if (status == AnimationStatus.completed) {
|
||||
setState(() {
|
||||
_repeatIndex++;
|
||||
});
|
||||
if (_repeatIndex < 5) {
|
||||
_controller.reset();
|
||||
_controller.forward();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
home: Scaffold(
|
||||
body: ListView(
|
||||
children: [
|
||||
Lottie.asset(
|
||||
'assets/AndroidWave.json',
|
||||
controller: _controller,
|
||||
width: 150,
|
||||
height: 150,
|
||||
onLoaded: (composition) {
|
||||
// Configure the AnimationController with the duration of the
|
||||
// Lottie file and start the animation.
|
||||
_controller.duration = composition.duration;
|
||||
_controller.forward();
|
||||
},
|
||||
),
|
||||
Center(child: Text('Repeat: $_repeatIndex')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
@ -12,7 +12,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatefulWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_AppState createState() => _AppState();
|
||||
@ -20,7 +20,7 @@ class App extends StatefulWidget {
|
||||
|
||||
class _AppState extends State<App> with TickerProviderStateMixin {
|
||||
int _index = 0;
|
||||
AnimationController _animationController;
|
||||
late final AnimationController _animationController;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
//@dart=2.10
|
||||
|
||||
import 'dart:io';
|
||||
import 'dart:ui';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -26,7 +28,7 @@ class _MyAppState extends State<MyApp> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
RaisedButton(
|
||||
ElevatedButton(
|
||||
child: Text('Export all frames'),
|
||||
onPressed: _export,
|
||||
),
|
||||
|
@ -1,157 +1,24 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'src/all_files.g.dart';
|
||||
|
||||
void main() {
|
||||
Logger.root
|
||||
..level = Level.ALL
|
||||
..onRecord.listen(print);
|
||||
Lottie.traceEnabled = true;
|
||||
runApp(App());
|
||||
}
|
||||
void main() => runApp(MyApp());
|
||||
|
||||
class App extends StatelessWidget {
|
||||
class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
//showPerformanceOverlay: true,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Lottie Flutter'),
|
||||
),
|
||||
body: GridView.builder(
|
||||
itemCount: files.length,
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
itemBuilder: (context, index) {
|
||||
var assetName = files[index];
|
||||
return GestureDetector(
|
||||
child: _Item(
|
||||
child: Lottie.asset(
|
||||
assetName,
|
||||
frameBuilder: (context, child, composition) {
|
||||
return AnimatedOpacity(
|
||||
child: child,
|
||||
opacity: composition == null ? 0 : 1,
|
||||
duration: const Duration(seconds: 1),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.of(context).push(MaterialPageRoute<void>(
|
||||
builder: (context) => Detail(assetName)));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Item extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const _Item({Key key, this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
offset: Offset(2, 2),
|
||||
blurRadius: 5)
|
||||
]),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Detail extends StatefulWidget {
|
||||
final String assetName;
|
||||
|
||||
const Detail(this.assetName, {Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DetailState createState() => _DetailState();
|
||||
}
|
||||
|
||||
class _DetailState extends State<Detail> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
_controller = AnimationController(vsync: this);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('${widget.assetName}'),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
body: ListView(
|
||||
children: [
|
||||
Center(
|
||||
child: Lottie.asset(
|
||||
widget.assetName,
|
||||
controller: _controller,
|
||||
onLoaded: (composition) {
|
||||
_controller.duration = composition.duration;
|
||||
_controller.repeat();
|
||||
},
|
||||
),
|
||||
),
|
||||
AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) => Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: _controller.value,
|
||||
onChanged: (newValue) {
|
||||
_controller.value = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(_controller.isAnimating
|
||||
? Icons.stop
|
||||
: Icons.play_arrow),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (_controller.isAnimating) {
|
||||
_controller.stop();
|
||||
} else {
|
||||
_controller.repeat();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
// Load a Lottie file from your assets
|
||||
Lottie.asset('assets/LottieLogo1.json'),
|
||||
|
||||
// Load a Lottie file from a remote url
|
||||
Lottie.network(
|
||||
'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'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
156
example/lib/main_app.dart
Normal file
@ -0,0 +1,156 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'src/all_files.g.dart';
|
||||
|
||||
void main() {
|
||||
Logger.root
|
||||
..level = Level.ALL
|
||||
..onRecord.listen(print);
|
||||
Lottie.traceEnabled = true;
|
||||
runApp(App());
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
//showPerformanceOverlay: true,
|
||||
home: Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Lottie Flutter'),
|
||||
),
|
||||
body: Scrollbar(
|
||||
child: GridView.builder(
|
||||
itemCount: files.length,
|
||||
gridDelegate:
|
||||
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 4),
|
||||
itemBuilder: (context, index) {
|
||||
var assetName = files[index];
|
||||
return GestureDetector(
|
||||
child: _Item(
|
||||
child: Lottie.asset(
|
||||
assetName,
|
||||
frameBuilder: (context, child, composition) {
|
||||
return AnimatedOpacity(
|
||||
child: child,
|
||||
opacity: composition == null ? 0 : 1,
|
||||
duration: const Duration(seconds: 1),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute<void>(
|
||||
builder: (context) => Detail(assetName)));
|
||||
},
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _Item extends StatelessWidget {
|
||||
final Widget child;
|
||||
|
||||
const _Item({Key? key, required this.child}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
borderRadius: BorderRadius.all(Radius.circular(10)),
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
offset: Offset(2, 2),
|
||||
blurRadius: 5)
|
||||
]),
|
||||
child: child,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class Detail extends StatefulWidget {
|
||||
final String assetName;
|
||||
|
||||
const Detail(this.assetName, {Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_DetailState createState() => _DetailState();
|
||||
}
|
||||
|
||||
class _DetailState extends State<Detail> with TickerProviderStateMixin {
|
||||
late final _controller = AnimationController(vsync: this);
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_controller.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('${widget.assetName}'),
|
||||
),
|
||||
body: SingleChildScrollView(
|
||||
child: Column(
|
||||
children: [
|
||||
Center(
|
||||
child: Lottie.asset(
|
||||
widget.assetName,
|
||||
controller: _controller,
|
||||
onLoaded: (composition) {
|
||||
_controller.duration = composition.duration;
|
||||
_controller.repeat();
|
||||
},
|
||||
),
|
||||
),
|
||||
AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, _) => Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: Slider(
|
||||
value: _controller.value,
|
||||
onChanged: (newValue) {
|
||||
_controller.value = newValue;
|
||||
},
|
||||
),
|
||||
),
|
||||
IconButton(
|
||||
icon: Icon(_controller.isAnimating
|
||||
? Icons.stop
|
||||
: Icons.play_arrow),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (_controller.isAnimating) {
|
||||
_controller.stop();
|
||||
} else {
|
||||
_controller.repeat();
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ void main() async {
|
||||
class App extends StatelessWidget {
|
||||
final LottieComposition composition;
|
||||
|
||||
const App({Key key, this.composition}) : super(key: key);
|
||||
const App({Key? key, required this.composition}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@ -97,13 +97,13 @@ class App extends StatelessWidget {
|
||||
|
||||
class _Lottie extends StatefulWidget {
|
||||
final LottieComposition composition;
|
||||
final double width;
|
||||
final double height;
|
||||
final BoxFit fit;
|
||||
final AlignmentGeometry alignment;
|
||||
final double? width;
|
||||
final double? height;
|
||||
final BoxFit? fit;
|
||||
final AlignmentGeometry? alignment;
|
||||
|
||||
const _Lottie(this.composition,
|
||||
{Key key, this.width, this.height, this.fit, this.alignment})
|
||||
{Key? key, this.width, this.height, this.fit, this.alignment})
|
||||
: super(key: key);
|
||||
|
||||
@override
|
||||
@ -111,7 +111,7 @@ class _Lottie extends StatefulWidget {
|
||||
}
|
||||
|
||||
class __LottieState extends State<_Lottie> with TickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
@ -6,7 +6,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -6,7 +6,7 @@ void main() async {
|
||||
}
|
||||
|
||||
class App extends StatelessWidget {
|
||||
const App({Key key}) : super(key: key);
|
||||
const App({Key? key}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -1,2 +1,3 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
|
@ -1,2 +1,3 @@
|
||||
#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
|
||||
#include "ephemeral/Flutter-Generated.xcconfig"
|
||||
|
@ -1,27 +1,28 @@
|
||||
PODS:
|
||||
- FlutterMacOS (1.0.0)
|
||||
- FlutterMacOS (1.22.4)
|
||||
- path_provider (0.0.1)
|
||||
- path_provider_macos (0.0.1):
|
||||
- FlutterMacOS
|
||||
|
||||
DEPENDENCIES:
|
||||
- FlutterMacOS (from `Flutter/ephemeral/.symlinks/flutter/darwin-x64`)
|
||||
- path_provider (from `Flutter/ephemeral/.symlinks/plugins/path_provider/macos`)
|
||||
- path_provider_macos (from `Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos`)
|
||||
|
||||
SPEC REPOS:
|
||||
trunk:
|
||||
- FlutterMacOS
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
FlutterMacOS:
|
||||
:path: Flutter/ephemeral/.symlinks/flutter/darwin-x64
|
||||
path_provider:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider/macos
|
||||
path_provider_macos:
|
||||
:path: Flutter/ephemeral/.symlinks/plugins/path_provider_macos/macos
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
FlutterMacOS: 15bea8a44d2fa024068daa0140371c020b4b6ff9
|
||||
FlutterMacOS: ac210ef71944b3f04789076d70d4c72c7ec0c619
|
||||
path_provider: e0848572d1d38b9a7dd099e79cf83f5b7e2cde9f
|
||||
path_provider_macos: a0a3fd666cb7cd0448e936fb4abad4052961002b
|
||||
|
||||
PODFILE CHECKSUM: d8ba9b3e9e93c62c74a660b46c6fcb09f03991a7
|
||||
|
||||
COCOAPODS: 1.9.1
|
||||
COCOAPODS: 1.10.1
|
||||
|
@ -26,10 +26,6 @@
|
||||
33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F22044A3C60003C045 /* Assets.xcassets */; };
|
||||
33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 33CC10F42044A3C60003C045 /* MainMenu.xib */; };
|
||||
33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; };
|
||||
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; };
|
||||
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = 33D1A10322148B71006C7A3E /* FlutterMacOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; };
|
||||
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */ = {isa = PBXBuildFile; fileRef = D73912EF22F37F9E000D13A0 /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||
F03CC91740A974D36C2A6384 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0BC6FF5FCD90624533CC60DB /* Pods_Runner.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
@ -50,8 +46,6 @@
|
||||
dstPath = "";
|
||||
dstSubfolderSpec = 10;
|
||||
files = (
|
||||
D73912F222F3801D000D13A0 /* App.framework in Bundle Framework */,
|
||||
33D1A10522148B93006C7A3E /* FlutterMacOS.framework in Bundle Framework */,
|
||||
);
|
||||
name = "Bundle Framework";
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -73,14 +67,12 @@
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Debug.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = "Flutter-Release.xcconfig"; sourceTree = "<group>"; };
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Flutter-Generated.xcconfig"; path = "ephemeral/Flutter-Generated.xcconfig"; sourceTree = "<group>"; };
|
||||
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = FlutterMacOS.framework; path = Flutter/ephemeral/FlutterMacOS.framework; sourceTree = SOURCE_ROOT; };
|
||||
33E51913231747F40026EE4D /* DebugProfile.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DebugProfile.entitlements; sourceTree = "<group>"; };
|
||||
33E51914231749380026EE4D /* Release.entitlements */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.entitlements; path = Release.entitlements; sourceTree = "<group>"; };
|
||||
33E5194F232828860026EE4D /* AppInfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = AppInfo.xcconfig; sourceTree = "<group>"; };
|
||||
5B4C0E87024EC2686CA05E23 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
|
||||
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = "<group>"; };
|
||||
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = "<group>"; };
|
||||
D73912EF22F37F9E000D13A0 /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/ephemeral/App.framework; sourceTree = SOURCE_ROOT; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -88,8 +80,6 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
D73912F022F37F9E000D13A0 /* App.framework in Frameworks */,
|
||||
33D1A10422148B71006C7A3E /* FlutterMacOS.framework in Frameworks */,
|
||||
F03CC91740A974D36C2A6384 /* Pods_Runner.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
@ -145,8 +135,6 @@
|
||||
33CEB47222A05771004F2AC0 /* Flutter-Debug.xcconfig */,
|
||||
33CEB47422A05771004F2AC0 /* Flutter-Release.xcconfig */,
|
||||
33CEB47722A0578A004F2AC0 /* Flutter-Generated.xcconfig */,
|
||||
D73912EF22F37F9E000D13A0 /* App.framework */,
|
||||
33D1A10322148B71006C7A3E /* FlutterMacOS.framework */,
|
||||
);
|
||||
path = Flutter;
|
||||
sourceTree = "<group>";
|
||||
@ -281,7 +269,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename\n";
|
||||
shellScript = "echo \"$PRODUCT_NAME.app\" > \"$PROJECT_DIR\"/Flutter/ephemeral/.app_filename && \"$FLUTTER_ROOT\"/packages/flutter_tools/bin/macos_assemble.sh embed\n";
|
||||
};
|
||||
33CC111E2044C6BF0003C045 /* ShellScript */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
@ -330,10 +318,10 @@
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputFileListPaths = (
|
||||
inputPaths = (
|
||||
);
|
||||
name = "[CP] Embed Pods Frameworks";
|
||||
outputFileListPaths = (
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
|
@ -7,77 +7,70 @@ packages:
|
||||
name: archive
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.13"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.0"
|
||||
version: "3.0.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.4.1"
|
||||
version: "2.5.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
version: "1.1.0"
|
||||
charcode:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: charcode
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.3"
|
||||
version: "1.2.0"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.1"
|
||||
version: "1.1.0"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.14.12"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
version: "1.15.0"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.1.5"
|
||||
version: "3.0.0"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0"
|
||||
ffi:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: ffi
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.3"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -96,7 +89,7 @@ packages:
|
||||
name: flutter_colorpicker
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.3.4"
|
||||
version: "0.4.0-nullsafety.0"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
@ -108,7 +101,7 @@ packages:
|
||||
name: golden_toolkit
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
version: "0.9.0-nullsafety.0"
|
||||
http:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
@ -136,42 +129,42 @@ packages:
|
||||
name: logging
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.11.4"
|
||||
version: "1.0.0"
|
||||
lottie:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.4.1"
|
||||
version: "1.0.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.12.6"
|
||||
version: "0.12.10"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.8"
|
||||
version: "1.3.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
path_provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: path_provider
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.6.11"
|
||||
version: "1.6.27"
|
||||
path_provider_linux:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -185,21 +178,28 @@ packages:
|
||||
name: path_provider_macos
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+3"
|
||||
version: "0.0.4+8"
|
||||
path_provider_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.4"
|
||||
path_provider_windows:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path_provider_windows
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.0.4+3"
|
||||
pedantic:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pedantic
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
version: "1.9.2"
|
||||
platform:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -213,7 +213,7 @@ packages:
|
||||
name: plugin_platform_interface
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.2"
|
||||
version: "1.0.3"
|
||||
process:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -232,63 +232,70 @@ packages:
|
||||
name: source_span
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.0"
|
||||
version: "1.8.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.9.3"
|
||||
version: "1.10.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.0"
|
||||
version: "2.1.0"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
version: "1.1.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
version: "1.2.0"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.2.16"
|
||||
version: "0.2.19"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.1.6"
|
||||
version: "1.3.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "2.0.8"
|
||||
version: "2.1.0"
|
||||
win32:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: win32
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "1.7.4"
|
||||
xdg_directories:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: xdg_directories
|
||||
url: "https://pub.dartlang.org"
|
||||
source: hosted
|
||||
version: "0.1.0"
|
||||
version: "0.1.2"
|
||||
sdks:
|
||||
dart: ">=2.7.0 <3.0.0"
|
||||
flutter: ">=1.12.13+hotfix.5 <2.0.0"
|
||||
dart: ">=2.12.0-29.10.beta <3.0.0"
|
||||
flutter: ">=1.24.0-10.2.pre"
|
||||
|
@ -1,23 +1,23 @@
|
||||
name: lottie_example
|
||||
description: A sample app for the Lottie player
|
||||
version: 0.0.1
|
||||
publish_to: none
|
||||
|
||||
environment:
|
||||
sdk: ">=2.7.0 <3.0.0"
|
||||
sdk: ">=2.12.0-0 <3.0.0"
|
||||
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_colorpicker: ^0.4.0-nullsafety.0
|
||||
http:
|
||||
lottie:
|
||||
path: ../
|
||||
flutter_colorpicker:
|
||||
path_provider:
|
||||
http:
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
sdk: flutter
|
||||
golden_toolkit:
|
||||
golden_toolkit: ^0.9.0-nullsafety.0
|
||||
|
||||
# For information on the generic Dart part of this file, see the
|
||||
# following page: https://dart.dev/tools/pub/pubspec
|
||||
@ -31,10 +31,11 @@ flutter:
|
||||
- assets/lottiefiles/
|
||||
- assets/Mobilo/
|
||||
- assets/Tests/
|
||||
- assets/Tests/images/
|
||||
- assets/Logo/
|
||||
- assets/Images/
|
||||
- assets/Images/WeAccept/
|
||||
- assets/Weather/
|
||||
- assets/weather/
|
||||
- assets/example_with_images/
|
||||
- assets/example_with_images/images/
|
||||
|
||||
|
74
example/test/dynamic_image_test.dart
Normal file
@ -0,0 +1,74 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:lottie/lottie.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('Can specify ImageProvider with zip file ', (tester) async {
|
||||
var size = Size(500, 400);
|
||||
tester.binding.window.physicalSizeTestValue = size;
|
||||
tester.binding.window.devicePixelRatioTestValue = 1.0;
|
||||
|
||||
var callCount = 0;
|
||||
LottieImageProviderFactory imageProviderFactory = (image) {
|
||||
++callCount;
|
||||
return FileImage(File('assets/Images/WeAccept/img_0.png'));
|
||||
};
|
||||
|
||||
var composition = (await tester.runAsync(() => FileLottie(
|
||||
File('assets/spinning_carrousel.zip'),
|
||||
imageProviderFactory: imageProviderFactory)
|
||||
.load()))!;
|
||||
|
||||
await tester.pumpWidget(FilmStrip(composition, size: size));
|
||||
|
||||
expect(callCount, 2);
|
||||
await expectLater(find.byType(FilmStrip),
|
||||
matchesGoldenFile('goldens/dynamic_image/zip_with_provider.png'));
|
||||
});
|
||||
|
||||
testWidgets('Can specify image delegate', (tester) async {
|
||||
var size = Size(500, 400);
|
||||
tester.binding.window.physicalSizeTestValue = size;
|
||||
tester.binding.window.devicePixelRatioTestValue = 1.0;
|
||||
|
||||
var image = await tester.runAsync(
|
||||
() => loadImage(FileImage(File('assets/Images/WeAccept/img_0.png'))));
|
||||
|
||||
var composition = (await tester.runAsync(
|
||||
() => FileLottie(File('assets/spinning_carrousel.zip')).load()))!;
|
||||
|
||||
var delegates = LottieDelegates(image: (composition, asset) {
|
||||
return image;
|
||||
});
|
||||
await tester.pumpWidget(FilmStrip(
|
||||
composition,
|
||||
size: size,
|
||||
delegates: delegates,
|
||||
));
|
||||
|
||||
await expectLater(find.byType(FilmStrip),
|
||||
matchesGoldenFile('goldens/dynamic_image/delegate.png'));
|
||||
});
|
||||
}
|
||||
|
||||
Future<ui.Image?> loadImage(ImageProvider provider) {
|
||||
var completer = Completer<ui.Image?>();
|
||||
var imageStream = provider.resolve(ImageConfiguration.empty);
|
||||
late ImageStreamListener listener;
|
||||
listener = ImageStreamListener((image, synchronousLoaded) {
|
||||
imageStream.removeListener(listener);
|
||||
|
||||
completer.complete(image.image);
|
||||
}, onError: (dynamic e, __) {
|
||||
imageStream.removeListener(listener);
|
||||
|
||||
completer.complete();
|
||||
});
|
||||
imageStream.addListener(listener);
|
||||
|
||||
return completer.future;
|
||||
}
|
@ -7,7 +7,7 @@ import 'package:lottie/lottie.dart';
|
||||
import 'utils.dart';
|
||||
|
||||
void main() {
|
||||
LottieComposition composition;
|
||||
late LottieComposition composition;
|
||||
|
||||
setUpAll(() async {
|
||||
composition = await LottieComposition.fromBytes(
|
||||
@ -15,7 +15,7 @@ void main() {
|
||||
});
|
||||
|
||||
void testGolden(String description, ValueDelegate delegate,
|
||||
{double progress}) async {
|
||||
{double? progress}) async {
|
||||
var screenshotName = description
|
||||
.toLowerCase()
|
||||
.replaceAll(RegExp('[^a-z0-9 ]'), '')
|
||||
@ -33,6 +33,7 @@ void main() {
|
||||
composition: composition,
|
||||
controller: animation,
|
||||
delegates: LottieDelegates(values: [delegate]),
|
||||
addRepaintBoundary: false,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
@ -45,6 +46,7 @@ void main() {
|
||||
composition: composition,
|
||||
controller: animation,
|
||||
delegates: LottieDelegates(values: []),
|
||||
addRepaintBoundary: false,
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
@ -286,8 +288,8 @@ void main() {
|
||||
testGolden(
|
||||
'Opacity interpolation ($progress)',
|
||||
ValueDelegate.transformOpacity(['Shape Layer 1', 'Rectangle'],
|
||||
callback: (frameInfo) => lerpDouble(
|
||||
10, 100, Curves.linear.transform(frameInfo.overallProgress))
|
||||
callback: (frameInfo) => lerpDouble(10, 100,
|
||||
Curves.linear.transform(frameInfo.overallProgress))!
|
||||
.round()),
|
||||
progress: progress);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'dart:async';
|
||||
import 'package:golden_toolkit/golden_toolkit.dart';
|
||||
|
||||
Future<void> main(FutureOr<void> Function() testMain) async {
|
||||
Future<void> testExecutable(FutureOr<void> Function() testMain) async {
|
||||
await loadAppFonts();
|
||||
return testMain();
|
||||
}
|
||||
|
@ -16,7 +16,8 @@ void main() {
|
||||
var size = Size(500, 400);
|
||||
tester.binding.window.physicalSizeTestValue = size;
|
||||
tester.binding.window.devicePixelRatioTestValue = 1.0;
|
||||
var composition = await tester.runAsync(() => FileLottie(asset).load());
|
||||
var composition =
|
||||
(await tester.runAsync(() => FileLottie(asset).load()))!;
|
||||
|
||||
await tester.pumpWidget(FilmStrip(composition, size: size));
|
||||
|
||||
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 3.1 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.7 KiB |
BIN
example/test/goldens/all/battery_optimizations.png
Normal file
After Width: | Height: | Size: 25 KiB |
BIN
example/test/goldens/all/camera_change.png
Normal file
After Width: | Height: | Size: 9.0 KiB |
BIN
example/test/goldens/all/envelope.png
Normal file
After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 95 KiB After Width: | Height: | Size: 95 KiB |
Before Width: | Height: | Size: 9.2 KiB After Width: | Height: | Size: 9.2 KiB |
Before Width: | Height: | Size: 64 KiB After Width: | Height: | Size: 64 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 63 KiB After Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 62 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 91 KiB After Width: | Height: | Size: 91 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB |
Before Width: | Height: | Size: 58 KiB After Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 120 KiB After Width: | Height: | Size: 120 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |