easy_church_json 0.1.1 copy "easy_church_json: ^0.1.1" to clipboard
easy_church_json: ^0.1.1 copied to clipboard

outdated

Plugin to connect to the easy church API. Easy church API is an API for the android app 'Easy church' soon to be on play store. This package is private and not mean't for public use.

example/lib/main.dart

import 'package:easy_church_json_example/Events.dart';
import 'package:easy_church_json_example/Notifications.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:imei_plugin/imei_plugin.dart';

import 'package:flutter/services.dart';
import 'package:easy_church_json/easy_church_json.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  EasyChurchJson easyChurchJson = new EasyChurchJson();
  String imei = "";

  @override
  void initState() {
    super.initState();
    initPlatformState();
    getImei();
  }

  void getImei() async {
    var im = await ImeiPlugin.getImei;
    imei = im.toString();

//    getChurch();
//    easyChurchJson.followChurch("5d116bd5c0bf362a3c545f05", imei);
    getChurch();
  }

  void getChurch() async {
    List<SingleChurch> churches = await easyChurchJson.getChurch(imei);

    if (churches.length == 0) {
      print("The user has not followed any church yet.");
    }
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
//      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          body: CustomScrollView(
        slivers: <Widget>[
          SliverAppBar(
            backgroundColor: Colors.grey.shade800,
            title: Text("Easy church API"),
          ),
          SliverToBoxAdapter(
            child: Text("All churches"),
          ),
          FutureBuilder(
              future: easyChurchJson.getAllChurches(),
              initialData: <SingleChurch>[],
              builder: ((BuildContext context,
                  AsyncSnapshot<List<SingleChurch>> snapshot) {
                if (!snapshot.hasData) {
                  return SliverToBoxAdapter(child: SizedBox());
                }
                return SliverFixedExtentList(
                    delegate: SliverChildBuilderDelegate((
                      BuildContext context,
                      int index,
                    ) {
                      return ListTile(
                        onTap: () {},
                        title: Text(snapshot.data[index].name),
                        subtitle: Text(snapshot.data[index].bio != null
                            ? snapshot.data[index].bio
                            : ""),
                        trailing: Row(
                          mainAxisSize: MainAxisSize.min,
                          children: <Widget>[
                            RaisedButton(
                              onPressed: () {
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                      builder: (context) =>
                                          Events(snapshot.data[index].id),
                                    ));
                              },
                              child: Text("Events"),
                            ),
                            RaisedButton(
                              onPressed: () {
                                Navigator.push(
                                    context,
                                    MaterialPageRoute(
                                      builder: (context) => Notifications(
                                          snapshot.data[index].id),
                                    ));
                              },
                              child: Text("Notifications"),
                            ),
                          ],
                        ),
                      );
                    }, childCount: snapshot.data.length),
                    itemExtent: 70.0);
              })),
        ],
      )),
    );
  }
}
0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Plugin to connect to the easy church API. Easy church API is an API for the android app 'Easy church' soon to be on play store. This package is private and not mean't for public use.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

dio, flutter, http

More

Packages that depend on easy_church_json