mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-30 19:50:40 +00:00
- Bump all apps to sdk >=3.0.0 <4.0.0 and add flutter_lints + a shared analysis_options.yaml to every app (flutter analyze is now green repo-wide) - Fix real compile errors in firebase_google_authentication and image_editor, plus deprecated APIs (Matrix4, SvgPicture.color, textScaleFactor), missing async 'mounted' guards, and misc lints via dart fix + manual fixes - Align pubspec 'name' with each folder and Android namespace/applicationId with the documented github.nisrulz.* convention - Convert bmi_calculator from a legacy Flutter module to a standard app with a proper android/ scaffold; fix missing android:exported in launcher manifests across 22 apps so all Android builds pass - Untrack generated build files (GeneratedPluginRegistrant, .flutter-plugins-dependencies) and ignore them
94 lines
2.6 KiB
Dart
94 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:news_memes_app/services/getMemes.dart';
|
|
import 'package:share_plus/share_plus.dart';
|
|
|
|
class MemeScreen extends StatefulWidget {
|
|
const MemeScreen({super.key});
|
|
|
|
@override
|
|
_MemeScreenState createState() => _MemeScreenState();
|
|
}
|
|
|
|
class _MemeScreenState extends State<MemeScreen> {
|
|
List<dynamic> memeUrl = ['loading'];
|
|
bool memeLoading = true;
|
|
int index = 0;
|
|
|
|
void getMeme() async {
|
|
memeUrl = await showMemes();
|
|
setState(() {
|
|
memeLoading = false;
|
|
});
|
|
}
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
getMeme();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
backgroundColor: Color(0xFF28496E),
|
|
appBar: AppBar(
|
|
title: Text(
|
|
'Memes',
|
|
style: GoogleFonts.kanit(),
|
|
),
|
|
centerTitle: true,
|
|
actions: [
|
|
IconButton(
|
|
onPressed: () {
|
|
SharePlus.instance.share(ShareParams(text: memeUrl[index]));
|
|
},
|
|
icon: Icon(Icons.share_rounded))
|
|
],
|
|
),
|
|
bottomNavigationBar: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 20),
|
|
child: Text(
|
|
'Swipe Up for more!',
|
|
style: GoogleFonts.changa(
|
|
fontSize: 18,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
body: memeLoading
|
|
? Center(
|
|
child: CircularProgressIndicator(
|
|
color: Colors.white,
|
|
),
|
|
)
|
|
: Dismissible(
|
|
key: Key(memeUrl[index]),
|
|
direction: DismissDirection.up,
|
|
onDismissed: (direction) {
|
|
if (direction == DismissDirection.up) {
|
|
setState(() {
|
|
index++;
|
|
if (index == 10) {
|
|
index = 0;
|
|
memeUrl = ['loading'];
|
|
memeLoading = true;
|
|
getMeme();
|
|
}
|
|
});
|
|
}
|
|
},
|
|
child: Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(20),
|
|
image:
|
|
DecorationImage(image: NetworkImage(memeUrl[index]))),
|
|
),
|
|
));
|
|
}
|
|
}
|