osam_flutter 3.1.1 copy "osam_flutter: ^3.1.1" to clipboard
osam_flutter: ^3.1.1 copied to clipboard

discontinued
outdated

Navigation and UI elements which fits with Osam library

example/lib/main.dart

import 'dart:async';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:osam_flutter/osam_flutter.dart';
import 'package:osam_flutter/src/navigation/osam_route.dart';

final navKey = GlobalKey<NavigatorState>();

void main() async {
  final state = N();
 final r =  state.findRoute('2');
 print(r);
//  runApp(MaterialApp(
//    navigatorKey: navKey,
//    home: App(null),
//  ));
}

class App extends StatefulWidget {
  final Core core;

  const App(this.core);

  @override
  _AppState createState() => _AppState();
}

class _AppState extends State<App> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          widget.core.news = [News(1)];
          widget.core.c.add(widget.core.news);
        },
      ),
      body: OsamBuilder<List<News>>(
          stream: widget.core.stream,
          builder: (context, snapshot) {
            return ListView(
              children: snapshot
                  .map((e) => Row(
                        key: ValueKey(e.id),
                        children: <Widget>[
                          Container(
                            height: 600,
                            child: OsamBuilder(
                              stream: e.stream,
                              builder: (ctx, data) => Text(data.toString()),
                            ),
                          ),
                          RaisedButton(
                            onPressed: () {
                              e.isFavorite = !e.isFavorite;
                              e.c.add(e.isFavorite);
                            },
                          )
                        ],
                      ))
                  .toList(),
            );
          }),
    );
  }
}

enum MR { first, second }

class Core {
  var num = 0;
  var news = <News>[News(1), News(2), News(3)];

  StreamController<List<News>> c;

  init() {
    c = StreamController<List<News>>.broadcast(onCancel: () {
      c.close();
      c = null;
    });
  }

  ValueStream<List<News>> get stream => ValueStream(c.stream, news);

  Core() {
    init();
  }
}

class News {
  bool isFavorite = false;
  final int id;

  StreamController<bool> c;

  ValueStream<bool> get stream => ValueStream(c.stream, isFavorite);

  init() {
    c = StreamController<bool>.broadcast(onCancel: () {
      c.close();
      c = null;
    });
  }

  News(this.id) {
    init();
  }
}

class N with Navigation {
  final routes = PropertyNotifier([OsamRoute('1'), OsamRoute('2')]);
}
2
likes
0
pub points
0%
popularity

Publisher

verified publisherrenesanse.net

Navigation and UI elements which fits with Osam library

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

after_layout, flutter, osam, provider

More

Packages that depend on osam_flutter