juvee_multiselect 0.0.1
juvee_multiselect: ^0.0.1 copied to clipboard
multiselection package for juvee project
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:juvee_multiselect/bottom_sheet/multi_select_bottom_sheet_field.dart';
import 'package:juvee_multiselect/util/multi_select_item.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Multi Select',
theme: ThemeData(
primarySwatch: Colors.purple,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Multi Select'),
);
}
}
class Animal {
final int id;
final String name;
Animal({
this.id,
this.name,
});
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
static List<Animal> _animals = [
Animal(id: 1, name: "Lion"),
Animal(id: 2, name: "Flamingo"),
Animal(id: 3, name: "Hippo"),
Animal(id: 4, name: "Horse"),
Animal(id: 5, name: "Tiger"),
Animal(id: 6, name: "Penguin"),
Animal(id: 7, name: "Spider"),
Animal(id: 8, name: "Snake"),
Animal(id: 9, name: "Bear"),
Animal(id: 10, name: "Beaver"),
Animal(id: 11, name: "Cat"),
Animal(id: 12, name: "Fish"),
Animal(id: 13, name: "Rabbit"),
Animal(id: 14, name: "Mouse"),
Animal(id: 15, name: "Dog"),
Animal(id: 16, name: "Zebra"),
Animal(id: 17, name: "Cow"),
Animal(id: 18, name: "Frog"),
Animal(id: 19, name: "Blue Jay"),
Animal(id: 20, name: "Moose"),
Animal(id: 21, name: "Gecko"),
];
final _items = _animals
.map((animal) => MultiSelectItem<Animal>(animal.id, animal.name))
.toList();
//List<Animal> _selectedAnimals = [];
List<Animal> _selectedAnimals2 = [];
List<Animal> _selectedAnimals3 = [];
//List<Animal> _selectedAnimals4 = [];
final _multiSelectKey = GlobalKey<FormFieldState>();
List<MultiSelectItem<dynamic>> l = [];
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: SingleChildScrollView(
child: Container(
alignment: Alignment.center,
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
SizedBox(height: 40),
MultiSelectBottomSheetField(
enableSingleSelection: false,
searchable: true,
enableTag: true,
decoration: BoxDecoration(
border: Border.all(
color: Color.fromARGB(255, 12, 1, 0),
),
borderRadius: BorderRadius.all(Radius.circular(20))),
items: _items,
onSelectionChanged: (values) {
// List list=values;
print(values.toString());
},
),
],
),
),
),
);
}
}