build method

  1. @override
dynamic build (
  1. dynamic context
)

Implementation

@override
Widget build(BuildContext context) {
  return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        // first down arrow
        leading: IconButton(
          icon: Icon(Icons.arrow_downward),
          tooltip: 'Go back',
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        // title
        title: Text(
          'Settings',
          style: TextStyle(fontWeight: FontWeight.bold, fontSize: 32),
        ),
        // second down arrow
        actions: <Widget>[
          IconButton(
            icon: Icon(Icons.arrow_downward),
            tooltip: 'Go back',
            onPressed: () {
              Navigator.pop(context);
            },
          ),
        ],
      ),
      body: NotificationListener<OverscrollNotification>(
          onNotification: (t) {
            if (t.overscroll < -15) {
              Navigator.pop(context);
              return true;
            }
            return false;
          },
          child: ListView(children: <Widget>[
            // GENERAL SETTINGS
            Container(
              margin: EdgeInsets.fromLTRB(8, 15, 8, 0),
              child: Center(
                child: Text(
                  'General',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
                ),
              ),
            ),
            cardBuilder([
              SwitchListTile(
                title: Text('Push Notifications'),
                value: state.prefs.getBool('pushNotifications'),
                onChanged: (bool value) {
                  state.prefs.setBool('pushNotifications', value);
                  setState();
                },
                secondary: const Icon(Icons.notifications),
              ),
              Builder(
                  builder: (context) => SwitchListTile(
                        title: Text('Lights Out'),
                        value: state.prefs.getBool('darkMode'),
                        onChanged: (bool value) {
                          state.prefs.setBool('darkMode', value);
                          BlocProvider.of<PrefsBloc>(context)
                              .add(ThemeChangedEvent(value));
                          setState();
                        },
                        secondary: const Icon(Icons.lightbulb_outline),
                      ))
            ]),
            // SHUTTLE SETTINGS
            Container(
              margin: EdgeInsets.fromLTRB(8, 15, 8, 0),
              child: Center(
                child: Text(
                  'Shuttle Settings',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
                ),
              ),
            ),
            cardBuilder(state.shuttles.keys
                .map((key) => SwitchListTile(
                      title: Text(key),
                      value: state.shuttles[key],
                      onChanged: (bool value) {
                        state.shuttles[key] = value;
                        BlocProvider.of<PrefsBloc>(context)
                            .add(SavePrefsEvent(key, value));
                        setState();
                      },
                      secondary: const Icon(Icons.directions_bus),
                    ))
                .toList()),

            // BUS SETTINGS
            Container(
              margin: EdgeInsets.fromLTRB(8, 15, 8, 0),
              child: Center(
                child: Text(
                  'Bus Settings',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
                ),
              ),
            ),
            cardBuilder(state.buses.keys
                .map((key) => SwitchListTile(
                      title: Text(key),
                      value: state.buses[key],
                      onChanged: (bool value) {
                        state.buses[key] = value;
                        BlocProvider.of<PrefsBloc>(context)
                            .add(SavePrefsEvent(key, value));
                        setState();
                      },
                      secondary: const Icon(Icons.directions_bus),
                    ))
                .toList()),

            // SAFE RIDE SETTINGS
            Container(
              margin: EdgeInsets.fromLTRB(8, 15, 8, 0),
              child: Center(
                child: Text(
                  'Safe Ride Settings',
                  style: TextStyle(fontWeight: FontWeight.bold, fontSize: 24),
                ),
              ),
            ),
            SizedBox(
              child: Stack(
                alignment: AlignmentDirectional.bottomCenter,
                children: <Widget>[
                  Padding(
                    padding: const EdgeInsets.all(25.0),
                    child: RaisedButton(
                        child: Text(
                          'SIGN OUT',
                          style: Theme.of(context).textTheme.button,
                        ),
                        onPressed: () {
                          BlocProvider.of<AuthenticationBloc>(context).add(
                            AuthenticationLoggedOut(),
                          );
                          Navigator.pop(context);
                        },
                        shape: RoundedRectangleBorder(
                            borderRadius: new BorderRadius.circular(20.0))),
                  ),
                ],
              ),
            )
          ])));
}