Skip to content

Instantly share code, notes, and snippets.

@flutterfromscratch
Created August 12, 2022 00:36
Show Gist options
  • Select an option

  • Save flutterfromscratch/7049a156a6996bff16278fb20a967c33 to your computer and use it in GitHub Desktop.

Select an option

Save flutterfromscratch/7049a156a6996bff16278fb20a967c33 to your computer and use it in GitHub Desktop.
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter_acrylic/flutter_acrylic.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
if (Platform.isWindows) {
await Window.initialize();
await Window.setEffect(
effect: WindowEffect.aero,
color: Colors.black.withOpacity(0.6),
);
}
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final textController = new TextEditingController();
final globalKey = GlobalKey<ScaffoldState>();
final String fileName = 'textPadNote.txt';
Future<void> _exportToFile(BuildContext context) async {
final File file = File('${Directory.current.absolute.path}/${fileName}');
final snackBar = SnackBar(content: Text('Saved to: ${file.path}'));
await file.writeAsString(textController.text);
globalKey.currentState!.showSnackBar(snackBar);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
color: Colors.transparent,
title: 'TextPad',
theme: ThemeData(
brightness: Brightness.dark,
),
home: Scaffold(
backgroundColor: Colors.transparent,
key: globalKey,
appBar: AppBar(title: Text('TextPad'), actions: <Widget>[
IconButton(
icon: const Icon(Icons.save),
tooltip: 'Export to ${fileName}',
onPressed: () {
_exportToFile(context);
})
]),
body: Center(
child: TextField(
controller: textController,
maxLines: null,
keyboardType: TextInputType.multiline,
expands: true,
decoration: InputDecoration(
hintText: 'Play with your notes here...',
contentPadding: EdgeInsets.all(12.0)),
),
),
),
);
}
}
@manofgodjr
Copy link

This was helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment