Skip to content

Commit f6d5c3c

Browse files
sentry added
1 parent 441bf3e commit f6d5c3c

File tree

1 file changed

+10
-266
lines changed

1 file changed

+10
-266
lines changed

lib/main.dart

Lines changed: 10 additions & 266 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
import 'package:brain_fusion/brain_fusion.dart';
2-
import 'package:flutter/foundation.dart';
31
import 'package:flutter/material.dart';
4-
import 'package:flutter/services.dart';
5-
import 'package:lottie/lottie.dart';
6-
import 'package:url_launcher/url_launcher.dart';
2+
import 'package:sentry_flutter/sentry_flutter.dart';
3+
import 'package:text_to_image_gen/Pages/splash_screen.dart';
74

8-
/// The [main] function is the entry point of the application
9-
void main() {
10-
// Call the runApp function to start the app
11-
runApp(const MyApp());
5+
6+
Future<void> main() async {
7+
await SentryFlutter.init(
8+
(options) => options.dsn = 'https://725035c013bd4e7495b4fc7e472f6c5f@o4505074740953088.ingest.sentry.io/4505074742132736',
9+
appRunner: () => runApp(const MyApp()),
10+
);
1211
}
1312

14-
// The [MyApp] widget is the root widget of the app
1513
class MyApp extends StatelessWidget {
1614
const MyApp({Key? key}) : super(key: key);
1715

@@ -24,261 +22,7 @@ class MyApp extends StatelessWidget {
2422
cursorColor: Colors.deepPurple.shade400,
2523
),
2624
),
27-
home: const HomePage(),
25+
home: const SplashScreen(),
2826
);
2927
}
30-
}
31-
32-
class HomePage extends StatefulWidget {
33-
const HomePage({Key? key}) : super(key: key);
34-
35-
@override
36-
State<HomePage> createState() => _HomePageState();
37-
}
38-
39-
class _HomePageState extends State<HomePage> {
40-
// The text editing controller for the query.
41-
final TextEditingController _queryController = TextEditingController();
42-
43-
// Initializes the [AI] class from the 'brain_fusion' package.
44-
final AI _ai = AI();
45-
46-
// The boolean value to run the function.
47-
bool run = false;
48-
49-
// The [_generate] function to generate image data.
50-
Future<Uint8List> _generate(String query) async {
51-
// Call the runAI method with the required parameters.
52-
Uint8List image = await _ai.runAI(query, AIStyle.render3D);
53-
return image;
54-
}
55-
56-
@override
57-
void dispose() {
58-
// Dispose the [_queryController].
59-
_queryController.dispose();
60-
super.dispose();
61-
}
62-
63-
@override
64-
Widget build(BuildContext context) {
65-
return Scaffold(
66-
backgroundColor: Colors.deepPurple.shade50,
67-
appBar: AppBar(
68-
iconTheme: IconThemeData(color: Colors.deepPurple.shade400),
69-
backgroundColor: Colors.transparent,
70-
title: Text('Imagination Generator',
71-
style: TextStyle(color: Colors.deepPurple.shade400)),
72-
elevation: 0,
73-
centerTitle: true,
74-
),
75-
drawer: Drawer(
76-
child: Container(
77-
color: Colors.deepPurple.shade50,
78-
child: ListView(
79-
children: [
80-
Container(
81-
color: Colors.deepPurple.shade50,
82-
child: DrawerHeader(
83-
child: Center(
84-
child: Text(
85-
"TexFusion AI App",
86-
style: TextStyle(
87-
fontSize: 18, color: Colors.deepPurple.shade400),
88-
)),
89-
),
90-
),
91-
ListTile(
92-
leading: Icon(
93-
Icons.source_rounded,
94-
color: Colors.deepPurple.shade800,
95-
),
96-
title: Text(
97-
"Source Code",
98-
style: TextStyle(
99-
fontSize: 16, color: Colors.deepPurple.shade400),
100-
),
101-
onTap: () async {
102-
final Uri url =
103-
Uri.parse('https://github.com/VikramadityaDev/text_to_image_gen/');
104-
if (!await launchUrl(url,
105-
mode: LaunchMode.externalApplication)) {
106-
throw Exception('Could not launch $url');
107-
}
108-
},
109-
),
110-
ListTile(
111-
leading: Icon(
112-
Icons.update,
113-
color: Colors.deepPurple.shade800,
114-
),
115-
title: Text(
116-
"Check for update",
117-
style: TextStyle(
118-
fontSize: 16, color: Colors.deepPurple.shade400),
119-
),
120-
onTap: () async {
121-
final Uri url =
122-
Uri.parse('https://telegram.me/vikimediaofficial/');
123-
if (!await launchUrl(url,
124-
mode: LaunchMode.externalApplication)) {
125-
throw Exception('Could not launch $url');
126-
}
127-
},
128-
),
129-
],
130-
),
131-
),
132-
),
133-
body: Center(
134-
child: SingleChildScrollView(
135-
physics: const BouncingScrollPhysics(),
136-
child: Column(
137-
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
138-
crossAxisAlignment: CrossAxisAlignment.center,
139-
children: <Widget>[
140-
Padding(
141-
padding: const EdgeInsets.all(6.0),
142-
child: TextField(
143-
keyboardType: TextInputType.multiline,
144-
minLines: 1,
145-
maxLines: 10,
146-
controller: _queryController,
147-
decoration: InputDecoration(
148-
hintText: 'Enter your imagination...',
149-
enabledBorder: OutlineInputBorder(
150-
borderRadius: BorderRadius.circular(8),
151-
borderSide: BorderSide(
152-
width: 1.5, color: Colors.deepPurple.shade400),
153-
),
154-
focusedBorder: OutlineInputBorder(
155-
borderRadius: BorderRadius.circular(8),
156-
borderSide: BorderSide(
157-
width: 1.5, color: Colors.deepPurple.shade400),
158-
),
159-
),
160-
),
161-
),
162-
Padding(
163-
padding: const EdgeInsets.all(20),
164-
child: SizedBox(
165-
height: 500,
166-
width: MediaQuery.of(context).size.width,
167-
child: run
168-
? FutureBuilder<Uint8List>(
169-
// Call the [_generate] function to get the image data.
170-
future: _generate(_queryController.text),
171-
builder: (context, snapshot) {
172-
if (snapshot.connectionState ==
173-
ConnectionState.waiting) {
174-
// While waiting for the image data, display a loading indicator.
175-
return Padding(
176-
padding: const EdgeInsets.all(100.0),
177-
child: Lottie.asset(
178-
'assets/loading.json',
179-
repeat: true,
180-
reverse: true,
181-
animate: true,
182-
),
183-
);
184-
} else if (snapshot.hasError) {
185-
// If an error occurred while getting the image data, display an error message.
186-
return const Center(
187-
child: Text('Something went wrong. Please Re-generate.'));
188-
} else if (snapshot.hasData) {
189-
// If the image data is available, display the image using Image.memory().
190-
return Image.memory(snapshot.data!);
191-
} else {
192-
// If no data is available, display a placeholder or an empty container.
193-
return Container();
194-
}
195-
},
196-
)
197-
: const Center(
198-
child: Text(
199-
'See Magic Here 🪄',
200-
style: TextStyle(
201-
fontWeight: FontWeight.w500,
202-
fontSize: 16,
203-
),
204-
),
205-
),
206-
),
207-
),
208-
const SizedBox(
209-
height: 10,
210-
),
211-
Padding(
212-
padding: const EdgeInsets.only(left: 80, right: 80),
213-
child: ElevatedButton(
214-
onPressed: () {
215-
// Get the user input from the [_queryController].
216-
String query = _queryController.text;
217-
if (query.isNotEmpty) {
218-
// If the user input is not empty, set [run] to true to generate the image.
219-
setState(() {
220-
run = true;
221-
});
222-
} else {
223-
// If the user input is empty, print an error message.
224-
if (kDebugMode) {
225-
print('Query is empty !!');
226-
}
227-
}
228-
},
229-
style: ButtonStyle(
230-
padding: MaterialStateProperty.all(
231-
const EdgeInsets.all(0.0),
232-
),
233-
elevation: MaterialStateProperty.all(0),
234-
shape: MaterialStateProperty.all(
235-
RoundedRectangleBorder(
236-
borderRadius: BorderRadius.circular(5.0),
237-
),
238-
),
239-
),
240-
child: Ink(
241-
decoration: BoxDecoration(
242-
gradient: LinearGradient(
243-
colors: [
244-
Colors.deepPurple.shade400,
245-
Colors.deepPurpleAccent.shade200,
246-
],
247-
),
248-
borderRadius: const BorderRadius.all(
249-
Radius.circular(5.0),
250-
),
251-
),
252-
child: Container(
253-
constraints: const BoxConstraints(
254-
minWidth: 88.0,
255-
minHeight: 45.0,
256-
),
257-
alignment: Alignment.center,
258-
child: const Text(
259-
'Generate',
260-
textAlign: TextAlign.center,
261-
style: TextStyle(fontSize: 18),
262-
),
263-
),
264-
),
265-
),
266-
),
267-
const SizedBox(
268-
height: 12,
269-
),
270-
],
271-
),
272-
),
273-
),
274-
bottomNavigationBar: const Padding(
275-
padding: EdgeInsets.only(bottom: 8),
276-
child: Text(
277-
"Made With Love ❤️ VikiMedia",
278-
textAlign: TextAlign.center,
279-
style: TextStyle(fontSize: 12),
280-
),
281-
),
282-
);
283-
}
284-
}
28+
}

0 commit comments

Comments
 (0)