Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
颤振中的蛇形杆不';不要在iOS上变得透明_Ios_Flutter - Fatal编程技术网

颤振中的蛇形杆不';不要在iOS上变得透明

颤振中的蛇形杆不';不要在iOS上变得透明,ios,flutter,Ios,Flutter,我遇到了一个问题,我得到了这个Snackbar,我希望它看起来像pciture1,它在安卓系统中运行良好,但在iOS系统中不起作用 在iOS中,它看起来像图片2 我不知道是什么导致了iOS的这种奇怪的差异 所以我的问题是:如何在iOS中实现picture1的设计? 注意:如果可能的话,我不想使用Toast或Flushbar 图片1: 图片2: Snackbar代码: import 'package:auto_size_text/auto_size_text.dart'; import 'pa

我遇到了一个问题,我得到了这个
Snackbar
,我希望它看起来像pciture1,它在安卓系统中运行良好,但在iOS系统中不起作用

在iOS中,它看起来像图片2

我不知道是什么导致了iOS的这种奇怪的差异

所以我的问题是:如何在iOS中实现picture1的设计?

注意:如果可能的话,我不想使用Toast或Flushbar

图片1:

图片2:

Snackbar
代码:

import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class SnackBarCustom {

  SnackBar snackBarCustom(final String title, final double height, final double width, final int maxLines) {
    return SnackBar(
      elevation: 1000,
      duration: Duration(seconds: 2),
      behavior: SnackBarBehavior.floating,
      backgroundColor: Colors.transparent,
      content: Padding(
        padding: EdgeInsets.symmetric(
          horizontal: width * 0.11,
          vertical: height * 0.06,
        ),
        child: Container(
          padding: EdgeInsets.symmetric(horizontal: width * 0.0075),
          height: height * 0.06,
          width: width,
          alignment: Alignment.center,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(height * 0.0374),
            color: const Color(0xFF555555).withOpacity(0.75),
          ),
          child: AutoSizeText(
            title,
            textAlign: TextAlign.center,
            style: GoogleFonts.montserrat(
              fontWeight: FontWeight.w700,
              fontSize: width * 0.32,
              color: const Color(0xFFFFFFFF),
              letterSpacing: 0.8,
            ),
            minFontSize: 5,
            maxFontSize: 14,
            maxLines: maxLines,
          ),
        ),
      ),
    );
  }

}

正如你所悲伤的,如果可能的话,你不想使用Toast,但我认为, 如果没有他们,要想实现你的目标绝非易事

所以我建议你使用FlightToast,它可以在IOS和Android上运行,而且使用方便

对于您想要的设计,您需要使用需要上下文的Toast

代码:

showToast(final FToast fToast, final String title, final double height, final double width, final int maxLines) {
    Widget toast = Container(
      padding: EdgeInsets.symmetric(horizontal: width * 0.015),
      height: height * 0.06,
      width: width * 0.55,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(height * 0.0374),
        color: const Color(0xFF555555).withOpacity(0.75),
      ),
      child: AutoSizeText(
        title,
        textAlign: TextAlign.center,
        style: GoogleFonts.montserrat(
          fontWeight: FontWeight.w700,
          fontSize: width * 0.32,
          color: const Color(0xFFFFFFFF),
          letterSpacing: 0.8,
          fontStyle: FontStyle.italic,
        ),
        minFontSize: 5,
        maxFontSize: 14,
        maxLines: maxLines,
      ),
    );


    fToast.showToast(
      child: toast,
      gravity: ToastGravity.BOTTOM,
      toastDuration: Duration(seconds: 2),
    );

  }
 FToast fToast;

  @override
  void initState() {
    super.initState();
    fToast = FToast();
    fToast.init(context);
  }
您还需要有一个FToast实例,它必须这样使用:

showToast(final FToast fToast, final String title, final double height, final double width, final int maxLines) {
    Widget toast = Container(
      padding: EdgeInsets.symmetric(horizontal: width * 0.015),
      height: height * 0.06,
      width: width * 0.55,
      alignment: Alignment.center,
      decoration: BoxDecoration(
        borderRadius: BorderRadius.circular(height * 0.0374),
        color: const Color(0xFF555555).withOpacity(0.75),
      ),
      child: AutoSizeText(
        title,
        textAlign: TextAlign.center,
        style: GoogleFonts.montserrat(
          fontWeight: FontWeight.w700,
          fontSize: width * 0.32,
          color: const Color(0xFFFFFFFF),
          letterSpacing: 0.8,
          fontStyle: FontStyle.italic,
        ),
        minFontSize: 5,
        maxFontSize: 14,
        maxLines: maxLines,
      ),
    );


    fToast.showToast(
      child: toast,
      gravity: ToastGravity.BOTTOM,
      toastDuration: Duration(seconds: 2),
    );

  }
 FToast fToast;

  @override
  void initState() {
    super.initState();
    fToast = FToast();
    fToast.init(context);
  }
有关更多信息,请查看: