Skip to content

Commit

Permalink
API improvements (#17)
Browse files Browse the repository at this point in the history
* Major improvements
* Apply lint rules
  • Loading branch information
ahmednfwela authored Jan 8, 2022
1 parent 4322bae commit 1dbe01d
Show file tree
Hide file tree
Showing 30 changed files with 1,542 additions and 1,316 deletions.
23 changes: 23 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "example",
"cwd": "example",
"request": "launch",
"type": "dart",
"program": "lib/main.dart"
},
{
"name": "example (profile mode)",
"cwd": "example",
"request": "launch",
"type": "dart",
"flutterMode": "profile",
"program": "lib/main.dart"
}
]
}
11 changes: 10 additions & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,10 @@
include: package:pedantic/analysis_options.yaml
include: package:flutter_lints_plus/flutter.yaml

linter:
rules:
prefer_relative_imports: false
sort_pub_dependencies: false
# avoid_print: false # Uncomment to disable the `avoid_print` rule
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
24 changes: 14 additions & 10 deletions example/lib/InnerSwiper.dart → example/lib/inner_swiper.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import 'package:flutter/material.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/material.dart';

void main() => runApp(MyApp());
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
return const MaterialApp(
home: InnerSwiper(),
);
}
}

class InnerSwiper extends StatefulWidget {
const InnerSwiper({Key? key}) : super(key: key);

@override
State<StatefulWidget> createState() {
return _InnerSwiperState();
Expand Down Expand Up @@ -41,19 +45,19 @@ class _InnerSwiperState extends State<InnerSwiper> {
loop: false,
itemCount: 10,
controller: controller,
pagination: SwiperPagination(),
itemBuilder: (BuildContext context, int index) {
pagination: const SwiperPagination(),
itemBuilder: (context, index) {
return Column(
children: <Widget>[
SizedBox(
child: Swiper(
controller: controllers[index],
pagination: SwiperPagination(),
pagination: const SwiperPagination(),
itemCount: 4,
itemBuilder: (BuildContext context, int index) {
itemBuilder: (context, index) {
return Container(
color: Colors.greenAccent,
child: Text('jkfjkldsfjd'),
child: const Text('jkfjkldsfjd'),
);
},
autoplay: autoPlayer[index],
Expand All @@ -66,15 +70,15 @@ class _InnerSwiperState extends State<InnerSwiper> {
autoPlayer[index] = true;
});
},
child: Text('Start autoplay'),
child: const Text('Start autoplay'),
),
ElevatedButton(
onPressed: () {
setState(() {
autoPlayer[index] = false;
});
},
child: Text('End autoplay'),
child: const Text('End autoplay'),
),
Text('is autoplay: ${autoPlayer[index]}')
],
Expand Down
23 changes: 12 additions & 11 deletions example/lib/listener_test.dart
Original file line number Diff line number Diff line change
@@ -1,42 +1,43 @@
import 'package:flutter/material.dart';
import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

void main() => runApp(new MyApp());
void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return new MaterialApp(
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: new MyHomePage(title: 'Flutter Swiper'),
home: const MyHomePage(title: 'Flutter Swiper'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
const MyHomePage({Key? key, required this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => new _MyHomePageState();
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return new Scaffold(
body: new Swiper(
return Scaffold(
body: Swiper(
itemCount: 10,
itemBuilder: (c, i) {
return new Text("$i");
return Text('$i');
},
plugins: [],
plugins: const [],
),
);
}
Expand Down
Loading

0 comments on commit 1dbe01d

Please sign in to comment.