Câu hỏi phỏng vấn Flutter
Câu hỏi

Làm sao để tạo animation đơn giản với AnimatedContainer?

Câu trả lời

markdown Copy
Để tạo animation đơn giản với `AnimatedContainer`, bạn cần chú ý các bước chính: **khởi tạo** `AnimatedContainer` với các thuộc tính như `width`, `height`, `color`, vv. mà bạn muốn thay đổi. **Thay đổi giá trị** các thuộc tính thông qua hàm setState để kích hoạt animation. **Chọn duration** phù hợp để animation diễn ra mượt mà. 

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('AnimatedContainer Demo')),
        body: Center(child: AnimatedContainerDemo()),
      ),
    );
  }
}

class AnimatedContainerDemo extends StatefulWidget {
  @override
  _AnimatedContainerDemoState createState() => _AnimatedContainerDemoState();
}

class _AnimatedContainerDemoState extends State<AnimatedContainerDemo> {
  double _width = 200.0;
  ...
middle

middle

Gợi ý câu hỏi phỏng vấn

junior

Kể tên các cơ sở dữ liệu được dùng nhiều nhất trong Flutter?

senior

Bạn tổ chức folder structure trong project Flutter lớn như thế nào?

middle

Bạn hiểu gì về tween animation trong Flutter?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào