jhtoast 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

jhtoast pub package #


jhtoast - Flutter toast package. 支持的效果:文字,图文,加载中,水平垂直两种布局


pub地址:https://pub.flutter-io.cn/packages/jhtoast




使用 #

  1. Add this to your package's pubspec.yaml file:
dependencies:
  jhtoast: ^0.2.0

  1. Install it
flutter pub get

  1. Import it
import 'package:jhtoast/jhtoast.dart';

Examples #

  • 样式1 - 文字
    JhToast.showText(context, msg: "这是一条提示文字信息",
//      closeTime: 10
      );

  • 样式2 - 成功
  JhToast.showSuccess(context, msg: "加载成功");
  • 样式3 - 失败
 JhToast.showError(context, msg: "上传失败。请重新上传数据");
  • 样式4 - 警告
 JhToast.showInfo(context, msg: "注意!注意!注意!");
  • 样式5 - 加载中
    var hide =  JhToast.showLoadingText(context,
          msg:"正在加载中..."
      );
      Future.delayed(Duration(seconds: 2),(){
        hide();
      });

  • 样式6 - 水平加载中
    var hide =  JhToast.showLoadingText_horizontal(context,
          msg:"正在加载中..."
      );
      Future.delayed(Duration(seconds: 2),(){
        hide();
      });
          
  • 样式7 - 自定义图文

     Widget img = Image.asset("assets/images/toast_error.png");
    JhToast.showImageText(context,
      msg: "自定义图文",
      image: img);
              

  • 样式8 - 水平自定义图文
    Widget img = Image.asset("assets/images/toast_success.png");
    JhToast.showImageText_horizontal(context,
      msg: "水平自定义图文",
      image: img);

  • 样式9 - iOS样式加载中
       var hide =  JhToast.showLoadingText_iOS(context,
            msg:"正在加载中...",
          );
          Future.delayed(Duration(seconds: 2),(){
            hide();
          });
        }

ChangeLog #

[0.2.0] - 2020/03/18 #

  • TODO: change center style to center top

[0.1.0] - 2020/03/16 #

  • TODO: remove warning

[0.0.5] - 2020/03/15 #

  • TODO: add loading picture

[0.0.2] - 2020/03/15 #

  • TODO: Add click Android back key to hide toast

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'jhTextList.dart';
import 'package:jhtoast/jhtoast.dart';


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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner:false,
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home:ToastTestPage(),
    );
  }
}



class ToastTestPage extends StatelessWidget {

  final List titleData = ["文字","成功","失败","警告","加载中","水平加载中","自定义图文","水平自定义图文","iOS样式加载中"];

  @override
  Widget build(BuildContext context) {
    return  JhTextList(
      title: "JhToast",dataArr: titleData,
      callBack: (index,str){

        if(index==0){
          JhToast.showText(context, msg: "这是一条提示文字信息",
//              closeTime: 10
          );
        }
        if(index==1){
          JhToast.showSuccess(context, msg: "加载成功");
        }
        if(index==2){
          JhToast.showError(context, msg: "上传失败。请重新上传数据");
        }
        if(index==3){
          JhToast.showInfo(context, msg: "注意!注意!注意!");
        }
        if(index==4){
          var hide =  JhToast.showLoadingText(context,
              msg:"正在加载中..."
          );
          Future.delayed(Duration(seconds: 2),(){
            hide();
          });
        }

        if(index==5){
          var hide =  JhToast.showLoadingText_horizontal(context,
              msg:"正在加载中..."
          );
          Future.delayed(Duration(seconds: 2),(){
            hide();
          });

        }
        if(index==6){

          Widget img = Image.asset("assets/images/toast_error.png",package: "jhtoast",);
          JhToast.showImageText(context,
              msg: "自定义图文",
              image: img);
        }

        if(index==7){
          Widget img = Image.asset("assets/images/toast_success.png",package: "jhtoast");
          JhToast.showImageText_horizontal(context,
              msg: "水平自定义图文",
              image: img);
        }

        if(index==8){
          var hide =  JhToast.showLoadingText_iOS(context,
            msg:"正在加载中...",
          );
          Future.delayed(Duration(seconds: 2),(){
            hide();
          });
        }


      },
    );

  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jhtoast: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jhtoast/jhtoast.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
49
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package not compatible with SDK dart

because of import path [jhtoast] that is in a package requiring null.

Health suggestions

Fix lib/jhtoast.dart. (-1.49 points)

Analysis of lib/jhtoast.dart reported 3 hints:

line 65 col 17: Name non-constant identifiers using lowerCamelCase.

line 81 col 24: Name non-constant identifiers using lowerCamelCase.

line 88 col 24: Name non-constant identifiers using lowerCamelCase.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
back_button_interceptor ^4.2.3 4.2.4
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test