Skip to content

Commit bb85312

Browse files
committed
Circle first version!
1 parent b704d7a commit bb85312

File tree

2 files changed

+60
-6
lines changed

2 files changed

+60
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import 'package:flutter/material.dart';
2+
3+
class CirclesHomeWidget extends StatefulWidget {
4+
@override
5+
State<StatefulWidget> createState() => _CircleHomeState();
6+
}
7+
8+
class _CircleHomeState extends State<CirclesHomeWidget> {
9+
@override
10+
Widget build(BuildContext context) {
11+
return Scaffold(
12+
body: ScrollableCircleGrid(),
13+
);
14+
}
15+
}
16+
17+
class ScrollableCircleGrid extends StatefulWidget {
18+
@override
19+
_ScrollableCircleGridState createState() => _ScrollableCircleGridState();
20+
}
21+
22+
class _ScrollableCircleGridState extends State<ScrollableCircleGrid> {
23+
int? selectedIndex;
24+
25+
@override
26+
Widget build(BuildContext context) {
27+
return GridView.builder(
28+
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
29+
crossAxisCount: 5,
30+
childAspectRatio: 1,
31+
),
32+
itemBuilder: (context, index) {
33+
bool isSelected = selectedIndex == index;
34+
return GestureDetector(
35+
onTap: () {
36+
setState(() {
37+
selectedIndex = isSelected ? null : index;
38+
});
39+
},
40+
child: AnimatedContainer(
41+
duration: Duration(milliseconds: 300),
42+
margin: EdgeInsets.all(isSelected ? 8 : 4),
43+
decoration: BoxDecoration(
44+
shape: BoxShape.circle,
45+
color: isSelected ? Colors.white : Colors.grey,
46+
),
47+
child: Center(
48+
child: Text('Friend $index'),
49+
),
50+
),
51+
);
52+
},
53+
);
54+
}
55+
}

lib/main.dart

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import 'package:flutter/material.dart';
22
import 'package:fx_2_folder/books/books.dart';
3+
import 'package:fx_2_folder/circles_selector/CirclesHomeWidget.dart';
34
import 'package:fx_2_folder/folder_shape/folder_home.dart';
45
import 'package:google_fonts/google_fonts.dart';
56

@@ -42,12 +43,10 @@ class HomeScreen extends StatelessWidget {
4243
builder: (context) =>
4344
const BookShelfPage(title: 'Flutter Demo Home Page'),
4445
),
45-
// AnimationExample(
46-
// title: 'Smoke',
47-
// builder: (context) => const FolderHomeWidget(
48-
// curve: Curves.easeInOutBack, title: 'EaseInOutBack'),
49-
// ),
50-
// Add more examples here
46+
AnimationExample(
47+
title: 'CircleSelector',
48+
builder: (context) => CirclesHomeWidget(),
49+
),
5150
];
5251

5352
@override

0 commit comments

Comments
 (0)