bolter_flutter 4.3.4
bolter_flutter: ^4.3.4 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';
//data layer
abstract class SomeApi {
int get value;
}
class SomeApiImplementation implements SomeApi {
@override
int get value => 123;
}
class SomeRepoImpl implements SomeRepo {
final SomeApi _api;
SomeRepoImpl(this._api);
@override
int get value => int.parse(_api.value.toString());
}
//domain
abstract class SomeRepo {
int get value;
}
class SomeState {
// default value
int value = 0;
}
class SomeUseCase {
final SomeRepo _repo;
final SomeState _state;
SomeUseCase(this._repo, this._state);
}
class State {
var _counter = 0;
int get counter => _counter;
void increment() => _counter++;
}
void main() {
runApp(BolterProvider(
child: MaterialApp(
home: Scaffold(
body: PresenterProvider(
presenter: P(),
child: Builder(builder: (context) {
return BolterTabNavigator<P>(
expandBody: true,
blurValue: 10,
// tabBarColor: Colors.blue,
tabsPadding: 5,
pages: {
'1': (ctx) => Container(
color: Colors.transparent,
alignment: Alignment.center,
child: SingleChildScrollView(
child: Container(
height: 2000,
child: PresenterProvider(
presenter: C(),
child: Builder(builder: (context) {
return InkWell(
onTap: () {
final p = context.presenter<C>();
Future.delayed(Duration(seconds: 4), () {
// ignore: invalid_use_of_protected_member
p.runContext((conteqxt) {
conteqxt.presenter();
});
});
print("Tap!");
},
child: SizedBox(
width: 80.0,
height: 80.0,
child: Center(
child: Text("Tap me!"),
),
),
);
}),
),
),
),
),
'2': (ctx) => Container(
color: Colors.green,
),
'3': (ctx) => Container(
color: Colors.green,
),
// '4': Container(
// color: Colors.green,
// ),
},
tabs: {
'1': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
'2': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
'3': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
},
selectedTabs: {
'1': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
'2': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
'3': Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
Icons.ac_unit,
color: Colors.black,
),
Text('1234')
],
),
},
);
}),
),
),
),
));
}
final c = TabNavigation('1');
class P extends Presenter with TabNavigationPresenter {
@override
TabNavigation get tabNavigation => c;
}
class C extends Presenter with TabNavigationPresenter {
@override
TabNavigation get tabNavigation => c;
}