Sunday, 4 August 2019

A rich and easy-to-use flutter page transition package



flutter_page_transition

A rich, convenient, easy-to-use flutter page transition package.













Getting Started

Add this to your package's pubspec.yaml file:
dependencies:
  flutter_page_transition: ^0.1.0
YAML
You can also depend on this package stored in my repository:
flutter_page_transition:
  git:
    url: git://github.com/handoing/flutter_page_transition.git
YAML
You should then run flutter packages upgrade.

Transition Type

PAGE TRANSITION TYPEDIRECTION
slideInLeft⬅️
slideInLeft➡️
slideInUp⬆️
slideInDown⬇️
slideLeft⬅️
slideRight➡️
slideUp⬆️
slideDown⬇️
slideParallaxLeft⬅️
slideParallaxRight➡️
slideParallaxUp⬆️
slideParallaxDown⬇️
slideZoomLeft⬅️
slideZoomRight➡️
slideZoomUp⬆️
slideZoomDown⬇️
rippleRightUp↖️
rippleLeftUp↗️
transferRight⬅️
transferUp⬆️
fadeIn
custom

Example

Use PageRouteBuilder Widget
initialRoute: 'Home',
onGenerateRoute: (RouteSettings routeSettings){
    return new PageRouteBuilder<dynamic>(
      settings: routeSettings,
      pageBuilder: (BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) {
        switch (routeSettings.name){
          case 'Home':
            return HomePage();
          case 'Other':
            return OtherPage();
          default:
            return null;
        }
      },
      transitionDuration: const Duration(milliseconds: 300),
      transitionsBuilder: (BuildContext context, Animation<double> animation,
          Animation<double> secondaryAnimation, Widget child) {
          return effectMap[PageTransitionType.slideInLeft](Curves.linear, animation, secondaryAnimation, child);
      }
    );
}

// use Navigator
Navigator.of(context).pushNamed('Other');
// or
Navigator.of(context).push(PageTransition(type: PageTransitionType.slideInLeft, child: FirstPage()));


Dart
Create custom methods:
Bash

Test Driver

run driver test
ce example/
flutter drive --target=test_driver/app.dart
Bash

GitHub

A rich, convenient, easy-to-use flutter page transition package — Read More
Latest commit to the master branch on 7-18-2019
Download as zip


Fun translation with flutter and BLoC pattern

Error Boundaries for Flutter



Boundary

Boundary is a new widget for Flutter that takes over FlutterError.onError and ErrorWidget.builder to make them composable and scoped.
If you ever wanted to have your error reporting applied only a specific part of your widget tree, or if you found difficult to implement an "Oops"/Loading screen, then this library is for you.

Installation

For Boundary to work, it is necessary to call setupBoundary first.
This can be done inside your main function like so:
void main() {
  setupBoundary();
  runApp(MyApp());
}
Dart
For tests purpose, setupBoundary returns a function to revert the settings
to their default behavior:
testWidgets('mytest', (tester) async {
  final restore = setupBoundary();

  await tester.pumpWidget(
    Boundary(
      fallback: (_, __) => Container(),
      child: Text('foo', textDirection: TextDirection.ltr),
    )
  );

  // necessary call before any `expect`, otherwise the test framework will throw
  restore();

  expect(find.text('foo'), findsOneWidget);
});
Dart

Principle

Error reporting and fallback UI are now represented through one universal widget:
Boundary
This widget, when inserted inside the widget tree, is able to catch exceptions
from descendants (and only descendants) to then create a fallback UI.
Here's a typical example:
Scaffold(
  appBar: AppBar(title: const Text('hello')),
  body: Boundary(
    fallbackBuilder: (context, error) {
      return const Center(child: Text('Oops'));
    },
    child: Container(
      color: Colors.red,
      padding: const EdgeInsets.all(50),
      child: Builder(builder: (_) {
        // a descendant somethow failed
        throw 42;
      }),
    ),
  ),
);
Dart
Which renders the following:


Notice how, even if there's a Container with padding and a red background
as child of Boundary, the "Oops" screen doesn't show any of these:
The widget returned by fallbackBuilder is in an entirely different widget tree.
But the failing subtree (Container -> Builder) is not removed for the tree either!
Its state is preserved and it is simply offstaged, until it rebuilds successfuly.
This is proved by the following example, which shows how Boundary can be used
to show a loading/error screen from a FutureBuilder deeper in the widget tree
– without having a reference on the Future.
Boundary(
  fallbackBuilder: (_, error) {
    // doesn't have the reference on the Future, but
    // is still able to display loading/error state
    if (error is Loading) {
      return const Center(child: CircularProgressIndicator());
    } else if (error is NotFoundError) {
      return const NotFoundScreen();
    } else {
      return const OopsScreen();
    }
  },
  child: SubtreeThatHasAFutureBuilder(),
)

Dart


FAQ

How to remove the fallback screen

Once an exception is thrown, the fallback screen is shown. But you may want to
stop showing that fallback at some point.
To achieve this, simply rebuild the failling widget such that it doesn't throw
anymore. This will automatically remove the fallback screen.

What happens if there's an exception inside fallbackBuilder?

If there's an exception inside fallbackBuilder, then the exception is propagated
to the next Boundary, until there are none anymore.
Boundary(
  fallbackBuilder: (_, err) => Text(err.toString()),
  child: Boundary(
    fallbackBuilder: (_, err) {
      print(err);
      throw err;
    },
    child: Builder(builder: (_) {
      throw 42;
    })
  )
)
Dart
Using the previous snippet, this will first print 42 in the console, then
render a Text with "42" on screen.

GitHub

Error Boundaries for Flutter — Read More
Latest commit to the master branch on 7-20-2019
Download as zip

A simple mobile game built with Flutter and BLoC pattern



FLX

A mobile game using Flutter to test your reaction speed in various ways

Key Features

  • Three different play modes!
    • Visual mode: tap when the screen color changes to green
    • Vibrate mode: tap when your phone vibrates
    • Sound mode: tap when you hear a laser sound
  • Beat your highscore, get better!
    • Highscore system, accessible through homepage's drawer
    • Highscore time measured in seconds for each mode individually
  • Saving your highscore for later plays!
    • Storing highscore objects in shared preference
    • Highscore list retrieval upon application launch
    • JSON encoding and decoding
  • Beautiful animations!
    • Dedicated Flare animations for each game mode
    • Dedicated Flare animation for personal stats

Features to be Implemented

  • Online rankings for each mode
  • Competitive mode

GitHub

A mobile game using Flutter to test your reaction speed in various ways — Read More
Latest commit to the master branch on 7-16-2019
Download as zip

A Flutter movie app build with Fish-Redux and TMDB api



movie

A Flutter movie app build with Fish-Redux and TMDB api.



GitHub

😎🎬A Flutter movie app build with Fish-Redux and The Movie DB api. — Read More
Latest commit to the master branch on 8-2-2019
Download as zip