Skip to content

Commit

Permalink
add hint
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Apr 29, 2024
1 parent 6394495 commit 8e87c60
Show file tree
Hide file tree
Showing 137 changed files with 3,098 additions and 2,975 deletions.
11 changes: 11 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
include: package:flutter_lints/flutter.yaml

analyzer:
errors:
mixin_inherits_from_not_object: ignore

linter:
rules:
library_private_types_in_public_api: false
constant_identifier_names: false
library_prefixes: false
67 changes: 36 additions & 31 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gsy_flutter_demo/widget/align_demo_page.dart'
deferred as align_demo_page;
Expand Down Expand Up @@ -213,9 +214,11 @@ import 'package:gsy_flutter_demo/widget/pageview_in_pageview_demo_page.dart'

import 'package:window_location_href/window_location_href.dart';

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

class MyApp extends StatelessWidget {
const MyApp({super.key});

// This widget is the root of your application.
@override
Widget build(BuildContext context) {
Expand All @@ -224,34 +227,36 @@ class MyApp extends StatelessWidget {
theme: ThemeData(
useMaterial3: false,
primarySwatch: Colors.blue,
textButtonTheme: TextButtonThemeData(
textButtonTheme: const TextButtonThemeData(
// 去掉 TextButton 的水波纹效果
style: ButtonStyle(splashFactory: NoSplash.splashFactory),
),
),
home: MyHomePage(title: 'GSY Flutter Demo'),
home: const MyHomePage(title: 'GSY Flutter Demo'),
routes: routers,
);
}
}

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

final String? title;

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

class _MyHomePageState extends State<MyHomePage> {
class MyHomePageState extends State<MyHomePage> {
@override
void initState() {
//loadLibrary();
super.initState();
print("get enum value with 2.15 ${Cat.white.name}");
print("get enum value with 2.15 ${Cat.values.byName("black")}");
print("get enum value with 2.17 ${Cat.white.value} ${Cat.white}");
if (kDebugMode) {
print("get enum value with 2.15 ${Cat.white.name}");
print("get enum value with 2.15 ${Cat.values.byName("black")}");
print("get enum value with 2.17 ${Cat.white.value} ${Cat.white}");
}

final href = getHref();
int? index = href?.indexOf("#");
Expand All @@ -276,25 +281,23 @@ class _MyHomePageState extends State<MyHomePage> {
appBar: AppBar(
title: Text(widget.title!),
),
body: new Container(
child: new ListView.builder(
itemBuilder: (context, index) {
return new InkWell(
onTap: () {
Navigator.of(context).pushNamed(routeLists[index]);
},
child: new Card(
child: new Container(
alignment: Alignment.centerLeft,
margin: EdgeInsets.symmetric(horizontal: 10),
height: 50,
child: new Text(routers.keys.toList()[index]),
),
body: ListView.builder(
itemBuilder: (context, index) {
return InkWell(
onTap: () {
Navigator.of(context).pushNamed(routeLists[index]);
},
child: Card(
child: Container(
alignment: Alignment.centerLeft,
margin: const EdgeInsets.symmetric(horizontal: 10),
height: 50,
child: Text(routers.keys.toList()[index]),
),
);
},
itemCount: routers.length,
),
),
);
},
itemCount: routers.length,
), // This trailing comma makes auto-formatting nicer for build methods.
);
}
Expand All @@ -307,7 +310,7 @@ class ContainerAsyncRouterPage extends StatelessWidget {
///稍后更新文章到掘金
final WidgetBuilder child;

ContainerAsyncRouterPage(this.libraryFuture, this.child);
const ContainerAsyncRouterPage(this.libraryFuture, this.child, {super.key});

@override
Widget build(BuildContext context) {
Expand All @@ -322,7 +325,7 @@ class ContainerAsyncRouterPage extends StatelessWidget {
alignment: Alignment.center,
child: Text(
'Error: ${s.error}',
style: TextStyle(color: Colors.red),
style: const TextStyle(color: Colors.red),
),
),
);
Expand All @@ -333,7 +336,7 @@ class ContainerAsyncRouterPage extends StatelessWidget {
appBar: AppBar(),
body: Container(
alignment: Alignment.center,
child: CircularProgressIndicator(),
child: const CircularProgressIndicator(),
),
);
});
Expand Down Expand Up @@ -940,6 +943,8 @@ extension CatExtension on Cat {
// }

void talk() {
print('meow');
if (kDebugMode) {
print('meow');
}
}
}
20 changes: 11 additions & 9 deletions lib/widget/align_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,24 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';

class AlignDemoPage extends StatefulWidget {
const AlignDemoPage({super.key});

@override
_AlignDemoPageState createState() => _AlignDemoPageState();
AlignDemoPageState createState() => AlignDemoPageState();
}

class _AlignDemoPageState extends State<AlignDemoPage>
class AlignDemoPageState extends State<AlignDemoPage>
with SingleTickerProviderStateMixin {
getAlign(x) {
return Align(
child: new Container(
alignment: Alignment(math.cos(x * math.pi), math.sin(x * math.pi)),
child: Container(
height: 20,
width: 20,
decoration: BoxDecoration(
decoration: const BoxDecoration(
color: Colors.green,
borderRadius: BorderRadius.all(Radius.circular(10))),
),
alignment: Alignment(math.cos(x * math.pi), math.sin(x * math.pi)),
);
}

Expand All @@ -26,11 +28,11 @@ class _AlignDemoPageState extends State<AlignDemoPage>
int size = 20;
return Scaffold(
appBar: AppBar(
title: new Text("AlignDemoPage"),
title: const Text("AlignDemoPage"),
),
body: new Container(
alignment: Alignment(0, 0),
child: Container(
body: Container(
alignment: const Alignment(0, 0),
child: SizedBox(
height: MediaQuery.sizeOf(context).width,
width: MediaQuery.sizeOf(context).width,
child: Stack(
Expand Down
30 changes: 17 additions & 13 deletions lib/widget/anim_bg_demo_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,36 @@ import 'package:supercharged/supercharged.dart';
enum _ColorTween { color1, color2 }

class AnimBgDemoPage extends StatelessWidget {
const AnimBgDemoPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: new Text("AnimBgDemoPage"),
title: const Text("AnimBgDemoPage"),
),
body: Stack(
children: <Widget>[
Positioned.fill(child: AnimatedBackground()),
onBottom(AnimatedWave(
const Positioned.fill(child: AnimatedBackground()),
onBottom(const AnimatedWave(
height: 180,
speed: 1.0,
)),
onBottom(AnimatedWave(
onBottom(const AnimatedWave(
height: 120,
speed: 0.9,
offset: pi,
)),
onBottom(AnimatedWave(
onBottom(const AnimatedWave(
height: 220,
speed: 1.2,
offset: pi / 2,
)),
Positioned.fill(
child: new Center(
child: new Text(
const Positioned.fill(
child: Center(
child: Text(
"GSY Flutter Demo",
style: new TextStyle(
style: TextStyle(
fontSize: 30,
fontWeight: FontWeight.bold,
color: Colors.white),
Expand All @@ -57,12 +59,12 @@ class AnimatedWave extends StatelessWidget {
final double? speed;
final double offset;

AnimatedWave({this.height, this.speed, this.offset = 0.0});
const AnimatedWave({super.key, this.height, this.speed, this.offset = 0.0});

@override
Widget build(BuildContext context) {
return LayoutBuilder(builder: (context, constraints) {
return Container(
return SizedBox(
height: height,
width: constraints.biggest.width,
child: LoopAnimationBuilder<double>(
Expand Down Expand Up @@ -112,17 +114,19 @@ class CurvePainter extends CustomPainter {
}

class AnimatedBackground extends StatelessWidget {
const AnimatedBackground({super.key});

@override
Widget build(BuildContext context) {
final tween = MovieTween()
..tween(
_ColorTween.color1,
Color(0xffD38312).tweenTo(Colors.lightBlue.shade900),
const Color(0xffD38312).tweenTo(Colors.lightBlue.shade900),
duration: 3.seconds,
)
..tween(
_ColorTween.color2,
Color(0xffA83279).tweenTo(Colors.blue.shade600),
const Color(0xffA83279).tweenTo(Colors.blue.shade600),
duration: 3.seconds,
);

Expand Down
22 changes: 14 additions & 8 deletions lib/widget/anim_bubble_gum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ import 'package:flutter/material.dart';
/// https://codepen.io/rx-labz/pen/xxwdGaM?__cf_chl_jschl_tk__=830b2fd03dd1ccb9ac8d7c1fdbdee39e71fc2e7c-1587971334-0-AQ6h_JKRflUPLJcJhlH7eT841oCDgD5EttuC0cq9I50PQHwBtecDMdA9H-_a9FitSk4HQwlPO3dvvYn83act0FI6ufSlRL7MCB-gJVkKQov2i-AVA92X3KFwD93JOfog1LMy9yTdUyNb1zr43ZgC2X-cg0IsMGPr6U54kAb40AQgoK-KbYc9-KYWUIFqFy8pShOZIfn23-0lInSjKlJ3p8rnLXp84p7rhdTNrQU0pWPKNiDkuuthEaqzi9THfk4-iTrZ3CJ6wU0t81T9GyKwIT5VthFlnuPyNqIKseggtyxBxgZJ4W4ec6FmQoFp7bYAQF9rFb3D5L_3juEL-262JH_TP20ojcgjb30pvNnHyTfh
class AnimBubbleGumDemoPage extends StatelessWidget {
const AnimBubbleGumDemoPage({super.key});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("AnimBubbleGumDemoPage"),
title: const Text("AnimBubbleGumDemoPage"),
),
body: Container(color: Colors.pink[200], child: AnimBubbleGum()),
body: Container(color: Colors.pink[200], child: const AnimBubbleGum()),
);
}
}
Expand All @@ -40,18 +42,20 @@ class Circle {
}

class AnimBubbleGum extends StatefulWidget {
const AnimBubbleGum({super.key});

@override
_AnimBubbleGumState createState() => _AnimBubbleGumState();
AnimBubbleGumState createState() => AnimBubbleGumState();
}

class _AnimBubbleGumState extends State<AnimBubbleGum> {
class AnimBubbleGumState extends State<AnimBubbleGum> {
late Timer timer;

final circles = <Circle>[];

late Size size;

Offset force = Offset(1, 1);
Offset force = const Offset(1, 1);

HSLColor hslColor = HSLColor.fromColor(Colors.pink[100]!);

Expand All @@ -70,7 +74,7 @@ class _AnimBubbleGumState extends State<AnimBubbleGum> {
timer = Timer.periodic(
frequency,
(t) {
if (circles.isEmpty)
if (circles.isEmpty) {
_circleStreamer.add(
circles
..add(
Expand All @@ -81,6 +85,7 @@ class _AnimBubbleGumState extends State<AnimBubbleGum> {
),
),
);
}
int count = 0;
while (count < 29) {
final p = // newPoint
Expand Down Expand Up @@ -118,7 +123,7 @@ class _AnimBubbleGumState extends State<AnimBubbleGum> {
Widget build(BuildContext context) => Stack(
children: [
StreamBuilder<List<Circle>>(
initialData: [],
initialData: const [],
stream: _circle$.map(
(event) => event.length > numCircles
? event
Expand Down Expand Up @@ -164,11 +169,12 @@ class Painter extends CustomPainter {
c.offset! - Offset(0, c.radius),
c.radius,
[
Color(0x53ffffff),
const Color(0x53ffffff),
Colors.transparent,
],
);
}
// ignore: empty_catches
} catch (e) {}
//too heavy for mobile web rendering

Expand Down
Loading

0 comments on commit 8e87c60

Please sign in to comment.