小编Zer*_*chi的帖子

如何在ChoiceChip中实现透明背景?

我正在使用ChoiceChip小部件创建一组选择。我想让芯片在某些条件下具有透明背景,例如此图像

原来的

我试过把backgroundColor: Colors.transparent,但它会变成白色而不是透明。

问题

这是我的代码:


String _selectedSize = "";
var sizes = ['XS', 'S', 'M', 'L', 'XL'];

_customChip(size) => InkWell(
        child: Container(
          width: 40.0,
          height: 40.0,
          decoration: BoxDecoration(
            borderRadius: BorderRadius.circular(20.0),
            color: Colors.white,
          ),
          child: Stack(
            children: <Widget>[
              Center(child: Text(size, style: _chipTextStyle,)),
              Center(
                child: RotationTransition(
                  turns: AlwaysStoppedAnimation(315/360),
                  child: Container(height: 1.0, color: Colors.grey),
                ),
              ),
            ],
          ),
        ),
      );

      return Wrap(
        alignment: WrapAlignment.center,
        crossAxisAlignment: WrapCrossAlignment.center,
        children: sizes.map((size) {
          return ChoiceChip(
            pressElevation: 1.0,
            backgroundColor: Colors.transparent, // this doesn't work
            label: …
Run Code Online (Sandbox Code Playgroud)

flutter

8
推荐指数
2
解决办法
1960
查看次数

验证器将 TextFormField 推送到上方

我尝试使用TextFormField. 由于文本字段的高度对我来说太大了,我将TextFormFieldwith包裹起来Container并将其设置height为 50。现在的问题是,每当我提交了错误的值时,验证器就会弹出并推送文本字段,使高度比我的要小得多设置在Container.

提交前:

提交前

提交后:

在此处输入图片说明

这是我的代码:

Widget _emailForm() {
    return Form(
      key: _emailFormKey,
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.stretch,
        children: <Widget>[
          Text("Enter Your Email", style: TextStyle(fontSize: 13.0, fontWeight: FontWeight.bold),),
          Padding(padding: EdgeInsets.symmetric(vertical: 4.0),),
          Container(
            height: 50,
            child: TextFormField(
              focusNode: _emailFocusNode,
              style: TextStyle(fontSize: 11.0, fontWeight: FontWeight.w600),
              keyboardType: TextInputType.emailAddress,
              controller: _emailTextController,
              decoration: InputDecoration(
                isDense: true,
                focusedBorder: OutlineInputBorder(
                  borderRadius: BorderRadius.all(Radius.circular(0.0),),
                ),
                suffixIcon: IconButton(
                  alignment: Alignment.centerRight,
                  iconSize: 16.0,
                  icon: Icon(Icons.clear),
                  onPressed: () {
                    if(_emailTextController != null) { …
Run Code Online (Sandbox Code Playgroud)

flutter

7
推荐指数
1
解决办法
3076
查看次数

使用Telegram Bot从URL发送照片

我做了一个电报机器人,它根据请求使用pyTelegramBotAPI包装器发送照片.所以我尝试放置一个虚拟照片URL并测试机器人是否可以发送图像,但它失败并出现以下错误.

telebot.apihelper.ApiException: sendPhoto failed. Returned result: <Response [400]>

我不确定错误是什么,但如何正确地使用Telegram Bot API从URL发送照片?这是我的代码

import telebot
import time
import urllib
from io import BytesIO
from PIL import Image

TOKEN = '<token here>'
url='http://scontent-b.cdninstagram.com/hphotos-xfa1/t51.2885-15/e15/10919672_584633251672188_179950734_n.jpg'

def listener(*messages):
    for m in messages:
        chatid = m.chat.id
        if m.content_type == 'text':
            text = m.text
            name = m.fromUser.first_name
            msgid = m.message_id
            if(text.startswith('/photo')):
                img = BytesIO(urllib.request.urlopen(url).read())
                tb.send_chat_action(chatid, 'upload_photo')
                tb.send_photo(chatid, img, reply_to_message_id=msgid)


tb = telebot.TeleBot(TOKEN)
tb.get_update()  # cache exist message
tb.set_update_listener(listener) #register listener
tb.polling()
while True:
    time.sleep(1)
Run Code Online (Sandbox Code Playgroud)

我不确定我是否错过了一些东西.

python telegram-bot

6
推荐指数
1
解决办法
2万
查看次数

替代if-elif子句

我制作了一个脚本从booru画板下载.是否有任何替代方法可以使这个丑陋的if-elif子句看起来更简单,以防我想添加更多的booru图像板选择?谢谢.

def runbooru(tags, limit=0, booru="Danbooru"):
    tag = Danbooru(tags, limit)
    if booru == "Danbooru":
        tag = Danbooru(tags, limit)
    elif booru == "Gelbooru":
        tag = Gelbooru(tags, limit)
    elif booru == "Rule34":
        tag = Rule34(tags, limit)
    elif booru == "Konachan":
        tag = Konachan(tags, limit)
    elif booru == "Yandere":
        tag = Yandere(tags, limit)
    elif booru == "Safebooru":
        tag = Safebooru(tags, limit)
    return tag
Run Code Online (Sandbox Code Playgroud)

python

1
推荐指数
1
解决办法
217
查看次数

标签 统计

flutter ×2

python ×2

telegram-bot ×1