mix_stack 1.0.3 mix_stack: ^1.0.3 copied to clipboard
MixStack lets you connects Flutter smoothly with existing Native codebase without headache.
import 'dart:core';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import 'package:mix_stack/mix_stack.dart';
import 'common_utils.dart';
import 'simple_flutter_page.dart';
import 'test_area_inset.dart';
import 'test_main.dart';
import 'test_popup_window.dart';
void main() {
runApp(MyApp());
}
class TestObserver extends RouteObserver<PageRoute<dynamic>> {
@override
void didPush(Route<dynamic> route, Route<dynamic> previousRoute) {
print('MixStack test push ${route.settings.name}');
}
@override
void didPop(Route<dynamic> route, Route<dynamic> previousRoute) {
print('MixStack test pop ${route.settings.name}');
}
}
class MyApp extends StatelessWidget {
MyApp() {
defineRoutes();
}
void defineRoute(String route, Handler handler) {
router.define(
route,
handler: handler,
transitionType: TransitionType.cupertino,
);
}
void defineRoutes() {
defineRoute(
'/test_main',
Handler(handlerFunc: (ctx, params) => TestMain()),
);
defineRoute(
'/simple_flutter_page',
Handler(
handlerFunc: (ctx, params) => SimpleFlutterPage('/simple_flutter_page'),
),
);
defineRoute(
'/popup_window',
Handler(
handlerFunc: (ctx, params) => TestPopupWindow(),
),
);
defineRoute(
'/area_inset',
Handler(
handlerFunc: (ctx, params) => TestAreaInset(),
),
);
defineRoute(
'/clear_stack',
Handler(
handlerFunc: (ctx, params) => SimpleFlutterPage('/clear_stack'),
),
);
MixStack.lifecycleNotifier.addListener(() {
print('MixStack lifecycle:${MixStack.lifecycleNotifier.value}');
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MixStackApp(
routeBuilder: (context, path) {
return router.matchRoute(context, path).route;
},
observersBuilder: () {
return [TestObserver()];
},
debugRoot: '/test_blue',
),
);
}
}