Transition Example

The transition example gives a good overview over the following features of EZ Flutter:

  • Transition

Copy the code in your main.dart file:

import 'package:flutter/material.dart';
import 'package:ez_flutter/ez_flutter.dart';

void main() => EzRunner.run(MyHomePage(),
    materialThemeData: ThemeData(primarySwatch: Colors.pink));

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State {
  void toProcess() async {
    EzLoadingBloc bloc =
        EzBlocProvider.of<EzGlobalBloc>(context).get(EzLoadingBloc);
    for (int i = 0; i < 101; i++) {
      bloc.addition.add("Loading $i%");
      await new Future.delayed(const Duration(milliseconds: 300));
    }
    Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => MyHomePage(),
        ));
  }

  @override
  Widget build(BuildContext context) {
    return EzScaffold(
      appBar: AppBar(
        title: Text('EZ Flutter'),
      ),
      body: Container(
        color: Colors.white,
        child: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              RaisedButton(
                child: Text("Start Transition"),
                onPressed: () {
                  Navigator.push(
                    context,
                    MaterialPageRoute(
                        builder: (context) => EzTransition(
                            EzDots(
                              text: Text("Loading 0%"),
                            ),
                            toProcess,
                            backgroundColor: Colors.white)),
                  );
                },
              )
            ],
          ),
        ),
      ),
    );
  }
}

Transition Example