agent-workspace / novelforge-project /flutter /examples /api /lib /material /carousel /carousel.0.dart
agent-workspace / novelforge-project /flutter /examples /api /lib /material /carousel /carousel.0.dart
Download novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart from luom2645/agent-workspace: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/luom2645/agent-workspace/resolve/main/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart
- Command line
-
hf download hf://luom2645/agent-workspace/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart
-
curl -L -o carousel.0.dart https://huggingface.co/luom2645/agent-workspace/resolve/main/novelforge-project/flutter/examples/api/lib/material/carousel/carousel.0.dart
1.92 kB
| // Copyright 2014 The Flutter Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style license that can be | |
| // found in the LICENSE file. | |
| import 'package:flutter/material.dart'; | |
| /// Flutter code sample for [Carousel]. | |
| void main() => runApp(const CarouselExampleApp()); | |
| class CarouselExampleApp extends StatelessWidget { | |
| const CarouselExampleApp({super.key}); | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| debugShowCheckedModeBanner: false, | |
| home: Scaffold( | |
| appBar: AppBar( | |
| title: const Text('Carousel Sample'), | |
| ), | |
| body: const CarouselExample(), | |
| ), | |
| ); | |
| } | |
| } | |
| class CarouselExample extends StatefulWidget { | |
| const CarouselExample({super.key}); | |
| State<CarouselExample> createState() => _CarouselExampleState(); | |
| } | |
| class _CarouselExampleState extends State<CarouselExample> { | |
| Widget build(BuildContext context) { | |
| return Center( | |
| child: ConstrainedBox( | |
| constraints: const BoxConstraints(maxHeight: 200), | |
| child: CarouselView( | |
| itemExtent: 330, | |
| shrinkExtent: 200, | |
| children: List<Widget>.generate(20, (int index) { | |
| return UncontainedLayoutCard(index: index, label: 'Item $index'); | |
| }), | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |
| class UncontainedLayoutCard extends StatelessWidget { | |
| const UncontainedLayoutCard({ | |
| super.key, | |
| required this.index, | |
| required this.label, | |
| }); | |
| final int index; | |
| final String label; | |
| Widget build(BuildContext context) { | |
| return ColoredBox( | |
| color: Colors.primaries[index % Colors.primaries.length].withOpacity(0.5), | |
| child: Center( | |
| child: Text( | |
| label, | |
| style: const TextStyle(color: Colors.white, fontSize: 20), | |
| overflow: TextOverflow.clip, | |
| softWrap: false, | |
| ), | |
| ), | |
| ); | |
| } | |
| } | |