locally 0.1.0+1 copy "locally: ^0.1.0+1" to clipboard
locally: ^0.1.0+1 copied to clipboard

outdated

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,
          title: title.text.toString(),
          body: title.text.toString(),
          appIcon: 'mipmap/ic_launcher',
          pageRoute: Navigator(context, MaterialPageRoute(builder: ( context ) =>
              SecondScreen(title: title.text, message: message.text,)))
      );
      locally.show();
    }
  }

  @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'
                  ),
                ),
              ),

            ],
          ),
        ),
      ),
    );
  }
}
70
likes
0
pub points
80%
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

License

unknown (license)

Dependencies

flutter, flutter_local_notifications

More

Packages that depend on locally