bolter_flutter 2.0.3 copy "bolter_flutter: ^2.0.3" to clipboard
bolter_flutter: ^2.0.3 copied to clipboard

discontinuedreplaced by: bolter
outdated

based on bolter library extensions for manage widgets and state

example/lib/main.dart

import 'package:bolter/bolter.dart';
import 'package:bolter_flutter/bolter_flutter.dart';
import 'package:bolter_flutter/src/value_stream_builder.dart';
import 'package:flutter/material.dart';

class State {
  var _counter = 0;

  int get counter => _counter;

  void increment() => _counter++;
}

void main() {
  final bolter = Bolter(State());
  runApp(BolterProvider(
    bolter: bolter,
    child: MaterialApp(
      home: Scaffold(
        body: ValueStreamBuilder<int>(
          valueStream: bolter.stream((state) => state.counter),
          builder: (_, value) {
            return PresenterProvider(
              presenter: P(),
              child: Builder(builder: (context) {
                return BolterTabNavigator<P>(
                  tabBackground: Colors.tealAccent,
                  tabsPadding: 5,
                  pages: {
                    '1': Container(
                      color: Colors.transparent,
                      alignment: Alignment.center,
                      child: Material(
                        clipBehavior: Clip.antiAlias,
                        borderRadius: BorderRadius.circular(25.0),
                        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': Container(
                      color: Colors.green,
                    ),
                    '3': Container(
                      color: Colors.green,
                    ),
                    // '4': Container(
                    //   color: Colors.green,
                    // ),
                  },
                  tabs: {
                    '1': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    '2': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    '3': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    // '4': Column(
                    //   mainAxisSize: MainAxisSize.min,
                    //   children: <Widget>[
                    //     Icon(
                    //       Icons.ac_unit,
                    //       color: Colors.black,
                    //     ),
                    //   ],
                    // ),
                  },
                  selectedTabs: {
                    '1': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    '2': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    '3': Icon(
                      Icons.ac_unit,
                      color: Colors.black,
                    ),
                    // '4': Column(
                    //   mainAxisSize: MainAxisSize.min,
                    //   children: <Widget>[
                    //     Icon(
                    //       Icons.ac_unit,
                    //       color: Colors.black,
                    //     ),
                    //   ],
                    // ),
                  },
                );
              }),
            );
          },
        ),
      ),
    ),
  ));
}

final c = TabNavigation('1');

class P extends Presenter with TabNavigationPresenter {
  @override
  TabNavigation get tabNavigation => c;

  @override
  void dispose() {
    super.dispose();
  }
}

class C extends Presenter with TabNavigationPresenter {
  @override
  TabNavigation get tabNavigation => c;
}