bolter_flutter 5.0.2 bolter_flutter: ^5.0.2 copied to clipboard
based on bolter library extensions for manage widgets and state
import 'package:bolter_flutter/bolter_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
void main() {
runApp(BolterProvider(
child: PresenterProvider(
presenter: NavPresenter(Navigation([F()])),
child: PresenterProvider(
presenter: NavTabPresenter(TabNavigation("1")),
child: CupertinoApp(
color: Colors.white,
home: Builder(builder: (context) {
return BolterNavigator<NavPresenter>(
// navigationPresenter: context.presenter<NavPresenter>(),
routes: {
F: (c) {
// return Root(
// key: ValueKey('1234'),
// );
return BolterTabNavigator<NavTabPresenter>(
key: ValueKey('1231232131'),
pages: {"1": (ctx) => Root()},
tabs: {"1": (ctx) => Icon(Icons.add)},
selectedTabs: {"1": (ctx) => Icon(Icons.add)},
);
},
S: (c) => Center(
child: RaisedButton(
onPressed: () {
Navigator.of(c).pop();
},
),
)
},
);
}),
),
),
),
));
}
class NavPresenter extends Presenter with NavigationPresenter {
final Navigation navState;
NavPresenter(this.navState);
@override
Navigation get navigation => navState;
}
class NavTabPresenter extends Presenter with TabNavigationPresenter {
final TabNavigation navState;
NavTabPresenter(this.navState);
@override
TabNavigation get tabNavigation => navState;
}
class Root extends StatefulWidget {
const Root({Key key}) : super(key: key);
@override
_RootState createState() => _RootState();
}
class _RootState extends State<Root> {
@override
Widget build(BuildContext context) {
print('root');
return Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
FutureBuilder<String>(
builder: (c, v) {
print('FURTURE');
return Material(child: Text(v?.data ?? "01"));
},
future: Future.value("123"),
),
RaisedButton(
onPressed: () {
context.presenter<NavPresenter>().push(S());
},
),
],
),
);
}
}
class F extends BolterRoute {}
class S extends BolterRoute {}