locally 1.0.5 copy "locally: ^1.0.5" to clipboard
locally: ^1.0.5 copied to clipboard

This package helps developers create local notification in flutter, it extends the flutter local notification package and tries to make usage more simple and user friendly.

example/lib/main.dart

import 'package:example/second_screen.dart';
import 'package:flutter/material.dart';
import 'package:locally/locally.dart';

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

class MyApp extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Locally Example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Locally Example'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

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

class _MyHomePageState extends State<MyHomePage> {

  var _formKey = GlobalKey<FormState>();
  TextEditingController title = TextEditingController();
  TextEditingController message = TextEditingController();

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  showMessage() {
    if(_formKey.currentState.validate()) {
      _formKey.currentState.save();
      Locally locally;

      locally = Locally(
          context: context,
          payload: 'test',
          pageRoute: MaterialPageRoute(builder: (context) => SecondScreen(title: title.text, message: message.text)),
          appIcon: 'mipmap/ic_launcher',
      );
      locally.show(title: title.text, message: message.text);

    }
  }

  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {
          showMessage();
        },
      ),
      body: Center(

        child: Form(
          key: _formKey,
          child: Column(

            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[

              Container(
                margin: EdgeInsets.all(20),
                child: TextFormField(
                  controller: title,
                  validator: (v){
                    return v.isEmpty ? 'Enter title' : null;
                  },
                  decoration: InputDecoration(
                      hintText: 'Title',
                      labelText: 'Title'
                  ),
                ),
              ),
              Container(
                margin: EdgeInsets.all(20),
                child: TextFormField(
                  controller: message,
                  validator: (v){
                    return v.isEmpty ? 'Enter message body' : null;
                  },
                  decoration: InputDecoration(
                      hintText: 'Message',
                      labelText: 'Message'
                  ),
                ),
              ),

            ],
          ),
        ),
      ),
    );
  }
}
69
likes
100
pub points
73%
popularity

Publisher

verified publishersamuelezedi.com

This package helps developers create local notification in flutter, it extends the flutter local notification package and tries to make usage more simple and user friendly.

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_local_notifications

More

Packages that depend on locally