小编pas*_*sul的帖子

Flutter - 检测内容溢出并对其进行剪辑

我正在尝试将ClipRect与其中的Column一起使用,但它似乎效果不佳。

我想要实现的是剪辑列的内容并在溢出时显示文本消息(如果列的内容无法在可用空间内显示)。

你对我如何实现它有什么建议吗?

import 'package:flutter/material.dart';

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

class ContentOverflowDetectionApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Overflow detection"),
        ),
        body: Stack(
          fit: StackFit.expand,
          children: [
            ClipRect(
              child: Column(
                children: [
                  Container(
                    width: 300,
                    height: 400,
                    color: Colors.green[200],
                    child: Text('first widget'),
                  ),
                  Container(
                    width: 350,
                    height: 350,
                    color: Colors.yellow[200],
                    child: Text('overflowed widget'),
                  ),
                ],
              ),
            ),
            Positioned(
              child: Align(
                alignment: FractionalOffset.bottomCenter,
                child: Text("SHOW THIS TEXT ONLY IF …
Run Code Online (Sandbox Code Playgroud)

dart flutter

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

Flutter - 翻转动画 - 根据点击位置将卡片翻转到其右侧或左侧

我已经开始使用 Flutter,现在正在考虑如何实现卡片翻转动画的最佳方式。

我找到了这个Flip_card包,我正在尝试根据我的需要调整它的源代码

这是我现在拥有的应用程序:

import 'dart:math';
import 'package:flutter/material.dart';

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

class FlipAnimationApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("Flip animation"),
        ),
        body: Center(
          child: Container(
            width: 200,
            height: 200,
            child: WidgetFlipper(
              frontWidget: Container(
                color: Colors.green[200],
                child: Center(
                  child: Text(
                    "FRONT side.",
                  ),
                ),
              ),
              backWidget: Container(
                color: Colors.yellow[200],
                child: Center(
                  child: Text(
                    "BACK side.",
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

class …
Run Code Online (Sandbox Code Playgroud)

flutter flutter-animation

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

标签 统计

flutter ×2

dart ×1

flutter-animation ×1