Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
GIfatahTH committed Jun 7, 2021
1 parent b195943 commit 86a344b
Show file tree
Hide file tree
Showing 37 changed files with 2,229 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ build/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*
android/
ios/
linux/
web/

.idea

Expand Down
46 changes: 46 additions & 0 deletions examples/animatedWidget/ex_001_animated_container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

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

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions examples/animatedWidget/ex_001_animated_container/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: b22742018b3edf16c6cadd7b76d9db5e7f9064b5
channel: stable

project_type: app
73 changes: 73 additions & 0 deletions examples/animatedWidget/ex_001_animated_container/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# ex_001_animated_container

This is a replication of the [AnimatedContainer example](https://api.flutter.dev/flutter/widgets/AnimatedContainer-class.html) using `AnimateWidget`.

```dart
void main() => runApp(const MyAnimatedContainer());
class MyAnimatedContainer extends StatelessWidget {
const MyAnimatedContainer({Key? key}) : super(key: key);
static const String _title = 'Implicit Animation';
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
),
);
}
}
/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);
@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}
/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
bool selected = false;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
selected = !selected;
});
},
child: Center(
child: AnimateWidget(
duration: const Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
builder: (context, animate) {
final width = animate(selected ? 200.0 : 100.0);
final height = animate(selected ? 100.0 : 200.0, 'height');
final alignment = animate(
selected
? Alignment.center
: AlignmentDirectional.topCenter,
);
final Color? color = animate(
selected ? Colors.red : Colors.blue,
);
return Container(
width: width,
height: height,
color: color,
alignment: alignment,
child: const FlutterLogo(size: 75),
);
},
),
),
);
}
}
```
96 changes: 96 additions & 0 deletions examples/animatedWidget/ex_001_animated_container/lib/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'package:animator/animator.dart';
import 'package:flutter/material.dart';

void main() => runApp(const MyAnimatedContainer());

/// Inspired form https://api.flutter.dev/flutter/widgets/AnimatedContainer-class.html
class MyAnimatedContainer extends StatelessWidget {
const MyAnimatedContainer({Key? key}) : super(key: key);

static const String _title = 'Implicit Animation';

@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text(_title)),
body: const MyStatefulWidget(),
),
);
}
}

/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
const MyStatefulWidget({Key? key}) : super(key: key);

@override
State<MyStatefulWidget> createState() => _MyStatefulWidgetState();
}

/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
bool selected = false;

@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
setState(() {
selected = !selected;
});
},
child: Column(
children: [
Text('Flutter AnimatedContainer'),
SizedBox(height: 20),
Expanded(
child: Center(
child: AnimatedContainer(
width: selected ? 200.0 : 100.0,
height: selected ? 100.0 : 200.0,
color: selected ? Colors.red : Colors.blue,
alignment: selected
? Alignment.center
: AlignmentDirectional.topCenter,
duration: const Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
child: const FlutterLogo(size: 75),
),
),
),
Text('Using AnimateWidget'),
SizedBox(height: 20),
Expanded(
child: Center(
child: AnimateWidget(
duration: const Duration(seconds: 2),
curve: Curves.fastOutSlowIn,
builder: (context, animate) {
final width = animate(selected ? 200.0 : 100.0);
final height = animate(selected ? 100.0 : 200.0, 'height');
final alignment = animate(
selected
? Alignment.center
: AlignmentDirectional.topCenter,
);
final Color? color = animate(
selected ? Colors.red : Colors.blue,
);
return Container(
width: width,
height: height,
color: color,
alignment: alignment,
child: const FlutterLogo(size: 75),
);
},
),
),
)
],
),
);
}
}
78 changes: 78 additions & 0 deletions examples/animatedWidget/ex_001_animated_container/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: ex_001_animated_container
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
sdk: ">=2.12.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
animator:
path: ../../../


# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2

dev_dependencies:
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
46 changes: 46 additions & 0 deletions examples/animatedWidget/ex_002_explicit_animation/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/

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

# Web related
lib/generated_plugin_registrant.dart

# Symbolication related
app.*.symbols

# Obfuscation related
app.*.map.json

# Android Studio will place build artifacts here
/android/app/debug
/android/app/profile
/android/app/release
10 changes: 10 additions & 0 deletions examples/animatedWidget/ex_002_explicit_animation/.metadata
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.

version:
revision: b22742018b3edf16c6cadd7b76d9db5e7f9064b5
channel: stable

project_type: app
Loading

0 comments on commit 86a344b

Please sign in to comment.