toast_msg 0.0.6 copy "toast_msg: ^0.0.6" to clipboard
toast_msg: ^0.0.6 copied to clipboard

The toast custom easy to use.

example/lib/main.dart

import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:toast_msg/toast_msg_service.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  

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

  final _focusNode = FocusNode();


  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: GestureDetector(
        onTap: () => _focusNode.unfocus(),
        child: Scaffold(
          appBar: AppBar(
            title: const Text('Plugin example app'),
          ),
          body:  ToastMsgMain(
            margin: const EdgeInsets.symmetric(horizontal: 16),
            // positionValue: 200,
            child:  Column(
              children: [
                const Expanded(
                  child: Center(
                  child: Text('Hello!'),
                        ),
                ),
                TextField(autofocus: true, decoration: const InputDecoration(border: OutlineInputBorder()), focusNode: _focusNode,)
              ],
            )),
          floatingActionButton: ElevatedButton(onPressed: (){
            ToastMsgStream.instance.showToast(
              ToastData(
                // title: 'Test Msg', 
                customTitle: _buildCustomTitle(),
                backgroundColor: Colors.green, 
                titleStyle: const TextStyle(color: Colors.white),
                iconWidget: const Icon(Icons.info)
              ),
            );
          }, child: const Icon(Icons.publish)),
        ),
      ),
    );
  }

  Widget _buildCustomTitle() {
    return Text.rich(
                TextSpan(
                  style: const TextStyle(color: Colors.black),
                  children: [
                    const TextSpan(
                      text: 'Msg content',
                    ),
                    const TextSpan(text: ' '),
                    TextSpan(
                      text: 'click here!',
                      style: const TextStyle(color: Colors.red),
                      recognizer: TapGestureRecognizer()
                        ..onTap = () {
                          debugPrint('click here! tapped');
                        },
                    )
                  ],
                ),
              );
  }
}
1
likes
120
points
6
downloads

Publisher

verified publisherit36vn.com

Weekly Downloads

The toast custom easy to use.

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on toast_msg

Packages that implement toast_msg