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

middle

Hãy phân biệt AsyncAsync* trong Flutter?

entry

Dart là gì? Vì sao Google sử dụng Dart cho Flutter

junior

Widget là gì? Nêu tầm quan trọng của nó trong Flutter.

Bình luận

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

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