Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Added FlareAnimationProvider to load from different sources #48

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,61 @@
.DS_Store
pubspec.lock
.idea
*.iml

# Created by https://www.gitignore.io/api/flutter
# Edit at https://www.gitignore.io/?templates=flutter

### Flutter ###
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.packages
.pub-cache/
.pub/
build/

# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages

# End of https://www.gitignore.io/api/flutter
2 changes: 1 addition & 1 deletion example/change_color/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class _MyHomePageState extends State<MyHomePage> implements FlareController {
// the App.build method, and use it to set our appbar title.
title: Text(widget.title),
),
body: FlareActor("assets/Change Color Example.flr", // You can find the example project here: https://www.2dimensions.com/a/castor/files/flare/change-color-example
body: FlareActor(FlareAssetAnimationProvider(context: context, fileName: 'Change Color Example.flr'), // You can find the example project here: https://www.2dimensions.com/a/castor/files/flare/change-color-example
fit: BoxFit.contain, alignment: Alignment.center, controller: this),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
Expand Down
6 changes: 5 additions & 1 deletion example/favorite/lib/buttons_row.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flare_flutter/flare_providers.dart';
import 'package:flutter/material.dart';
import 'package:flare_flutter/flare_actor.dart';

Expand All @@ -8,6 +9,7 @@ class ButtonsRow extends StatefulWidget {

class _ButtonsState extends State<ButtonsRow> {
static final double containerSize = 20.0;

// Wheather this element is a favorite or not.
bool _isFav = false;

Expand Down Expand Up @@ -44,7 +46,9 @@ class _ButtonsState extends State<ButtonsRow> {
margin: EdgeInsets.only(right: 10),
width: containerSize,
height: containerSize,
child: FlareActor("assets/Favorite.flr",
child: FlareActor(
FlareAssetAnimationProvider(
context: context, fileName: 'assets/Favorite.flr'),
shouldClip: false,
// Play the animation depending on the state.
animation:
Expand Down
4 changes: 2 additions & 2 deletions example/favorite/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:heart_demo/main.dart';
import 'package:favorite/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(Heart());

// Verify that our counter starts at 0.
expect(find.text('0'), findsOneWidget);
Expand Down
6 changes: 4 additions & 2 deletions example/penguin_dance/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ class _MyHomePageState extends State<MyHomePage> implements FlareController {
body: new Stack(
children: [
Positioned.fill(
child: FlareActor("assets/Penguin.flr",
child: FlareActor(
FlareAssetAnimationProvider(
context: context, fileName: 'Penguin.flr'),
alignment: Alignment.center,
isPaused: _isPaused,
isPaused: _isPaused,
fit: BoxFit.cover,
animation: "walk",
controller: this)),
Expand Down
4 changes: 3 additions & 1 deletion example/simple/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import "package:flare_flutter/flare_actor.dart";
import 'package:flare_flutter/flare_providers.dart';
import "package:flutter/material.dart";

void main() => runApp(MyApp());
Expand Down Expand Up @@ -38,7 +39,8 @@ class _MyHomePageState extends State<MyHomePage> {
children: [
Expanded(
child: FlareActor(
"assets/Filip.flr",
FlareAssetAnimationProvider(
context: context, fileName: 'Filip.flr'),
alignment: Alignment.center,
fit: BoxFit.contain,
animation: _animationName,
Expand Down
83 changes: 77 additions & 6 deletions example/simple/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.6"
cupertino_icons:
dependency: "direct main"
description:
Expand All @@ -42,24 +56,45 @@ packages:
path: "../../flare_dart"
relative: true
source: path
version: "1.1.0"
version: "1.3.0"
flare_flutter:
dependency: "direct main"
description:
path: "../../flare_flutter"
relative: true
source: path
version: "1.1.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_cache_manager:
dependency: transitive
description:
name: flutter_cache_manager
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+1"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
matcher:
dependency: transitive
description:
Expand All @@ -81,6 +116,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.2"
path_provider:
dependency: transitive
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0+1"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
quiver:
dependency: transitive
description:
Expand All @@ -99,7 +148,14 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.1"
version: "1.5.4"
sqflite:
dependency: transitive
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
stack_trace:
dependency: transitive
description:
Expand All @@ -121,27 +177,41 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "1.1.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.1"
version: "0.2.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
uuid:
dependency: transitive
description:
name: uuid
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
vector_math:
dependency: transitive
description:
Expand All @@ -150,4 +220,5 @@ packages:
source: hosted
version: "2.0.8"
sdks:
dart: ">=2.0.0 <3.0.0"
dart: ">=2.1.0 <3.0.0"
flutter: ">=0.1.4 <2.0.0"
3 changes: 2 additions & 1 deletion example/slider/lib/page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'dart:async';
import 'dart:ui';

import 'package:flare_flutter/flare_providers.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flare_flutter/flare_actor.dart';
Expand Down Expand Up @@ -50,7 +51,7 @@ class _PageState extends State<Page> with SingleTickerProviderStateMixin {
child: Listener(
onPointerUp: _scheduleDemo,
child: Stack(fit: StackFit.expand, children: [
FlareActor("assets/Resizing_House.flr",
FlareActor(FlareAssetAnimationProvider(context:context,fileName:"Resizing_House.flr"),
controller: _houseController,
fit: BoxFit.cover,
),
Expand Down
Loading