osam_flutter 1.0.2 osam_flutter: ^1.0.2 copied to clipboard
Navigation and UI elements which fits with Osam library
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:osam_flutter/osam_flutter.dart';
void main() async {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return UseCaseProvider(
null,
null,
null,
child: PresenterProvider(
presenter: NavPresenter(),
child: MaterialApp(
home: OsamNavigator<NavPresenter>({
'1': (ctx) => Page1(key: ValueKey('1'), color: Colors.red),
'2': (ctx) => Page1(key: ValueKey('2'), color: Colors.green),
}),
),
),
);
}
}
class Page1 extends StatelessWidget {
final Color color;
const Page1({Key key, this.color}) : super(key: key);
@override
Widget build(BuildContext context) {
final s = showBottomSheet(context: null, builder: null);
return Scaffold(
appBar: AppBar(),
body: Container(
color: color,
child: Center(
child: RaisedButton(
onPressed: () => context.presenter<NavPresenter>().push(color == Colors.red ? '2' : '1'),
child: Text(color == Colors.red ? 'push 2' : 'push 1'),
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => showDialog(context: context, builder: (ctx) => Text('123')).then((_) {
print('2134');
}),
),
);
}
}
class NavPresenter extends Presenter with NavigationPresenter {
@override
NavigationState get navigationState => nav;
}
final nav = NavigationState(['1']);