Skip to main content
ExodeUI

EXODEUI DESKTOP

A little space for good ideas.

Choose your platform to get the official ExodeUI installer.

Looking for Intel Mac or other builds? Explore the web studio or check all download options.

Prefer the browser? Try for free in your browser →
Cụm Figma Motionđọc 9 phút·Đội ngũ ExodeUI

Chuyển đổi Ảnh động nguyên mẫu Figma thành Widget Vật lý Flutter

Tìm hiểu cách xuất hoạt ảnh nguyên mẫu Figma thành mã Flutter SpringSimulation và AnimationController gốc với khoản nợ chuyển giao bằng 0.

Tóm tắt và định nghĩa

Điểm chính

Để dịch hoạt ảnh Figma sang Flutter, các nhà phát triển thường xây dựng AnimationControllers bằng CurvedAnimations. Tuy nhiên, cảm giác di động đích thực trong Flutter yêu cầu SpringSimulation và các cử chỉ dựa trên vật lý. ExodeUI chuyển các lớp vectơ trực quan và lực căng lò xo trực tiếp thành cây phụ tùng Flutter.

Tại sao CurvedAnimation trong Flutter lại gây thất vọng

Flutter cung cấp các Curves tiêu chuẩn (Curves.easeInOut, Curves.fastOutSlowIn), nhưng chúng có giới hạn về thời lượng. Nếu người dùng làm gián đoạn cử chỉ vuốt, đường cong thời lượng sẽ thay đổi. Bằng cách tận dụng SpringSimulation với SpringDescription(khối lượng, độ cứng, độ giảm chấn), hoạt ảnh Flutter trở nên hoàn toàn tự nhiên.

Đoạn mã triển khai thực tế

Triển khai component tương tác
// Flutter Spring Simulation Widget
import 'package:flutter/material.dart';
import 'package:flutter/physics.dart';

class SpringCard extends StatefulWidget {
  @override
  _SpringCardState createState() => _SpringCardState();
}

class _SpringCardState extends State<SpringCard> with SingleTickerProviderStateMixin {
  late AnimationController _controller;
  
  @override
  void initState() {
    super.initState();
    _controller = AnimationController(vsync: this);
  }

  void _runSpring(double target) {
    final spring = SpringDescription(mass: 1.0, stiffness: 420.0, damping: 24.0);
    final simulation = SpringSimulation(spring, _controller.value, target, 0);
    _controller.animateWith(simulation);
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTapDown: (_) => _runSpring(0.92),
      onTapUp: (_) => _runSpring(1.0),
      child: ScaleTransition(scale: _controller, child: Card(child: Text("Exode Flutter"))),
    );
  }
}

Hướng dẫn và ví dụ liên quan

Thiết kế UI tương tác một lần. Phát hành cùng một tệp.

Tạo trạng thái, vật lý lò xo và logic trực quan trong ExodeUI, rồi phát cùng một tệp trong React, SwiftUI, Flutter và hơn thế. Bắt đầu miễn phí.

Dùng thử miễn phí