uygulamam tam istediğim gibi çalışıyor. hesaplamaları uygulamada değilde excel üzerinden yapıp uygulama içerisinde gösteriyorum. bu yüzden de excel paketini kullanmayı düşünüyorum.
ancak aşağıdaki kodu
ByteData data = await rootBundle.load("assets/existing_excel_file.xlsx");
var bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes);
var excel = Excel.decodeBytes(bytes, update: true);
for (var table in excel.tables.keys) {
print(table); //sheet Name
print(excel.tables[table].maxCols);
print(excel.tables[table].maxRows);
for (var row in excel.tables[table].rows) {
print("$row");
}
}flutter uygulamamdaki sayfamda kullanmak istiyorum. ve sayfanın herhangi bir yerinden erişebilmek istiyorum . örneğin buton tıklamarında vs. sayfa kodlarım şu şekilde. yardımcı olabilecek var mı acaba?import 'package:eoscalculator/providers/AppStateProvider.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'dart:math';
import 'package:eoscalculator/models/emodal.dart' as emodal;
class EOSPage extends StatefulWidget {
@override
EOSPageState createState() {
return EOSPageState();
}
}
// Create a corresponding State class.
// This class holds data related to the form.
class EOSPageState extends State<EOSPage> {
// Create a global key that uniquely identifies the Form widget
// and allows validation of the form.
//
// Note: This is a GlobalKey<FormState>,
// not a GlobalKey<EOSPageState>.
final _formKey = GlobalKey<FormState>();
double multiplyResult;
@override
Widget build(BuildContext context) {
// Build a Form widget using the _formKey created above.
final provider = Provider.of<AppStateProvider>(context);
final multiplyFieldController = TextEditingController();
final multiplyFieldController2 = TextEditingController();
count() {
setState(() {
multiplyResult = double.parse(multiplyFieldController.text) *
provider.currentCompound.pc;
});
}
return Scaffold(
appBar: AppBar(
title: Text('EOS Hesaplama'),
),
body: Builder(
builder: (context) => Container(
child: Form(
key: _formKey,
child: Padding(
padding: const EdgeInsets.all(18.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
"Seçilen adı: " + provider.currentCompound?.name ??
"-"),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("PC değeri: " +
provider.currentCompound?.pc.toString()),
),
// TextFormField(
// validator: (value) {
// if (value.isEmpty) {
// return 'Please enter some text';
// }
// return null;
// },
// ),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Sıcaklık Değerini Giriniz"),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
decoration: new InputDecoration(
labelText: "Kelvin Cinsinden Sıcaklık Değeri",
fillColor: Colors.white,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
keyboardType: TextInputType.number,
controller: multiplyFieldController,
validator: (value) {
if (value.isEmpty) {
return 'Değer Giriniz';
}
return null;
},
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Basınç Değerini Giriniz"),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: TextFormField(
decoration: new InputDecoration(
labelText: "MPa cinsinden sıcaklık değeri",
fillColor: Colors.white,
border: new OutlineInputBorder(
borderRadius: new BorderRadius.circular(25.0),
borderSide: new BorderSide(),
),
//fillColor: Colors.green
),
keyboardType: TextInputType.number,
controller: multiplyFieldController2,
validator: (value2) {
if (value2.isEmpty) {
return 'Değer Girinizz';
}
return null;
},
),
),
Padding(
padding: const EdgeInsets.symmetric(vertical: 16.0),
child: ElevatedButton(
onPressed: () {
// Validate returns true if the form is valid, or false
// otherwise.
if (_formKey.currentState.validate()) {
// If the form is valid, display a Snackbar.
count();
Scaffold.of(context).showSnackBar(
SnackBar(content: Text('Hesaplanıyor...')));
}
},
child: Text('Hesapla'),
),
),
multiplyResult != null
? Text("Sonuç : " + multiplyResult.toString())
: Text(""),
],
),
),
),
),
),
);
}
}