slider_view 1.0.0
slider_view: ^1.0.0 copied to clipboard
A slider view widget that supports custom type models and various configs.
example/lib/main.dart
// Copyright 2018 The FlutterCandies author. All rights reserved.
// Use of this source code is governed by an Apache license that can be found
// in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:slider_view/slider_view.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'slider_view example',
home: DemoPage(title: 'slider_view example'),
);
}
}
class DemoPage extends StatefulWidget {
const DemoPage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<DemoPage> createState() => _DemoPageState();
}
class _DemoPageState extends State<DemoPage> {
late List<String> characters = <String>[String.fromCharCode(_counter)];
int _counter = 64;
void _incrementCounter() {
setState(() {
++_counter;
characters.add(String.fromCharCode(_counter));
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SliderView(
config: SliderViewConfig<String>(
aspectRatio: 16 / 9,
models: characters,
itemBuilder: (String e) => Center(
child: Text(e, style: Theme.of(context).textTheme.headline3),
),
),
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}